courses/machine_learning/deepdive/09_sequence/word2vec/word2vec.py
def optimize(self, loss):
    """Build the graph to optimize the loss function."""

    # Optimizer nodes.
    # Linear learning rate decay.
    opts = self._options
    words_to_train = float(opts.words_per_epoch * opts.epochs_to_train)
    lr = opts.learning_rate * tf.maximum(
        0.0001, 1.0 - tf.cast(self._words, tf.float32) / words_to_train)
    self._lr = lr
    optimizer = tf.train.GradientDescentOptimizer(lr)
    train = optimizer.minimize(loss,
                               global_step=self.global_step,
                               gate_gradients=optimizer.GATE_NONE)
    self._train = train
Build the graph to optimize the loss function.
Build the graph to optimize the loss function.
Build the graph to optimize the loss function .
def optimize(self, loss):
    opts = self._options
    words_to_train = float(opts.words_per_epoch * opts.epochs_to_train)
    lr = opts.learning_rate * tf.maximum(
        0.0001, 1.0 - tf.cast(self._words, tf.float32) / words_to_train)
    self._lr = lr
    optimizer = tf.train.GradientDescentOptimizer(lr)
    train = optimizer.minimize(loss,
                               global_step=self.global_step,
                               gate_gradients=optimizer.GATE_NONE)
    self._train = train
def optimize ( self , loss ) : opts = self . _options words_to_train = float ( opts . words_per_epoch * opts . epochs_to_train ) lr = opts . learning_rate * tf . maximum ( 0.0001 , 1.0 - tf . cast ( self . _words , tf . float32 ) / words_to_train ) self . _lr = lr optimizer = tf . train . GradientDescentOptimizer ( lr ) train = optimizer . minimize ( loss , global_step = self . global_step , gate_gradients = optimizer . GATE_NONE ) self . _train = train
Build the graph to optimize the loss function.
Build the graph to optimize the loss function .
"""Build the graph to optimize the loss function.""" # Optimizer nodes. # Linear learning rate decay.
self
loss