资源简介
内含cnn的matlab程序,简单易懂,不到百行,混科研搞数据必备良代码。超低价甩卖。

代码片段和文件信息
# -*- coding: utf-8 -*-
“““
Created on Thu Aug 27 11:27:34 2015
@author: lab-liu.longpo
“““
from __future__ import absolute_import
from __future__ import print_function
from keras.models import Sequential
from keras.layers.core import Dense Dropout Activation Flatten
from keras.layers.convolutional import Convolution2D MaxPooling2D
from keras.optimizers import SGD Adadelta Adagrad
from keras.utils import np_utils generic_utils
import matplotlib.pyplot as plt
import numpy as np
import scipy.io as sio
d = sio.loadmat(‘data.mat‘)
data = d[‘d‘]
label = d[‘l‘]
data = np.reshape(data(5000033232))
label = np_utils.to_categorical(label 10)
print (‘finish loading data‘)
model = Sequential()
model.add(Convolution2D(32 3 5 5 border_mode=‘valid‘))
model.add(Activation(‘relu‘))
#model.add(MaxPooling2D(poolsize=(2 2)))
model.add(Dropout(0.25))
model.add(Convolution2D(32 32 5 5 border_mode=‘valid‘))
model.add(Activation(‘relu‘))
model.add(MaxPooling2D(poolsize=(2 2)))
model.add(Dropout(0.25))
model.add(Convolution2D(64 32 3 3 border_mode=‘valid‘))
model.add(Activation(‘relu‘))
model.add(MaxPooling2D(poolsize=(2 2)))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(64*5*5 512 init=‘normal‘))
model.add(Activation(‘tanh‘))
model.add(Dense(512 10 init=‘normal‘))
model.add(Activation(‘softmax‘))
sgd = SGD(l2=0.001lr=0.0065 decay=1e-6 momentum=0.9 nesterov=True)
model.compile(loss=‘categorical_crossentropy‘ optimizer=sgdclass_mode=“categorical“)
#checkpointer = ModelCheckpoint(filepath=“weight.hdf5“verbose=1save_best_only=True)
#model.fit(data label batch_size=100nb_epoch=10shuffle=Trueverbose=1show_accuracy=Truevalidation_split=0.2callbacks=[checkpointer])
result = model.fit(data label batch_size=50nb_epoch=35shuffle=Trueverbose=1show_accuracy=Truevalidation_split=0.2)
#model.save_weights(weightsaccuracy=False)
# plot the result
plt.figure
plt.plot(result.epochresult.history[‘acc‘]label=“acc“)
plt.plot(result.epochresult.history[‘val_acc‘]label=“val_acc“)
plt.scatter(result.epochresult.history[‘acc‘]marker=‘*‘)
plt.scatter(result.epochresult.history[‘val_acc‘])
plt.legend(loc=‘under right‘)
plt.show()
plt.figure
plt.plot(result.epochresult.history[‘loss‘]label=“loss“)
plt.plot(result.epochresult.history[‘val_loss‘]label=“val_loss“)
plt.scatter(result.epochresult.history[‘loss‘]marker=‘*‘)
plt.scatter(result.epochresult.history[‘val_loss‘]marker=‘*‘)
plt.legend(loc=‘upper right‘)
plt.show()
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2517 2016-05-02 15:13 DeepLearning\CNN_cifar-10\cifar.py
文件 2724 2016-05-02 15:13 DeepLearning\CNN_mnist\cnn.py
文件 492 2016-05-02 15:13 DeepLearning\CNN_mnist\data.py
文件 608 2016-05-02 15:13 DeepLearning\CNN_mnist\trainCNN.py
文件 2647 2016-05-02 15:13 DeepLearning\UFLDL\stl_exercise\display_network.m
文件 1305 2016-05-02 15:13 DeepLearning\UFLDL\stl_exercise\feedForwardAutoencoder.m
文件 622 2016-05-02 15:13 DeepLearning\UFLDL\stl_exercise\initializeParameters.m
文件 811 2016-05-02 15:13 DeepLearning\UFLDL\stl_exercise\loadMNISTImages.m
文件 516 2016-05-02 15:13 DeepLearning\UFLDL\stl_exercise\loadMNISTLabels.m
文件 1589 2016-05-02 15:13 DeepLearning\UFLDL\stl_exercise\softmaxCost.m
文件 743 2016-05-02 15:13 DeepLearning\UFLDL\stl_exercise\softmaxPredict.m
文件 1891 2016-05-02 15:13 DeepLearning\UFLDL\stl_exercise\softmaxTrain.m
文件 4335 2016-05-02 15:13 DeepLearning\UFLDL\stl_exercise\sparseAutoencoderCost.m
文件 5243 2016-05-02 15:13 DeepLearning\UFLDL\stl_exercise\stlExercise.m
文件 2018 2016-05-02 15:13 DeepLearning\UFLDL\Vectorization_sparseae_exercise\checkNumericalGradient.m
文件 1228 2016-05-02 15:13 DeepLearning\UFLDL\Vectorization_sparseae_exercise\computeNumericalGradient.m
文件 2647 2016-05-02 15:13 DeepLearning\UFLDL\Vectorization_sparseae_exercise\display_network.m
文件 622 2016-05-02 15:13 DeepLearning\UFLDL\Vectorization_sparseae_exercise\initializeParameters.m
目录 0 2018-06-29 20:01 DeepLearning\UFLDL\stl_exercise
目录 0 2018-06-29 20:01 DeepLearning\UFLDL\Vectorization_sparseae_exercise
目录 0 2018-06-29 20:01 DeepLearning\CNN_cifar-10
目录 0 2018-06-29 20:01 DeepLearning\CNN_mnist
目录 0 2018-06-29 20:01 DeepLearning\UFLDL
目录 0 2018-06-29 20:01 DeepLearning
----------- --------- ---------- ----- ----
32558 24
相关资源
- matlab_OFDM调制解调(来自剑桥大学)
- Matlab路面裂缝识别69319
- 高灵敏度GPS接收机MATLAB仿真,附捕获
- 基于MATLAB的质点弹道计算与外弹道优
- 阵列天线的matlab仿真
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 天线阵的波束形成在MATLAB仿真程序及
- 非线性SVM算法-matlab实现
- 《MATLAB 智能算法超级学习手册》-程序
- 组合导航matlab程序
- 读取txt文件内容matlab代码实现
- Matlab实现基于相关的模板匹配程序
- matlab优化工具箱讲解
- 基于MATLAB的快速傅里叶变换
- 光纤传输中的分布傅立叶算法matlab实
- 基于matlab的图像处理源程序
- matlab 椭圆拟合程序
- 算术编码解码matlab源代码
- optical_flow 光流法 matlab 实现程序
- 引导图像滤波器 Matlab实现
- 分形几何中一些经典图形的Matlab画法
- OFDM系统MATLAB仿真代码
- SVM工具箱(matlab中运行)
- 图像小波变换MatLab源代码
- LU分解的MATLAB实现
- 冈萨雷斯数字图像处理matlab版(第三
- 替代数据法的matlab程序
- 用matlab实现的多站定位系统性能仿真
- 通过不同方法进行粗糙集属性约简m
评论
共有 条评论