Open 19980715dyy opened 2 years ago
seq2seq_tensorflow
input_tensor 里面有None值,将None换成其他数值就行了。
但是又出现这个错误output, state = self.gru(x_emb, initial_state=hidden) tensorflow.python.framework.errors_impl.InvalidArgumentError: Exception encountered when calling layer "gru" (type GRU).
不是替换的问题,而是tokenizer序列化后再反序列出来有问题,丢失了很多key,不要提前去生成词袋,运行的时候动态生成就行。
我也遇到了同样的问题,所以该怎么办呢?
同问 何解
tf.keras.preprocessing.sequence.pad_sequences([[1,2],[2,3]], maxlen=20,padding='post') the code above is ok.
but , tf.keras.preprocessing.sequence.pad_sequences(input_tensor, maxlen=20,padding='post') File "/home/student2/software/anaconda3/envs/tf/lib/python3.8/site-packages/keras_preprocessing/sequence.py", line 98, in pad_sequences trunc = np.asarray(trunc, dtype=dtype) TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType' I don't kown why?
type(input_tensor) is list type(input_tensor[0][0]) is int