资源简介
使用卷积神经网络预测波士顿房价,采用一维卷积的模式。
代码片段和文件信息
# -*- 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
- 下一篇:批量提取栅格影像
相关资源
- Python+Tensorflow+CNN实现车牌识别的
- 利用keras实现的cnn卷积神经网络对手写
- AI智能五子棋Python代码
- CNN卷积神经网络TensorFlow代码
- DeepLab-ResNet-101
- 卷积神经网络(CNN)源码
- Practical Computer Vision Applications Using D
- minist+CNN+交叉验证
- faster Rcnn(python)demo
- keras+tensorflow CNN
- 基于MTCNN实现制作脸部VOC格式数据集
- mnist_CNN 深度学习小
- 深度学习之一:卷积神经网络(CNN)
- 深度学习之二:用Tensorflow实现卷积神
- MaskR-CNNpython
- CNN实现手写数字识别
- python实现的CNN代码
- 车牌识别Python程序,使用五层的CNN网
- TensorFlow实现CNN
- fasterRCNN python36
- CNN卷积神经网络-识别阿喵阿汪源代码
- BP算法实现26个字母识别
- minist-CNN-kreas-tsne.py
- MLPCNN;识别手写数字集Mnist
- cnn +rnn +attention 以及CTC-loss融合的文字
- cython_bbox.cpython-36m-x86_64-linux-gnu.so
- label.png图像16位或24位转8位用于Mask
评论
共有 条评论