Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
BiTransDPI
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
CI / CD
CI / CD
流水线
日程表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
提交
问题看板
Open sidebar
杨志辉
BiTransDPI
Commits
e5d444a3
提交
e5d444a3
authored
6月 09, 2021
作者:
朱学凯
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix pad_1
上级
fc1caac2
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
5 行增加
和
11 行删除
+5
-11
dataset.py
dataset.py
+1
-0
test.py
test.py
+4
-11
没有找到文件。
dataset.py
浏览文件 @
e5d444a3
...
@@ -188,6 +188,7 @@ class Data_Encoder_mol(data.Dataset):
...
@@ -188,6 +188,7 @@ class Data_Encoder_mol(data.Dataset):
token_type_ids
=
np
.
concatenate
((
np
.
zeros
((
len
(
d
)
+
2
),
dtype
=
np
.
int
),
np
.
ones
((
len
(
p
)
+
1
),
dtype
=
np
.
int
)))
token_type_ids
=
np
.
concatenate
((
np
.
zeros
((
len
(
d
)
+
2
),
dtype
=
np
.
int
),
np
.
ones
((
len
(
p
)
+
1
),
dtype
=
np
.
int
)))
if
len
(
input_seq
)
>
self
.
max_len
:
if
len
(
input_seq
)
>
self
.
max_len
:
input_seq
=
input_seq
[:
self
.
max_len
-
1
]
+
[
self
.
sep_id
]
input_seq
=
input_seq
[:
self
.
max_len
-
1
]
+
[
self
.
sep_id
]
token_type_ids
=
token_type_ids
[:
self
.
max_len
]
else
:
else
:
token_type_ids
=
np
.
pad
(
token_type_ids
,
(
0
,
self
.
max_len
-
len
(
input_seq
)),
'constant'
,
constant_values
=
0
)
token_type_ids
=
np
.
pad
(
token_type_ids
,
(
0
,
self
.
max_len
-
len
(
input_seq
)),
'constant'
,
constant_values
=
0
)
input
,
input_mask
=
seq2emb_encoder
(
input_seq
,
self
.
max_len
,
self
.
vocab
)
input
,
input_mask
=
seq2emb_encoder
(
input_seq
,
self
.
max_len
,
self
.
vocab
)
...
...
test.py
浏览文件 @
e5d444a3
from
transformers
import
BertTokenizer
from
transformers
import
BertTokenizer
from
modeling_bert
import
BertForMaskedLM
from
modeling_bert
import
BertForMaskedLM
import
torch
import
torch
import
numpy
as
np
tokenizer
=
BertTokenizer
.
from_pretrained
(
'bert-base-uncased'
)
a
=
np
.
ones
((
5
))
# model = BertForMaskedLM.from_pretrained('bert-base-uncased')
seq_a
=
"The capital of France is [MASK]."
seq_b
=
"The capital of France is Paris."
choice0
=
"It is eaten with a fork and a knife."
choice1
=
"It is eaten while held in the hand."
inputs
=
tokenizer
([[
seq_a
,
seq_b
],
[
choice0
,
choice1
]],
padding
=
True
)
labels
=
tokenizer
(
"The capital of France is Paris."
,
return_tensors
=
"pt"
)
#["input_ids"]
b
=
a
[:
4
]
print
(
'----------------'
)
print
(
'----------------'
)
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论