October 2018
Intermediate to advanced
472 pages
10h 57m
English
We are using the Adam optimizer to train the model and masking the loss calculated for the <PAD> key:
optimizer = tf.train.AdamOptimizer()# We are masking the loss calculated for paddingdef loss_function(real, pred): mask = 1 - np.equal(real, 0) loss_ = tf.nn.sparse_softmax_cross_entropy_with_logits(labels=real, logits=pred) * mask return tf.reduce_mean(loss_)
Read now
Unlock full access