我正在Azure中建立循环神经网络:
model = Sequential()
model.add(GRU(units=512,
return_sequences=True,
input_shape=(None, x1,)))
model.add(Dense(y1, activation='sigmoid'))
但是我得到了错误:
TypeError: while_loop() got an unexpected keyword argument 'maximum_iterations'
我不是cretin,但我认为我可能正在做一些当前版本的TensorFlow&Keras中已贬值的事情,例如在this示例中,发生了类似的错误,并指出了此类错误。我正在Jupyter Azure平台中使用Python 3.6,这也意味着我不确定我正在使用哪个版本的Keras和TensoFlow。
我完整的断网错误消息是:
TypeError Traceback (most recent call last)
<ipython-input-7-e6bcba2d0346> in <module>()
205 model.add(GRU(units=512, return_sequences=True,
--> 207 input_shape=(None,x1,)))
208
~/anaconda3_501/lib/python3.6/site-packages/keras/engine/sequential.py in add(self, layer)
164 # and create the node connecting the current layer
165 # to the input layer we just created.
--> 166 layer(x)
167 set_inputs = True
168 else:
~/anaconda3_501/lib/python3.6/site-packages/keras/layers/recurrent.py in __call__(self, inputs, initial_state, constants, **kwargs)
498
499 if initial_state is None and constants is None:
--> 500 return super(RNN, self).__call__(inputs, **kwargs)
501
502 # If any of `initial_state` or `constants` are specified and are Keras
~/anaconda3_501/lib/python3.6/site-packages/keras/engine/base_layer.py in __call__(self, inputs, **kwargs)
458 # Actually call the layer,
459 # collecting output(s), mask(s), and shape(s).
--> 460 output = self.call(inputs, **kwargs)
461 output_mask = self.compute_mask(inputs, previous_mask)
462
~/anaconda3_501/lib/python3.6/site-packages/keras/layers/recurrent.py in call(self, inputs, mask, training, initial_state)
1587 mask=mask,
1588 training=training,
-> 1589 initial_state=initial_state)
1590
1591 @property
~/anaconda3_501/lib/python3.6/site-packages/keras/layers/recurrent.py in call(self, inputs, mask, training, initial_state, constants)
607 mask=mask,
608 unroll=self.unroll,
--> 609 input_length=timesteps)
610 if self.stateful:
611 updates = []
~/anaconda3_501/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py in rnn(step_function, inputs, initial_states, go_backwards, mask, constants, unroll, input_length)
2955 parallel_iterations=32,
2956 swap_memory=True,
-> 2957 maximum_iterations=input_length)
2958 last_time = final_outputs[0]
2959 output_ta = final_outputs[1]
TypeError: while_loop() got an unexpected keyword argument 'maximum_iterations'
我还从this教程中学到了WARNING:tensorflow:From keep_dims is deprecated, use keepdims instead
。如果这是有效的,我该怎么办?
这也许有些直截了当,但我很困惑,对此的帮助将不胜感激。
答案 0 :(得分:5)
!pip uninstall keras
!pip install keras==2.1.2
现在可以正常工作