我正在使用Windows 10上的Tensorflow 1.4.0和Python 3.6。我查看了其他有关值排序的帖子,但到目前为止没有发现有效的解决方法。
谢谢。
谢谢。
import tensorflow as tf
import numpy as np
from sklearn.datasets import fetch_california_housing
housing = fetch_california_housing()
m, n = housing.data.shape
housing_data_plus_bias = np.c_[np.ones((m, 1)), housing.data]
#normalization
scaled_housing_data_plus_bias = tf.nn.l2_normalize(housing_data_plus_bias, 1, epsilon=1e-12,name="Normalized")
n_epochs = 1000
learning_rate = 0.01
#error occurs here
X = tf.constant(scaled_housing_data_plus_bias, dtype=tf.float32, name="X")
Traceback (most recent call last):
File "C:/Users/tony/PycharmProjects/NNCourse/Hands-On_Book_5.py", line 14, in <module>
X = tf.constant(scaled_housing_data_plus_bias, dtype=tf.float32, name="X")
File "C:\Users\tony\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\constant_op.py", line 208, in constant
value, dtype=dtype, shape=shape, verify_shape=verify_shape))
File "C:\Users\tony\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\tensor_util.py", line 383, in make_tensor_proto
_AssertCompatible(values, dtype)
File "C:\Users\tony\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\tensor_util.py", line 303, in _AssertCompatible
(dtype.name, repr(mismatch), type(mismatch).__name__))
TypeError: Expected float32, got list containing Tensors of type '_Message' instead.