资源简介
使用卷积神经网络预测波士顿房价,采用一维卷积的模式。
代码片段和文件信息
# -*- coding: utf-8 -*-
“““
Created on Tue Sep 12 15:05:41 2017
@author: thinkpad
“““
import numpy as np
from sklearn import preprocessing
import tensorflow as tf
from sklearn.datasets import load_boston
from sklearn.model_selection import train_test_split
import matplotlib.pyplot as plt
#波士顿房价数据
boston=load_boston()
x=boston.data
y=boston.target
#x_3=x[:3:6]
#x=np.column_stack([xx_3])
train_x test_x train_y test_y = train_test_split(x ytrain_size=0.5 random_state=33)
ss_x = preprocessing.StandardScaler()
train_x = ss_x.fit_transform(train_x)
test_x = ss_x.transform(test_x)
train_y = ss_x.fit_transform(train_y.reshape(-1 1))
test_y=ss_x.transform(test_y.reshape(-1 1))
def weight_variable(shape):
initial= tf.truncated_normal(shapestddev=0.1)
return tf.Variable(initial)
def bias_variable(shape):
initial = tf.constant(0.1 shape=shape)
return tf.Variable(initial)
def conv2d(x W):
return tf.nn.conv2d(x W strides=[1 1 1 1] padding=‘SAME‘)
def max_pool_2x2(x):
return tf.nn.max_pool(x ksize=[1221] strides=[1221] padding=‘SAME‘)
xs = tf.placeholder(tf.float32 [None 13]) #原始数据的维度:13
ys = tf.placeholder(tf.float32 [None 1])#输出数据为维度:1
keep_prob = tf.placeholder(tf.float32)#dropout的比例
x_image = tf.reshape(xs [-1 13 1 1])
#第一卷积层
W_conv1 = weight_variable([22 132])
b_conv1 = bias_variable([32])
h_conv1 = tf.nn.relu(conv2d(x_image W_conv1) + b_conv1)
# conv2 layer ##第二卷积层
W_conv2 = weight_variable([22 32 64])
b_conv2 = bias_variable([
- 上一篇:图像配准融合拼接Python.zip
- 下一篇:批量提取栅格影像
相关资源
- 基于TensorFlow实现CNN文本分类实验指导
- 利用CNN网络实现mnist图像分类,手动实
- Python-用PyTorch10实现FasterRCNN和MaskRCNN比
- Python-基于tensorflow实现的用textcnn方法
- Python-FastSCNN的PyTorch实现快速语义分割
- 基于深度学习堆栈自动编码器模型的
- 性别模型库 simple_CNN.81-0.96.hdf5
- lightened_cnn_S 5M模型
- TBCNN 源码
- faster rcnn(python+caffe)源代码
- CNN卷积神经网络PYTHON
- 基于CNN的图像搜索demo
- python实现的卷积神经网络CNN无框架
- 机器学习对应的相关python代码SVM、C
- 基于 CNN 的疲劳检测源码-Python
- CNN网络代码,数据集,及对应论文和
- Faster-RCNN-TensorFlow-Python3.5-master
- MTCNN源码python版
- keras实现中文文本分类
- pytorch版本手写体识别MNIST.zip
- Mask R-CNN源码(TensorFlow版本)
- TensorflowOpenCV实现的CNN车牌识别代码
- 文本分类代码集合含数据_TextCNN_Text
- python实现CNN中文文本分类
- Deep learning with Python Francois Chollet
- 基于卷积神经网络的手势识别
- CNN用于图像分类以外的数字序列.rar
- DnCNN tensorflow实现
- Python-Tensorflow实现SpatialAsDeepSpatialCNN
- CNN+pythoncode8.18.zip
评论
共有 条评论