parameters: (self, train_dataset, epochs=10)
return_statement: return model
docstring: Optimize the parameters by training the probability network, and return the trained network.
  
          Args:
              train_dataset (Dataset): A training dataset iterator.
              epochs (int): Total number of iterations on the data. Default: 10.
  
          Returns:
              Cell, the trained probability network.
docstring_summary: Optimize the parameters by training the probability network, and return the trained network.
docstring_tokens: Optimize the parameters by training the probability network and return the trained network .
function: def run(self, train_dataset, epochs=10):
          """
          Optimize the parameters by training the probability network, and return the trained network.
  
          Args:
              train_dataset (Dataset): A training dataset iterator.
              epochs (int): Total number of iterations on the data. Default: 10.
  
          Returns:
              Cell, the trained probability network.
          """
          epochs = Validator.check_positive_int(epochs)
          train_net = TrainOneStepCell(self.net_with_loss, self.optimizer)
          train_net.set_train()
          for _ in range(1, epochs+1):
              train_loss = 0
              dataset_size = 0
              for data in train_dataset.create_dict_iterator(num_epochs=1):
                  x = Tensor(data['image'], dtype=mstype.float32)
                  y = Tensor(data['label'], dtype=mstype.int32)
                  dataset_size += len(x)
                  loss = train_net(x, y).asnumpy()
                  train_loss += loss
              self._loss = train_loss / dataset_size
          model = self.net_with_loss.backbone_network
          return model
function_tokens: def run ( self , train_dataset , epochs = 10 ) : epochs = Validator . check_positive_int ( epochs ) train_net = TrainOneStepCell ( self . net_with_loss , self . optimizer ) train_net . set_train ( ) for _ in range ( 1 , epochs + 1 ) : train_loss = 0 dataset_size = 0 for data in train_dataset . create_dict_iterator ( num_epochs = 1 ) : x = Tensor ( data [ 'image' ] , dtype = mstype . float32 ) y = Tensor ( data [ 'label' ] , dtype = mstype . int32 ) dataset_size += len ( x ) loss = train_net ( x , y ) . asnumpy ( ) train_loss += loss self . _loss = train_loss / dataset_size model = self . net_with_loss . backbone_network return model