喀拉拉邦密集网络输入问题

时间:2018-12-08 06:43:14

标签: python tensorflow keras

我遇到了一个很奇怪的问题,其中我向keras模型提供了适当的输入,但是却得到了输入张量未找到的错误,如下所示:-

  

“ ValueError:图形已断开:无法获取张量的值   Tensor(“ input_12:0”,shape =(?, 3212,1),dtype = float32)   “ input_12”。可以顺利访问以下先前的层:   []”

这是我制作模型的方式,没有导入错误。我还尝试扩展数据的最后一个维度,并尝试输入形状(3212,1),但是它也没有用,请告诉我我做错了,任何帮助将不胜感激。

X_train, X_test, y_train, y_test = train_test_split(feats,y,test_size=0.1,random_state=42,shuffle=True)

print(X_train.shape)   # prints (24723, 3212)

x = Input(shape=(3212,))

x=Dense(64)(x)
x=LeakyReLU()(x)
x=Dropout(0.4)(x)

x=Dense(128)(x)
x=LeakyReLU()(x)
x=Dropout(0.4)(x)

x=Dense(256, name='dense3')(x)
x=LeakyReLU()(x)
x=Dropout(0.4)(x)

x=Dense(512, name='dense23')(x)
x=LeakyReLU()(x)
x=Dropout(0.4)(x)

x=Dense(1024, name='dense33')(x)
x=LeakyReLU()(x)
x=Dropout(0.4)(x)

x=Dense(2048, name='dense43')(x)
x=LeakyReLU()(x)

output=Dense(5, activation='softmax')(x)

model = Model(x, output)

adam=Adam(lr=0.0001)

model.compile(optimizer=adam, loss='categorical_crossentropy', metrics=['acc'])

model.summary()

from keras.callbacks import TensorBoard

es=keras.callbacks.EarlyStopping(monitor='val_loss', min_delta=0, patience=2, verbose=0, mode='auto',baseline=None, restore_best_weights=True)

model.fit(X_train, y_train,
                epochs=10,
                batch_size=64,
                shuffle=True,
                validation_data=(X_test, y_test),
                callbacks=[es])
model.save('DNN_model.h5')

0 个答案:

没有答案