feed_forward.py
def self_teaching(self, outputs, teaching_outputs):
        '''
        loss is defined as the difference between output and teaching nodes
        weights are updated by backpropagation
        '''
        # set the action brain in training mode
        self.train()
        
        # define optimizer
        adam_optimizer = torch.optim.Adam(self.parameters(), lr=0.001)
        
        #set the gradients to zero before starting to do backpropragation 
        adam_optimizer.zero_grad()
        
        #Caculate loss
        loss = self.loss_function(outputs, teaching_outputs)
        #print("Loss = ", loss)

        #print(loss, loss.grad)
        # require auto-grad for loss only if output has been detached from graph
        #loss.requires_grad = True
        
        #Backpropogate
        loss.backward()
        
        #Update weights
        adam_optimizer.step()

        loss is defined as the difference between output and teaching nodes
        weights are updated by backpropagation
        
loss is defined as the difference between output and teaching nodes
weights are updated by backpropagation
loss is defined as the difference between output and teaching nodes weights are updated by backpropagation
def self_teaching(self, outputs, teaching_outputs):
        self.train()
        adam_optimizer = torch.optim.Adam(self.parameters(), lr=0.001)
        adam_optimizer.zero_grad()
        loss = self.loss_function(outputs, teaching_outputs)
        loss.backward()
        adam_optimizer.step()
def self_teaching ( self , outputs , teaching_outputs ) : self . train ( ) adam_optimizer = torch . optim . Adam ( self . parameters ( ) , lr = 0.001 ) adam_optimizer . zero_grad ( ) loss = self . loss_function ( outputs , teaching_outputs ) loss . backward ( ) adam_optimizer . step ( )
loss is defined as the difference between output and teaching nodes
weights are updated by backpropagation
loss is defined as the difference between output and teaching nodes weights are updated by backpropagation
'''
        loss is defined as the difference between output and teaching nodes
        weights are updated by backpropagation
        ''' # set the action brain in training mode # define optimizer #set the gradients to zero before starting to do backpropragation  #Caculate loss #print("Loss = ", loss) #print(loss, loss.grad) # require auto-grad for loss only if output has been detached from graph #loss.requires_grad = True #Backpropogate #Update weights
self
outputs
teaching_outputs