I am new in deep learning in python using tensorflow and keras
I am trying to make own SRGAN network
I read about it here and I tried to make it in python but I do not know I am
in the right way or not
my code here
=> content and style losses
I pass low resolution to generator (low --> super) and calculate the content and style outputs from VGG model then get the gram matrices (calculate gram matrix on style and content outputs )losses between super and high resolution
my generator losses function :
def generator_loss(sr,hr,diso_preds):
loss_content= 0
loss_style=0
for i in range(0,batch):
s=sr[i][tf.newaxis, :]
s=preprocess_input(s*255.0)
content_sr=con_vgg(s)
content_sr_outputs,style_sr_outputs = (content_sr[0],
content_sr[1:])
gram_sr_content =gram_matrix(content_sr_outputs)
gram_sr_style = [gram_matrix(style) for style in style_sr_outputs]
h=hr[i][tf.newaxis, :]
h=preprocess_input(h*255.0)
content_hr=con_vgg(h)
content_hr_outputs,style_hr_outputs = (content_hr[0],
content_hr[1:])
gram_hr_content=gram_matrix(content_hr_outputs)
gram_hr_style = [gram_matrix(style) for style in style_hr_outputs]
content_loss=tf.reduce_mean((gram_sr_content-gram_hr_content)**2)
for gram_sr,gram_hr in zip(gram_sr_style,gram_hr_style):
style_loss=tf.reduce_mean((gram_sr-gram_hr)**2)
loss_style=loss_style+style_loss
loss_content=loss_content+content_loss
adversial_loss=cross_entropy(tf.ones_like(diso_preds), diso_preds)
total=loss_content+adversial_loss+loss_style
return total
but i get weird results after 100 epochs :
1- super resolution :
2- real images :
should i increase number of epochs or make generator more depth??
thanks :)
question from:
https://stackoverflow.com/questions/65557618/am-i-implement-srgan-network-correctly-in-tensorflow 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…