Tf.reduce_sum, tf.reduce_mean

what will the equivalent code be for

 z_loss = 0.5 * tf.reduce_sum(tf.square(z_mean) + tf.exp(z_logvar) - z_logvar  - 1, axis = [1,2,3])

What are the pytorch equivalent for reduce_mean and reduce_sum

Thanks

torch.mean and torch.sum would be the replacements (or call .mean() or .sum() on a tensor directly).

1 Like