Skip to content

Commit

Permalink
debugged
Browse files Browse the repository at this point in the history
  • Loading branch information
LiyuanLucasLiu committed Sep 14, 2017
1 parent 7aa7c52 commit c824ff7
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions model/crf.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ def repack_vb(self, feature, target, mask):
"""packer for viterbi loss
args:
- **feature** (Seq_len, Batch_size): input feature
- **target** (Seq_len, Batch_size): output target
- **mask** (Seq_len, Batch_size): padding mask
outputs:
- **feature**, **target**, **mask**
feature (Seq_len, Batch_size): input feature
target (Seq_len, Batch_size): output target
mask (Seq_len, Batch_size): padding mask
return:
feature, target, mask
"""

if self.if_cuda:
Expand All @@ -118,13 +118,13 @@ def repack_gd(self, feature, target, current):
"""packer for greedy loss
args:
feature: input feature, of size Seq_len * Batch_size
target: output target, of size Seq_len * Batch_size
current: current state, of size Seq_len * Batch_size
outputs:
feature: input feature, of size Batch_size * Seq_len
target: output target, of size (Seq_len * Batch_size)
current: current state, of size (Seq_len * Batch_size) * 1 * 1
feature (Seq_len, Batch_size): input feature
target (Seq_len, Batch_size): output target
current (Seq_len, Batch_size): current state
return:
feature (Seq_len, Batch_size): input feature
target (Seq_len * Batch_size): output target
current (Seq_len * Batch_size, 1, 1): current state
"""
if self.if_cuda:
fea_v = autograd.Variable(feature.transpose(0, 1)).cuda()
Expand All @@ -144,15 +144,14 @@ def convert_for_eval(self, target):

class CRFRepack_WC:
"""Packer for model with char-level and word-level
args:
tagset_size: target_set_size
if_cuda: whether use GPU
"""

def __init__(self, tagset_size, if_cuda):
"""Constructor
args:
tagset_size: target_set_size
if_cuda: whether use GPU
"""

self.tagset_size = tagset_size
self.if_cuda = if_cuda

Expand All @@ -168,7 +167,7 @@ def repack_vb(self, f_f, f_p, b_f, b_p, w_f, target, mask, len_b):
target: output target, of size Seq_len * Batch_size
mask: padding mask, of size Word_Seq_len * Batch_size
len_b: length of instances in one batch, of size Batch_size
output:
return :
f_f: forward_char input feature, of size Char_Reduced_Seq_len * Batch_size
f_p: forward_char input position w.r.t. shortest length, of size Word_Reduced_Seq_len * Batch_size
b_f: backward_char input feature, of size Char_Reduced_Seq_len * Batch_size
Expand Down

0 comments on commit c824ff7

Please sign in to comment.