contrib.bayesflow.stochastic_graph.surrogate_loss

tf.contrib.bayesflow.stochastic_graph.surrogate_loss

tf.contrib.bayesflow.stochastic_graph.surrogate_loss

surrogate_loss(
    sample_losses,
    stochastic_tensors=None,
    name='SurrogateLoss'
)

Defined in tensorflow/contrib/bayesflow/python/ops/stochastic_graph_impl.py.

See the guide: BayesFlow Stochastic Graph (contrib) > Stochastic Computation Graph Helper Functions

Surrogate loss for stochastic graphs.

This function will call loss_fn on each StochasticTensor upstream of sample_losses, passing the losses that it influenced.

Note that currently surrogate_loss does not work with StochasticTensors instantiated in while_loops or other control structures.

Args:

  • sample_losses: a list or tuple of final losses. Each loss should be per example in the batch (and possibly per sample); that is, it should have dimensionality of 1 or greater. All losses should have the same shape.
  • stochastic_tensors: a list of StochasticTensors to add loss terms for. If None, defaults to all StochasticTensors in the graph upstream of the Tensors in sample_losses.
  • name: the name with which to prepend created ops.

Returns:

Tensor loss, which is the sum of sample_losses and the loss_fns returned by the StochasticTensors.

Raises:

  • TypeError: if sample_losses is not a list or tuple, or if its elements are not Tensors.
  • ValueError: if any loss in sample_losses does not have dimensionality 1 or greater.

© 2017 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/contrib/bayesflow/stochastic_graph/surrogate_loss

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部