#python #tensorflow #deep-learning #generative-adversarial-network
Вопрос:
У меня есть этот код для обучения генератора в сети GAN, но я не уверен, как построить точность обучения с помощью tenserflow? функция потерь в зависимости от эпох?
def train_g(self, g_input, d_input): loss_g = 0 for e in tqdm(range(1, self.conf.epochs 1)): # train for self.conf.epochs times for current input with self.G.graph.as_default(): # get generator predictions for the generator input g_pred = self.sess_g.run( self.G.final_layer, { self.G.input: g_input } ) g_pred = np.swapaxes(g_pred, axis1=0, axis2=-1) # swap axes for the discirminator moel with self.D.graph.as_default(): # get the discirminator outout for the generator input - fake variable d_pred_fake = self.sess_d.run( self.D.final_layer, { self.D.input: g_pred } ) with self.G.graph.as_default(): # get all the loss values of the generator model value = self.sess_g.run( [self.G.grad_op, self.G.total_loss, self.G.loss_sparse, self.G.loss_centralized, self.G.loss_boundaries, self.G.loss_bicubic, self.G.loss_sum2one, self.G.criterion_loss], { self.G.input: g_input, self.G.d_pred_fake_placeholder: d_pred_fake } ) # add the total loss loss_g variable which is averaged at the end. loss_g = value[1] print('Generator Loss =gt; ', loss_g / self.conf.epochs)
Любая помощь будет признательна.