【发布时间】:2019-10-20 01:21:55
【问题描述】:
与link1和link2不同,现在我有两个损失函数不同的网络,我想在一批中交替拟合这两个模型。
具体来说,如果有一个模型,A。我用下面的伪代码训练它:
model = some_value # initial
for e in 1:epoch
for b in 1:batch
model = train(A, model)
上面的程序在keras中只需要一行代码就可以实现:
model.fit(X_train, Y_train,
batch_size=32, epoch=10)
现在,我有两个模型,A 和 B。我通过以下伪代码训练它们:
model_A = some_value # initial
model_B = some_value # initial
for e in 1:epoch
for b in 1:batch
model_A = train(A, model_B) # I using the model_B in the loss function of neural network model_A
model_B = train(A, model_A) # I using the model_A in the loss function of neural network model_B
如何在keras中实现这个程序?
【问题讨论】:
标签: python-3.x keras neural-network