У меня есть фрагмент кода с двумя идентичными моделями RNN, пытающимися создать порождающую состязательную сеть.
Ошибка: ValueError: Недопустимый размер сокращения 2 для ввода с двумя измерениями. для 'sequential_1 / simple_rnn_1 / Sum' (op: 'Sum') с формами ввода: [?, 19], [2] и с вычисленными тензорами ввода: input [1] = <1 2>.
Я получаю ошибку, указанную выше, и я действительно не понимаю, почему.
На данный момент нет соответствия данных. Я просто отлаживаю эти 3 функции (создать генератор, создать дискриминатор, создать GAN)
Я уже пробовал отлаживать его и изменять значения, я действительно не понимаюне понимаю, в чем проблема.
# define the standalone discriminator model
def define_discriminator(in_shape=(44,19)):
model = Sequential()
#3D tensor with shape (batch_size, timesteps, input_dim). Keras convention says batch size is ommited.
#Input shape is (sample size, time steps, number of input features)
model.add(SimpleRNN(units=19, return_sequences=True, input_shape=in_shape))
model.add(SimpleRNN(units=30, return_sequences=True))
model.add(SimpleRNN(units=30))
model.add(Dense(units=1))
model.add(LeakyReLU(alpha=0.2))
model.add(Dense(19, activation='sigmoid'))
# compile model
opt = Adam(lr=0.0002)
model.compile(loss='mean_absolute_error', optimizer=opt, metrics=['accuracy'])
#metrics=[keras_metrics.precision(), keras_metrics.recall()
return model
# define the standalone generator model
def define_generator(in_shape=(44,19)):
# foundation for 7x7 image
model = Sequential()
# 3D tensor with shape (batch_size, timesteps, input_dim).
# Input shape is (sample size, time steps, number of input features)
model.add(SimpleRNN(units=19, return_sequences=True,input_shape=in_shape))
model.add(SimpleRNN(units=30, return_sequences=True))
model.add(SimpleRNN(units=30))
model.add(Dense(units=1))
model.add(LeakyReLU(alpha=0.2))
model.add(Dense(19, activation='sigmoid'))
# compile model
opt = Adam(lr=0.0002)
model.compile(loss='mean_absolute_error', optimizer=opt, metrics=['accuracy'])
# metrics=[keras_metrics.precision(), keras_metrics.recall()
return model
# define the combined generator and discriminator model, for updating the generator
def define_gan(g_model, d_model):
# make weights in the discriminator not trainable
d_model.trainable = False
# connect them
model = Sequential()
# add generator
model.add(g_model)
# add the discriminator
model.add(d_model)
# compile model
opt = Adam(lr=0.0002)
model.compile(loss='mean_absolute_error', optimizer=opt)
return model
На данный момент я просто хочу обучить GAN на данных с 44 строками и 19 столбцами.
Заранее спасибо!