Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#76 Fix Type to be correct in Assert bsz % 2 #106

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,6 @@ def relative_positional_encoding(qlen, klen, d_model, clamp_len, attn_type,
bwd_pos_seq = tf.clip_by_value(bwd_pos_seq, -clamp_len, clamp_len)

if bsz is not None:
# With bi_data, the batch size should be divisible by 2.
assert bsz%2 == 0
fwd_pos_emb = positional_embedding(fwd_pos_seq, inv_freq, bsz//2)
bwd_pos_emb = positional_embedding(bwd_pos_seq, inv_freq, bsz//2)
else:
Expand Down Expand Up @@ -472,6 +470,10 @@ def transformer_xl(inp_k, n_token, n_layer, d_model, n_head,
mlen = tf.shape(mems[0])[0] if mems is not None else 0
klen = mlen + qlen

# With bi_data, the batch size should be divisible by 2.
if bi_data:
assert (inp_k.shape[1] % 2) == 0

##### Attention mask
# causal attention mask
if attn_type == 'uni':
Expand Down