我和Recurrentshop和Keras有问题.我试图在Recurrent Model中使用Concatenate和多维张量,无论我如何安排Input,shape和batch_shape,我都会遇到维度问题.
最小代码:
from keras.layers import *
from keras.models import *
from recurrentshop import *
from keras.layers import Concatenate
input_shape=(128,128,3)
x_t = Input(shape=(128,128,3,))
h_tm1 = Input(shape=(128,128,3, ))
h_t1 = Concatenate()([x_t, h_tm1])
last = Conv2D(3, kernel_size=(3,3), strides=(1,1), padding='same', name='conv2')(h_t1)
# Build the RNN
rnn = RecurrentModel(input=x_t, initial_states=[h_tm1], output=last, final_states=[last], state_initializer=['zeros'])
x = Input(shape=(128,128,3, ))
y = rnn(x)
model = Model(x, y)
model.predict(np.random.random((1, 128, 128, 3)))
Run Code Online (Sandbox Code Playgroud)
错误代码:
ValueError: Shape must be rank 3 but it is rank 4 for 'recurrent_model_1/concatenate_1/concat' (op:ConcatV2) with …Run Code Online (Sandbox Code Playgroud) python machine-learning keras tensorflow recurrent-neural-network