Tensorflow:深度神经网络DNN预测波士顿房价(boston house price)【一】

刚学习TF,尝试拿sklearn的datasets来做下练习。波士顿房价数据是个不错的选择。
python3.5
tensorflow 0.12

把所有的包import进来

# coding: utf-8
import tensorflow as tf
from sklearn.datasets import load_boston
import matplotlib.pyplot as plt
from sklearn.preprocessing import scale
from sklearn.model_selection import train_test_split

获取数据

boston = load_boston()
# X = scale(boston.data)
# y = scale(boston.target.reshape((-1,1)))


X_train,X_test,y_train,y_test = train_test_split(boston.data,boston.target,test_size=0.1,random_state=0)
X_train = scale(X_train)
X_test = scale(X_test)
y_train = scale(y_train.reshape((-1,1)))
y_test = scale(y_test.reshape((-1,1)))

定义每一层网络结构,写了个add_layer,让添加网络更加灵活。
完全参照莫烦老师:https://morvanzhou.github.io/tutorials/machine-learning/tensorflow/3-1-add-layer/

def add_layer(inputs,input_size,output_size,activation_function=None):
    with tf.variable_scope("Weights"<
  • 10
    点赞
  • 106
    收藏
    觉得还不错? 一键收藏
  • 11
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 11
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值