0
私はテンソルフローを使用していますが、学校のプロジェクトに使用しています。ここでは、ハウスIDを作成しようとしています。ここでExcelシートのデータを作成し、それをcsvファイルに変換し、データが読み込まれるかどうかをテストしていました。 "ValueError:形状はランク2でなければなりませんが、入力形状を持つ 'MatMul'(op: 'MatMul')のランク0です。 、[1,1]。どうもありがとうございます!行列の乗算が機能しない - Tensorflow
import tensorflow as tf
import os
dir_path = os.path.dirname(os.path.realpath(__file__))
filename = dir_path+ "\House Price Data .csv"
w1=tf.Variable(tf.zeros([1,1]))
w2=tf.Variable(tf.zeros([1,1])) #Feature 1's weight
w3=tf.Variable(tf.zeros([1,1])) #Feature 1's weight
b=tf.Variable(tf.zeros([1])) #bias for various features
x1= tf.placeholder(tf.float32,[None, 1])
x2= tf.placeholder(tf.float32,[None, 1])
x3= tf.placeholder(tf.float32,[None, 1])
Y= tf.placeholder(tf.float32,[None, 1])
y_=tf.placeholder(tf.float32,[None,1])
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
with open(filename) as inf:
# Skip header
next(inf)
for line in inf:
# Read data, using python, into our features
housenumber, x1, x2, x3, y_ = line.strip().split(",")
x1 = float(x1)
product = tf.matmul(x1, w1)
y = product + b
x1変数を上書きしているようです。 – Aaron
csvファイルからの入力は、x1が可能であることを望んでいました。助けてくれてありがとう! – anonymous
デバッグ時のテスト例としてx1を使用しました – anonymous