我正在尝试在 C++ TensorFlow 中实现一个简单的神经网络。
我无法访问 SoftmaxCrossEntropyWithLogits 函数 ( https://www.tensorflow.org/api_docs/cc/class/tensorflow/ops/softmax-cross-entropy-with-logits ) 返回的损失。
请检查上述链接中的“返回”部分。我只想访问“损失”输出。我无法用 C++ 编写它。
谢谢
最佳答案
这里它不返回任何东西,它是一个属性。您可以从类实例访问它。
#define the loss class instance with your logits and labels
softmax_loss_function = SoftmaxCrossEntropyWithLogits(const ::tensorflow::Scope & scope, ::tensorflow::Input features, ::tensorflow::Input labels)
# access the loss
loss = softmax_loss_function.loss
关于C++ TensorFlow SoftmaxCrossEntropWithLogits 返回(成本,梯度),如何访问成本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45631925/