1
我想在C++ TensorFlow中實現一個簡單的神經網絡。C++ TensorFlow SoftmaxCrossEntropWithLogits返回(成本,梯度),如何訪問成本?
我無法訪問由SoftmaxCrossEntropyWithLogits函數返回的損失(https://www.tensorflow.org/api_docs/cc/class/tensorflow/ops/softmax-cross-entropy-with-logits)。
請檢查上述鏈接中的「退貨」細分。我只想訪問「損失」輸出。我無法用C++編寫它。
謝謝
謝謝你的回答。我有一個疑問。在函數的官方頁面(https://www.tensorflow.org/api_docs/cc/class/tensorflow/ops/softmax-cross-entropy-with-logits)中提到它計算交叉熵和梯度並返回它們也。所以,我很困惑.. – sansingh
還有另一個屬性'backprop'來訪問計算出來的漸變。 –
那麼你的意思是說,除非我定義它,否則這個函數不會返回任何值(損失和漸變)?因爲當我在做softmax_loss_function.loss時,我在C++中出錯:錯誤:初始化參數1的'std :: basic_ostream <_CharT,_Traits>&std :: operator <<(std :: basic_ostream <_CharT,_Traits> && ,const _Tp&)[with _CharT = char; _Traits = std :: char_traits; _Tp = tensorflow :: Output]' operator <<(basic_ostream <_CharT,_Traits> && __os,const _Tp&__x) –
sansingh