python输入float_python – 在tensorflow中创建一个float64变量
生活随笔
收集整理的這篇文章主要介紹了
python输入float_python – 在tensorflow中创建一个float64变量
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
我正在嘗試進行邏輯回歸,我的訓練數據集來自一個numpy float64數組.我的代碼看起來像,
import tensorflow as tf
graph = tf.Graph()
with graph.as_default():
examples =tf.constant(mat6) # mat6 is a numpy float64 array
t_labels = tf.constant(labels) # labels is an a numpy float64 array
W = tf.Variable(tf.truncated_normal([115713, 2]))
b = tf.Variable(tf.zeros([2]))
logits = tf.matmul(examples, W)+b
這引發了一個例外
TypeError: Input 'b' of 'MatMul' Op has type float32 that does not match type float64 of argument 'a'.
這可能是因為W和b是float32而不是float64.有沒有辦法轉換W和b或創建它作為float64
總結
以上是生活随笔為你收集整理的python输入float_python – 在tensorflow中创建一个float64变量的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Java开发以及Web 和移动程序员必须
- 下一篇: php论坛系统教程,国内php原创论坛