2017-08-11 60 views

回答

0

這裏它不返回任何東西,它的一個屬性。你可以從類實例中訪問它。

#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 
+0

謝謝你的回答。我有一個疑問。在函數的官方頁面(https://www.tensorflow.org/api_docs/cc/class/tensorflow/ops/softmax-cross-entropy-with-logits)中提到它計算交叉熵和梯度並返回它們也。所以,我很困惑.. – sansingh

+0

還有另一個屬性'backprop'來訪問計算出來的漸變。 –

+0

那麼你的意思是說,除非我定義它,否則這個函數不會返回任何值(損失和漸變)?因爲當我在做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