也许是缓存。尝试:
import numpy as np
from tensorflow.keras.layers import Input,Dense,Concatenate
from tensorflow.keras.models import Model
import tensorflow.keras.backend as K
i = Input((10,))
x = Dense(10)(i)
a = Dense(3,use_bias=False)(x)
b = Dense(3,use_bias=False)(x)
# Now you concatenate both outputs,# so nothing happens to them
c = Concatenate()([a,b])
m = Model(i,c)
def loss(y_true,y_pred):
# Do your loss on your subset
a,b = y_pred[:,:3],y_pred[:,3:]
# Do something random
return K.mean(a*b)
m.compile("adam",loss)
m.fit(np.random.random((10,10)),np.random.random((10,6)))
# Outputs:
# 10/10 [=======] - 0s 22ms/sample - loss: -0.2251
或搭配
./bin/console cache:clear
本文链接:https://www.f2er.com/3160646.html