def loss(self) -> tf.Tensor:
"""
Computes the reconstruction loss of the autoencoder.
The reconstruction loss is computed as the root mean square error between the target sequence and the
reconstructed sequence.
Returns
-------
tf.Tensor
Scalar tensor containing the reconstruction loss averaged over the entire input batch
"""
reconstruction = self.reconstruction
if self.mask_silence:
reconstruction = tf.where(self.targets == -1., -tf.ones_like(reconstruction), reconstruction)
loss = tf.sqrt(tf.reduce_mean(tf.square(self.targets - reconstruction)))
summaries.scalar_summaries(loss)
tf.add_to_collection(tf.GraphKeys.LOSSES, loss)
return loss
评论列表
文章目录