Why does the following code fail if a==b
, but work fine otherwise? Error: ValueError: Shapes must be equal rank, but are 2 and 1 for 'Assign' (op: 'Assign') with input shapes: [12,12], [12].
#!/usr/bin/env python3
import keras
a = 12
b = 12
x = keras.layers.Input(shape=(a,))
y = keras.layers.Dense(b)(x)
model = keras.models.Model(inputs=[x], outputs=y)
model.save_weights("model.h5")
model.load_weights("model.h5")
I use python 3, TensorFlow 1.1.0 as backend and keras version 2.0.1. OS is some Linux.
Upgrading to Tensorflow 1.3.0 did not resolve the problem However, upgrading to Keras 2.0.8 did resolve the problem .
Apparently, loading caused the issue rather than saving.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.