我使用张量流来实现一个简单的多层感知器用于回归.代码是从标准的mnist分类器修改的,我只将输出成本更改为MSE(使用tf.reduce_mean(tf.square(pred-y))),以及一些输入,输出大小设置.但是,如果我使用回归训练网络,在几个时期之后,输出批次完全相同.例如:
target: 48.129, estimated: 42.634
target: 46.590, estimated: 42.634
target: 34.209, estimated: 42.634
target: 69.677, estimated: 42.634
......
Run Code Online (Sandbox Code Playgroud)
我尝试了不同的批量大小,不同的初始化,使用sklearn.preprocessing.scale进行输入规范化(我的输入范围非常不同).但是,它们都没有奏效.我还尝试了Tensorflow的一个sklearn示例(波士顿数据的深度神经网络回归).但我在第40行得到了另一个错误:
'module'对象没有属性'infer_real_valued_columns_from_input'
任何人都有关于问题所在的线索?谢谢
我的代码如下所示,可能有点长,但非常简单:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import tensorflow as tf
from tensorflow.contrib import learn
import matplotlib.pyplot as plt
from sklearn.pipeline import Pipeline
from sklearn import datasets, linear_model
from sklearn import cross_validation
import numpy as np
boston = learn.datasets.load_dataset('boston')
x, y = boston.data, boston.target
X_train, X_test, Y_train, Y_test = …Run Code Online (Sandbox Code Playgroud)