load water_data.mat attributes = mapminmax(attributes); P_train = attributes(:,1:35); T_train = classes(:,1:35); P_test = attributes(:,36:end); T_test = classes(:,36:end); net = newc(minmax(P_train),4,0.01,0.01); w=net.iw{1,1}; b=net.b{1} net.trainPa…
load water_data.mat attributes = mapminmax(attributes); P_train = attributes(:,1:35); T_train = classes(:,1:35); P_test = attributes(:,36:end); T_test = classes(:,36:end); net = newsom(P_train,[4 4]); net.trainParam.epochs = 200; net = train(net,P_tr…
import tensorflow as tf import numpy as np def add_layer(inputs, in_size, out_size, n_layer, activation_function=None): # add one more layer and return the output of this layer layer_name = 'layer%s' % n_layer with tf.name_scope(layer_name): with tf.…
理论以前写过:https://www.cnblogs.com/fangxiaoqi/p/11306545.html,这里根据天气.是否周末.有无促销的情况,来预测销量情况. function [ matrix,attributes ] = bp_preprocess( inputfile ) %% BP神经网络算法数据预处理,把字符串转换为0,1编码 % inputfile: 输入数据文件: % output: 转换后的0,1矩阵: % attributes: 属性和Label: %% 读取数据…
BP神经网络 百度百科:传送门 BP(back propagation)神经网络:一种按照误差逆向传播算法训练的多层前馈神经网络,是目前应用最广泛的神经网络 #设置文件工作区间 setwd('D:\\dat') #读入数据 Gary=read.csv("sales_data.csv")[,2:5] #数据命名 library(nnet) colnames(Gary)<-c("x1","x2","x3","y&q…
load concrete_data.mat n = randperm(size(attributes,2)); p_train = attributes(:,n(1:80))'; t_train = strength(:,n(1:80))'; p_test = attributes(:,n(81:end))'; t_test = strength(:,n(81:end))'; [pn_train,inputps] = mapminmax(p_train'); pn_train = pn_tra…
load spectra; temp = randperm(size(NIR, 1)); P_train = NIR(temp(1:50),:); T_train = octane(temp(1:50),:); P_test = NIR(temp(51:end),:); T_test = octane(temp(51:end),:); k = 2; [Xloadings,Yloadings,Xscores,Yscores,betaPLS,PLSPctVar,MSE,stats] = plsreg…
load spectra; temp = randperm(size(NIR, 1)); P_train = NIR(temp(1:50),:); T_train = octane(temp(1:50),:); P_test = NIR(temp(51:end),:); T_test = octane(temp(51:end),:); [PCALoadings,PCAScores,PCAVar] = princomp(NIR); figure percent_explained = 100 *…
%RF:RF实现根据乳腺肿瘤特征向量高精度(better)预测肿瘤的是恶性还是良性 load data.mat a = randperm(569); Train = data(a(1:500),:); Test = data(a(501:end),:); P_train = Train(:,3:end); T_train = Train(:,2); P_test = Test(:,3:end); T_test = Test(:,2); model = classRF_train(P_train,…
load iris_data.mat P_train = []; T_train = []; P_test = []; T_test = []; for i = 1:3 temp_input = features((i-1)*50+1:i*50,:); temp_output = classes((i-1)*50+1:i*50,:); n = randperm(50); P_train = [P_train temp_input(n(1:40),:)']; T_train = [T_train…
%ELM:ELM基于近红外光谱的汽油测试集辛烷值含量预测结果对比—Jason niu load spectra_data.mat temp = randperm(size(NIR,1)); P_train = NIR(temp(1:50),:)'; T_train = octane(temp(1:50),:)'; P_test = NIR(temp(51:end),:)'; T_test = octane(temp(51:end),:)'; N = size(P_test,2); [Pn_tra…
load BreastTissue_data.mat n = randperm(size(matrix,1)); train_matrix = matrix(n(1:80),:); train_label = label(n(1:80),:); test_matrix = matrix(n(81:end),:); test_label = label(n(81:end),:); [Train_matrix,PS] = mapminmax(train_matrix'); Train_matrix…
load spectra_data.mat temp = randperm(size(NIR,1)); P_train = NIR(temp(1:50),:)'; T_train = octane(temp(1:50),:)'; P_test = NIR(temp(51:end),:)'; T_test = octane(temp(51:end),:)'; N = size(P_test,2); net = newrbe(P_train,T_train,0.3); w1=net.iW{1,1}…
global p global t global R % 输入神经元个数,此处是6个 global S1 % 隐层神经元个数,此处是10个 global S2 % 输出神经元个数,此处是4个 global S % 连接权值个数+阈值个数即(6*10+10*4)+(10+4) S1 = 10; p = [0.01 0.01 0.00 0.90 0.05 0.00; 0.00 0.00 0.00 0.40 0.50 0.00; 0.80 0.00 0.10 0.00 0.00 0.00; 0.00…
%DT:DT实现根据乳腺肿瘤特征向量高精度预测肿瘤的是恶性还是良性 load data.mat a = randperm(569); Train = data(a(1:500),:); Test = data(a(501:end),:); P_train = Train(:,3:end); T_train = Train(:,2); P_test = Test(:,3:end); T_test = Test(:,2); ctree = ClassificationTree.fit(P_train…
对手写数据集50000张图片实现阿拉伯数字0~9识别,并且对结果进行分析准确率, 手写数字数据集下载:http://yann.lecun.com/exdb/mnist/ 首先,利用图片本身的属性,图片的灰度平均值进行识别分类,我运行出来的准确率是22%左右 利用图片的灰度平均值来进行分类实现手写图片识别(数据集50000张图片)——Jason niu 其次,利用SVM算法,我运行出来的准确率是93%左右,具体代码请点击 SVM:利用SVM算法实现手写图片识别(数据集50000张图片)—Jason…
如上图所示的两层神经网络, 单样本向量化:                                                                                 多样本向量化: for i=1 to 4: z[1](i) = W[1](i) x(i)  + b[1](i)                                       Z[1] = W[1] X+ b[1] (4,1)               (4,3)        (…
自己测试人口预测的matlab实现: x=[54167    55196    56300    57482    58796    60266    61465    62828    64653    65994    67207    66207    65859    67295    69172    70499    72538    74542    76368    78534    80671    82992    85229    87177    89211     90…
http://c.biancheng.net/view/1950.html 本节将介绍如何利用 RNN 预测未来的比特币价格. 核心思想是过去观察到的价格时间序列为未来价格提供了一个很好的预估器.给定时间间隔的比特币值通过https://www.coindesk.com/api/的 API 下载,以下是 API 文档的一部分: 经 MIT 授权许可,本节将使用https://github.com/guillaume-chevalier/seq2seq-signal-prediction中的代码.…
(1)导入数据:点击最左底部Import 按钮 (2)创建模型network_Jason_niu:点击底部的New按钮 (3)设置参数并训练:点击底部的Open按钮 (4)仿真预测: 大功告成!…
1. csv.reader(csvfile) # 进行csv文件的读取操作 参数说明:csvfile表示已经有with oepn 打开的文件 2. X.tolist() 将数据转换为列表类型 参数说明:X可以是数组类型等等 代码说明:使用的是单层的rnn网络,迭代的终止条件为,第n的100次循环的损失值未降低次数超过3次,即跳出循环 数据说明:使用的是乘客的人数,训练集和测试集的分配为0.8和0.2, train_x使用的是前5个数据,train_y使用的是从2个数据到第6个数据,以此往后类推…
load spectra_data.mat plot(NIR') title('Near infrared spectrum curve—Jason niu') temp = randperm(size(NIR,1)); P_train = NIR(temp(1:50),:)'; T_train = octane(temp(1:50),:)'; P_test = NIR(temp(51:end),:)'; T_test = octane(temp(51:end),:)'; N = size(P_…
分成两种情况,一种是公开的训练好的模型,下载后可以使用的,一类是自己训练的模型,需要保存下来,以备今后使用. 如果是第一种情况,则参考    http://keras-cn.readthedocs.io/en/latest/other/application/ 使用的是Application应用,文档中的例子如下 利用ResNet50网络进行ImageNet分类 from keras.applications.resnet50 import ResNet50 from keras.preproc…
上一篇文章,比较了三种算法实现对手写数字识别,其中,SVM和神经网络算法表现非常好准确率都在90%以上,本文章进一步探讨对神经网络算法优化,进一步提高准确率,通过测试发现,准确率提高了很多. 首先,改变之一: 先在初始化权重的部分,采取一种更为好的随机初始化方法,我们依旧保持正态分布的均值不变,只对标准差进行改动, 初始化权重改变前, def large_weight_initializer(self): self.biases = [np.random.randn(y, 1) for y in…
load iris_data.mat P_train = []; T_train = []; P_test = []; T_test = []; for i = 1:3 temp_input = features((i-1)*50+1:i*50,:); temp_output = classes((i-1)*50+1:i*50,:); n = randperm(50); P_train = [P_train temp_input(n(1:40),:)']; T_train = [T_train…
import tensorflow as tf import numpy as np import matplotlib.pyplot as plt #Import MNIST data from tensorflow.examples.tutorials.mnist import input_data mnist=input_data.read_data_sets("/niu/mnist_data/",one_hot=False) # Parameter learning_rate…
import tensorflow as tf import numpy as np import matplotlib.pyplot as plt BATCH_START = 0 TIME_STEPS = 20 BATCH_SIZE = 50 INPUT_SIZE = 1 OUTPUT_SIZE = 1 CELL_SIZE = 10 LR = 0.006 BATCH_START_TEST = 0 def get_batch(): global BATCH_START, TIME_STEPS x…
import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets('MNIST_data', one_hot=True) lr=0.001 training_iters=100000 batch_size=128 n_inputs=28 n_steps=28 n_hidden_units=128 n_classes=10 x=tf…
import tensorflow as tf import numpy as np W = tf.Variable(np.arange(6).reshape((2, 3)), dtype=tf.float32, name="weights") b = tf.Variable(np.arange(3).reshape((1, 3)), dtype=tf.float32, name="biases") saver = tf.train.Saver() with tf.…
import mnist_loader from network3 import Network from network3 import ConvPoolLayer, FullyConnectedLayer, SoftmaxLayer training_data, validation_data, test_data = mnist_loader.load_data_wrapper() mini_batch_size = 10 #NN算法:sigmoid函数:准确率97% net = Netw…