tensorlayer / TensorLayer

Deep Learning and Reinforcement Learning Library for Scientists and Engineers
http://tensorlayerx.com
Other
7.33k stars 1.61k forks source link

How to use tl.iterate funcion feed three argument? #387

Closed SPY-Ming closed 6 years ago

SPY-Ming commented 6 years ago

I want to write blstm model with mask,and I saw API shows that BiDynamicRNNLayer can do this whit argument "sequence_length".But Iterate function ,for example ,tl.tierate.seq_minbatch can just feed input_x and input_y, So how can I use iterate function to split "seq_len" into batch iterate? PS:input example x = [2,5,13,5,6,4,3,6,0,0,0,0,0] sel_len = [8]

zsdonghao commented 6 years ago

there is a hint in the docs http://tensorlayer.readthedocs.io/en/latest/modules/iterate.html#non-time-series

If you have two inputs and one label and want to shuffle them together, e.g. X1 (1000, 100), X2 (1000, 80) and Y (1000, 1), you can stack them together (np.hstack((X1, X2))) into (1000, 180) and feed to inputs. After getting a batch, you can split it back into X1 and X2.

SPY-Ming commented 6 years ago

Thank u to give me a new view to slove this problem.But np.hstack can not do this work because: ValueError: all the input arrays must have same number of dimensions My input is x=[1,2,3,4,5,6,0,0,0,0] and seq = [6],that means seq input a list of int which is number of list x No zero int. So do u know anthor function except "for" iter?Or how can I do in data process for blstm+mask

zsdonghao commented 6 years ago

@SPY-Ming Hi, the latest version supports list as the input, so it can handle your situation.