(self)
Runs a training loop on the model.
Runs a training loop on the model.
Runs a training loop on the model .
def train(self):
        """
        Runs a training loop on the model.
        """
        while True:
            inputs, targets = self.data_reader.get_train_batch(c.BATCH_SIZE, c.SEQ_LEN)
            print 'Training model...'

            feed_dict = {self.model.inputs: inputs, self.model.targets: targets}
            global_step, loss, _ = self.sess.run([self.model.global_step,
                                                  self.model.loss,
                                                  self.model.train_op],
                                                 feed_dict=feed_dict)

            print 'Step: %d | loss: %f' % (global_step, loss)
            if global_step % c.MODEL_SAVE_FREQ == 0:
                print 'Saving model...'
                self.saver.save(self.sess, join(c.MODEL_SAVE_DIR, self.artist_name + '.ckpt'),
                                global_step=global_step)
def train ( self ) : while True : inputs , targets = self . data_reader . get_train_batch ( c . BATCH_SIZE , c . SEQ_LEN ) print 'Training model...' feed_dict = { self . model . inputs : inputs , self . model . targets : targets } global_step , loss , _ = self . sess . run ( [ self . model . global_step , self . model . loss , self . model . train_op ] , feed_dict = feed_dict ) print 'Step: %d | loss: %f' % ( global_step , loss ) if global_step % c . MODEL_SAVE_FREQ == 0 : print 'Saving model...' self . saver . save ( self . sess , join ( c . MODEL_SAVE_DIR , self . artist_name + '.ckpt' ) , global_step = global_step )