注意:型一致
代码:
import tensorflow as tf
m = int(input())
n = int(input())
count = m * n
A_list = []
while count > 0:
x_input = int(input())
A_list.append(x_input)
count = count - 1
A = tf.constant(A_list, shape=[m, n])
count = m
A_list.clear()
while count > 0:
x_input = int(input())
A_list.append(x_input)
count = count - 1
b = tf.constant(A_list, shape=[m,1])
count = n
A_list.clear()
while count > 0:
x_input = int(input())
A_list.append(x_input)
count = count - 1
x = tf.constant(A_list, shape=[n, 1])
y = tf.add(tf.matmul(A, x), b)
init_op = tf.global_variables_initializer()
sess = tf.InteractiveSession()
sess.run(init_op)
A = sess.run(A)
print(A)
x = sess.run(x)
print(x)
b = sess.run(b)
print(b)
y = sess.run(y)
print(y)
sess.close()