資源簡(jiǎn)介
內(nèi)含cnn的matlab程序,簡(jiǎn)單易懂,不到百行,混科研搞數(shù)據(jù)必備良代碼。超低價(jià)甩賣。

代碼片段和文件信息
#?-*-?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[‘a(chǎn)cc‘]label=“acc“)
plt.plot(result.epochresult.history[‘val_acc‘]label=“val_acc“)
plt.scatter(result.epochresult.history[‘a(chǎn)cc‘]marker=‘*‘)
plt.scatter(result.epochresult.history[‘val_acc‘])
plt.legend(loc=‘under?right‘)
plt.show()
plt.figure
plt.plot(result.epochresult.history[‘loss‘]label=“l(fā)oss“)
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()
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????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
評(píng)論
共有 條評(píng)論