我正在使用Keras训练一个ANN。训练本身是由以下命令完成的:
history=model.fit(x_train,y_train,batch_size=32,epochs=500,verbose=1,validation_split = 0.2 ) #train on the noise (not moshe)
fit=model.predict(x_test)
loss = history.history['loss']
val_loss = history.history['val_loss']我的问题是,val_loss是取误差的总和还是取平均值。
发布于 2019-02-14 06:53:15
这取决于你的损失函数。通常,损失将是每个样本的损失的平均值,例如,像mean_squared_error这样的超常见损失
def mean_squared_error(y_true, y_pred):
return K.mean(K.square(y_pred - y_true), axis=-1)很明显,它取所有损失的平均值。
问题是没有明确的答案,因为你总是可以传入一个自定义的损失函数,它接受总和:
def sum_squared_error(y_true, y_pred):
return K.sum(K.square(y_pred - y_true), axis=-1)TLDR:通常是这样的,但请检查您使用的每个损失函数的来源以确保。你可以在here上找到keras内置损失的来源。
https://stackoverflow.com/questions/54678811
复制相似问题