TensorFlowのドキュメントに従って、Tensorflowをマスターしてください。Tensorflowプログラムでタイプ変換エラーが発生する
File "v-prog3-variables.py", line 7, in linear_model = W * x + b .. .. .. ValueError: Incompatible type conversion requested to type 'float32' for variable of type 'int32_ref'
import tensorflow as tf
W = tf.Variable([.3], tf.float32)
b = tf.Variable([-3], tf.float32)
x = tf.placeholder(tf.float32)
linear_model = 1.0
linear_model = W * x + b
#tf.to_float(linear_model, name='ToFloat')
# Global initialization is must
init = tf.global_variables_initializer()
sess.run(init)
print(sess.run(linear_model, {x:[1,2,3,4]}))
このエラーでプログラムの結果の上の '互換性のない型変換エラー' におけるプログラム結果の下
は、私が「linear_modelを定義することで問題を解決しようとしました'float(linear_model = 1.0)またはtf.to_float(linear_model = W * x + b)の変数
しかし何も動作しません
私はTensorFlow初心者、私を助けてください。 ありがとうございます。
Thx Alex、それは働いた。 – Vikram