mean,variance = tf.nn.moments(X_train,axes = 1,keep_dims = True)我试图使用tf.nn.moments()获得均值和方差,如上所示。但是,我遇到以下错误:
—…
tf.nn.moments 期待一个张量,而不是一个numpy数组:
tf.nn.moments
ARGS: x :一个张量。
ARGS:
x
试试这个:
x = tf.convert_to_tensor(X_train) mean , variance = tf.nn.moments(x, axes = 1, keep_dims = True)