我已经为100个时期训练了自动编码器,批量大小为32。
当我使用model.fit()时,我没有直接获得每个时期的整体准确性和损失,但是我看到了网络中各个层(例如density_1,density_2,reshape_1等)的准确性和损失。因此,我不确定该网络是否真的经过了100个时期的训练。
任何人都可以告诉我如何跟踪每个时期的总体网络准确性/损失吗?我的网络很复杂,有2个输入,2个输出以及介于它们之间的一些连接层。
def all_in_one_model(embeddedOutput,charMatrixList):
embeddedInput = Input(shape=(1,400))
#charInput = Input(shape=(40774,32,30))
charInput = Input(shape=(32,30,1))
p20 = Sequential()(charInput)
p21 = Conv2D(32, (3, 3), strides=(1,1) , padding="same", activation="relu",input_shape=(32,30,1))(p20)
print('p21 shape')
print(p21.shape)
#pp = Reshape((40774,32*32),name='reshape_1')(p21)
pp = Reshape((32,960))(p21)
p22 = LSTM(16, return_sequences=True,input_shape=(32,32))(pp)
p23 = LSTM(16, return_sequences=True)(p22)
p24 = Flatten()(p23)
print('p24 shape')
print(p24.shape)
p10 = Sequential()(embeddedInput)
p11 = LSTM(64, return_sequences=True, input_shape=(1,400))(p10) #Must be (400,1)
p12 = LSTM(128, return_sequences=True)(p11)
p13 = Flatten()(p12)
print('p13 shape')
print(p13.shape)
x = Concatenate()([p13, p24])
#print(x.shape)
y = Dense(400,activation='relu',name = 'dense_1')(x)
print('y shape')
print(y.shape)
pp = Reshape((1,400),name='reshape_2')(y)
embOut = Dense(400,activation='relu',name = 'dense_2')(pp)
print('Emb out shape')
print(embOut.shape)
#qq = Reshape((40774,960))(y)
charMatOut = Dense(960,activation='relu',name = 'dense_3')(y)
print('Char matrix output shape')
print(charMatOut.shape)
#charout = np.reshape(np.array(charMatOut),(32,30,1))
charout = Reshape((32,30,1),name='reshape_3')(charMatOut)
print('Reshaped Char matrix output shape')
print(charout.shape)
model = Model(inputs=[embeddedInput, charInput], outputs=[embOut, charout])
model.summary()
model.compile(loss='mean_squared_error', optimizer='adam',metrics=['accuracy'])
plot_model(model, to_file = "model.png")
return model
model = all_in_one_model(embeddedOutput,charMatrixList)
model.fit([npeo, npcm], [npeo, npcm], epochs=100, batch_size=32,verbose=1)
史诗1/100 40774/40774 [==============================]-188s 5ms / step-损耗:0.0031-density_2_loss:8.3277e- 04-reshape_3_loss:0.0022-density_2_acc:0.0020-reshape_3_acc:0.9976- ETA:17:16-损失:0.0058-density_2_loss:8.3114e-04-reshape_3_loss:0.0050-density_2_acc:0.0104-reshape_3_acc:0.9950-ETA:6:01-损失:0.0058-density_2_loss:8.3613e-04-reshape_3_loss:0.0050-density_2_acc:0.0024-reshape_3_acc:0.9948 992/40774 [..................................... .....]-ETA:5:28-损失:0.0058-density_2_loss:8.3601e-04-reshape_3_loss:0.0050-density_2_acc:0.0020-reshape_3_acc:0.9948-ETA:4:28-损失:0.0057-density_2_loss:8.3579e -04-reshape_3_loss:0.0049-density_2_acc:0.0027-reshape_3_acc:0.9948-ETA:4:16-损失:0.0057-density_2_loss:8.3530e-04-reshape_3_loss:0.0048-density_2_acc:0.0024-reshape_3_acc:0.9949-ETA:3:54-损失:0.0056-密度_2_损失:8.3492e-04-变形3_损失:0.0047-密度_2_acc:0.0023-形状_3_acc:0.9949 2688/40774