SoFunction
Updated on 2024-10-29

Finally figured out the correspondence of multiloss in Keras introduction

I'll cut to the chase, so let's get right to the code~

model = Model(inputs=[src, tgt], outputs=[y, flow])  
# Inputs and outputs are given when defining a network
(optimizer=Adam(lr=lr), loss=[
           losses.cc3D(), ('l2')], loss_weights=[1.0, reg_param]) 
# Specify the loss when training the network, in case of multi-loss.
loss weightscorresponds to each of the precedinglossweights,final outputlosscounterfeit medicines
train_loss = model.train_on_batch(
      [X, atlas_vol], [atlas_vol, zero_flow]) 
 # Start training, the correspondence between y_pred and y_true in loss is:
 # Output y with atlas_vol to count cc3Dloss, output flow with zero_flow to count gradientloss

Additional knowledge:Code run by keras server with fit_generator, loss,acc graph saving

I'll cut to the chase, so let's get right to the code~

import  as plt

...  //Data processing code Omit

history = model.fit_generator(
  image_generator, steps_per_epoch=2000 // 32 ,
  epochs=16, verbose=1,
  validation_data=image_generator_TEST, validation_steps=20
)

print(())
plt.switch_backend('agg')  #Saving images on the server requires this to be set.
//acc
(['acc'])
(['val_acc'])
('model accuracy')
('accuracy')
('epoch')
(['train', 'test'], loc='upper left')
('')
//loss
(['loss'])
(['val_loss'])
('loss')
('epoch')
(['train', 'test'], loc='upper left')
('')

Above this finally figured out the correspondence in Keras multiloss introduction is all that I have shared with you, I hope to give you a reference, and I hope you support me more.