Merge pull request #791 from Jackwaterveg/fix_bug

Fix bug of paddling len for "def forward_chunk_by_chunk"
pull/792/head
Hui Zhang 3 years ago committed by TianYuan
commit b874d84671

@ -180,8 +180,10 @@ class CRNNEncoder(nn.Layer):
eouts_chunk_list = [] eouts_chunk_list = []
eouts_chunk_lens_list = [] eouts_chunk_lens_list = []
if (max_len - chunk_size) % chunk_stride != 0:
padding_len = chunk_stride - (max_len - chunk_size) % chunk_stride padding_len = chunk_stride - (max_len - chunk_size) % chunk_stride
else:
padding_len = 0
padding = paddle.zeros((x.shape[0], padding_len, x.shape[2])) padding = paddle.zeros((x.shape[0], padding_len, x.shape[2]))
padded_x = paddle.concat([x, padding], axis=1) padded_x = paddle.concat([x, padding], axis=1)
num_chunk = (max_len + padding_len - chunk_size) / chunk_stride + 1 num_chunk = (max_len + padding_len - chunk_size) / chunk_stride + 1

Loading…
Cancel
Save