bojone / seq2seq

keras example of seq2seq, auto title
332 stars 118 forks source link

keras和tensorflow版本? #5

Closed ghost closed 6 years ago

ghost commented 6 years ago

请问这个代码使用的keras和tensorflow版本?

bojone commented 6 years ago

keras 2.1.5 ~ keras 2.2.2均可。对应的最低的tf版本就行了。

ghost commented 6 years ago

你好,请问你用的tf版本是多少?

bojone commented 6 years ago

tf 1.2、1.8、1.10都测试过~

ghost commented 6 years ago

我用的tf1.3 报错? Using TensorFlow backend. Traceback (most recent call last): File 'seq2seq.py', line 168, in xy = Interact()([y, x, x_mask]) File '/export/gpudata/xiatianci/env/lib/python2.7/site-packages/keras/engine/base_layer.py', line 457, in call output = self.call(inputs, **kwargs) File 'seq2seq.py', line 159, in call a = K.softmax(a) File '/export/gpudata/xiatianci/env/lib/python2.7/site-packages/keras/backend/tensorflow_backend.py', line 3154, in softmax return tf.nn.softmax(x, axis=axis) TypeError: softmax() got an unexpected keyword argument 'axis'

bojone commented 6 years ago

那只是因为你的keras版本太高,而tf版本过低...两者不配套。你把tf升级到1.8,或者自己修改一下tensorflow_backend.py,将tf.nn.softmax(x, axis=axis)改为tf.nn.softmax(x, axis)

ghost commented 6 years ago

谢谢,刚好的问题解决了,但是还是出现下面这个问题,我用的GPU去跑了,安装的tensorflow是cpu版本的 Caused by op u'cu_dnnlstm_3/CudnnRNN', defined at: File 'seq2seq.py', line 135, in y = CuDNNLSTM(char_size, return_sequences=True)(y) File '/export/gpudata/xiatianci/env/envs/bein/lib/python2.7/site-packages/keras/layers/recurrent.py', line 500, in call return super(RNN, self).call(inputs, kwargs) File '/export/gpudata/xiatianci/env/envs/bein/lib/python2.7/site-packages/keras/engine/base_layer.py', line 457, in call output = self.call(inputs, kwargs) File '/export/gpudata/xiatianci/env/envs/bein/lib/python2.7/site-packages/keras/layers/cudnn_recurrent.py', line 90, in call output, states = self._process_batch(inputs, initial_state) File '/export/gpudata/xiatianci/env/envs/bein/lib/python2.7/site-packages/keras/layers/cudnn_recurrent.py', line 510, in _process_batch is_training=True) File '/export/gpudata/xiatianci/env/envs/bein/lib/python2.7/site-packages/tensorflow/contrib/cudnn_rnn/python/ops/cudnn_rnn_ops.py', line 1546, in call input_data, input_h, input_c, params, is_training=is_training) File '/export/gpudata/xiatianci/env/envs/bein/lib/python2.7/site-packages/tensorflow/contrib/cudnn_rnn/python/ops/cudnn_rnn_ops.py', line 1437, in call seed=self._seed) File '/export/gpudata/xiatianci/env/envs/bein/lib/python2.7/site-packages/tensorflow/contrib/cudnn_rnn/python/ops/cudnn_rnn_ops.py', line 926, in _cudnn_rnn name=name) File '/export/gpudata/xiatianci/env/envs/bein/lib/python2.7/site-packages/tensorflow/python/ops/gen_cudnn_rnn_ops.py', line 115, in cudnn_rnn is_training=is_training, name=name) File '/export/gpudata/xiatianci/env/envs/bein/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py', line 787, in _apply_op_helper op_def=op_def) File '/export/gpudata/xiatianci/env/envs/bein/lib/python2.7/site-packages/tensorflow/python/framework/ops.py', line 3392, in create_op op_def=op_def) File '/export/gpudata/xiatianci/env/envs/bein/lib/python2.7/site-packages/tensorflow/python/framework/ops.py', line 1718, in init self._traceback = self._graph._extract_stack() # pylint: disable=protected-access

InvalidArgumentError (see above for traceback): No OpKernel was registered to support Op 'CudnnRNN' with these attrs. Registered devices: [CPU], Registered kernels:

[[Node: cu_dnnlstm_3/CudnnRNN = CudnnRNN[T=DT_FLOAT, direction='unidirectional', dropout=0, input_mode='linear_input', is_training=true, rnn_mode='lstm', seed=87654321, seed2=0](cu_dnnlstm_3/transpose, cu_dnnlstm_3/ExpandDims_1, cu_dnnlstm_3/ExpandDims_2, cu_dnnlstm_3/concat_1)]]
bojone commented 6 years ago

你有N卡么?装好对应的CUDA和CUDNN环境了?

ghost commented 6 years ago

有的,我装的CUDA8.0

bojone commented 6 years ago

那我不清楚了,你可以考虑换回普通的LSTM,效果等价的

ghost commented 6 years ago

好的,谢谢,我使用普通的可以跑通了