在python学习过程中使用矩阵相乘函数发现无法实现向量和矩阵相乘。
报错ValueError: Shape must be rank 2 but is rank 1 for ‘MatMul’ (op: ‘MatMul’) with input shapes: [2], [2,1].
查找原因发现相乘的两个矩阵格式不对。
import tensorflow as tf
x = tf.constant([1.0,2.0])
w = tf.constant([[3.0]
在python学习过程中使用矩阵相乘函数发现无法实现向量和矩阵相乘。
报错ValueError: Shape must be rank 2 but is rank 1 for ‘MatMul’ (op: ‘MatMul’) with input shapes: [2], [2,1].
查找原因发现相乘的两个矩阵格式不对。
import tensorflow as tf
x = tf.constant([1.0,2.0])
w = tf.constant([[3.0]