Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 与tensorflow模型接口会导致错误_Python 3.x_Tensorflow - Fatal编程技术网

Python 3.x 与tensorflow模型接口会导致错误

Python 3.x 与tensorflow模型接口会导致错误,python-3.x,tensorflow,Python 3.x,Tensorflow,我目前使用的DNN回归器有11个输入神经元,多个隐藏层,11个输出神经元。 我已经完成了模特的训练。但是,当我尝试使用此代码与模型交互时: a = np.array(0,0,0,0,0,0,0,0,0,0,0) y_pred = regressor.predict(a, as_iterable=False) print(y_pred) 但是,这会产生一个错误: InvalidArgumentError (see above for traceback): Input to

我目前使用的DNN回归器有11个输入神经元,多个隐藏层,11个输出神经元。 我已经完成了模特的训练。但是,当我尝试使用此代码与模型交互时:

 a = np.array(0,0,0,0,0,0,0,0,0,0,0) 
    y_pred = regressor.predict(a, as_iterable=False) 
    print(y_pred)
但是,这会产生一个错误:

InvalidArgumentError (see above for traceback): Input to reshape is a tensor with 11 values, but the requested shape has 121
         [[node dnn/input_from_feature_columns/input_layer/X/Reshape (defined at regressor_full.py:177) ]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "regressor_full.py", line 206, in <module>
    a = np.array(0,0,0,0,0,0,0,0,0,0,0)
ValueError: only 2 non-keyword arguments accepted.

尝试将输入数组更改为a=np.array([0,0,0,0,0,0,0,0,0,0],dtype=”“),并定义可能解决此问题的数据类型

如果您发布代码来定义模型,这将很有帮助。回归者属于哪一类?谢谢你的回答:这是我的回购协议。我将编辑该问题,以包含定义我的模型的代码。@zihaozhao您仍能提供帮助吗?您能检查代码中的
功能列吗?看起来你的输入特征应该是121,但是你传递了一个11维的输入张量。
import tensorflow.contrib.learn as skflow

regressor = skflow.DNNRegressor(feature_columns=feature_columns,
                label_dimension=11,
                hidden_units=hidden_layers,
                model_dir=MODEL_PATH,
                dropout=dropout,
                config=test_config,
                activation_fn = tf.nn.relu,
                optimizer  = tf.compat.v1.train.AdamOptimizer(learning_rate = learning_rate)
)