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

fix #2

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: 3 additions & 3 deletions week8_scst/basic_model_torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def translate(self, inp, greedy=False, max_len = None, eps = 1e-30, **flags):

def infer_mask(seq, eos_ix, batch_first=True, include_eos=True, type=torch.FloatTensor):
"""
compute length given output indices and eos code
compute mask given output indices and eos code
:param seq: tf matrix [time,batch] if batch_first else [batch,time]
:param eos_ix: integer index of end-of-sentence token
:param include_eos: if True, the time-step where eos first occurs is has mask = 1
Expand All @@ -136,8 +136,8 @@ def infer_mask(seq, eos_ix, batch_first=True, include_eos=True, type=torch.Float

def infer_length(seq, eos_ix, batch_first=True, include_eos=True, type=torch.LongTensor):
"""
compute mask given output indices and eos code
:param seq: tf matrix [time,batch] if time_major else [batch,time]
compute length given output indices and eos code
:param seq: tf matrix [time,batch] if batch_first else [batch,time]
:param eos_ix: integer index of end-of-sentence token
:param include_eos: if True, the time-step where eos first occurs is has mask = 1
:returns: mask, float32 matrix with '0's and '1's of same shape as seq
Expand Down