keras metric different during training

有些话、适合烂在心里 提交于 2019-12-24 00:45:59

问题


I have implemented a custom metric based on SIM and when i try the code it works. I have implemented it using tensors and np arrays and both give the same results. However when I start fitting the model the values given back are a lot higher then the values I get when i load the weights generated by the training and applying the same function.

My function is:

def SIM(y_true,y_pred):

    n_y_true=y_true/(K.sum(y_true)+K.epsilon())    
    n_y_pred=y_pred/(K.sum(y_pred)+K.epsilon())

    return K.mean(K.sum( K.minimum(n_y_true, n_y_pred)))

When I compile the Keras model I add this to the metrics and during training it gives for example SIM: 0.7092. When i load the weights and try it the SIM score is around 0.3. The correct weights are loaded (when restarting training with these weights the same values popup). Does anybody know if I am doing anything wrong?

Why are the metrics given back during training so much higher compared to running the function over a batch?

来源:https://stackoverflow.com/questions/48167733/keras-metric-different-during-training

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!