使用Matlab创建完全连接的神经网络

时间:2020-06-02 03:07:02

标签: matlab machine-learning deep-learning neural-network

我是MATLAB中神经网络的新手,并尝试使用MATLAB创建深度神经网络,其中输入层的大小为16,隐藏层的大小为64,最后输出层的大小为20。

此刻,输入和输出被视为随机布尔值。

我创建如下的深度神经网络:

close all, clear all, clc, format compact
% number of samples of each class
% create network
%# load sample data
input = randi([0 1],16,1000);        %# 16x1000, 
output = randi([0 1],20,1000);       %# 20x1000,

%# split data into training/testing sets
trainInd = 1:500;                  
testInd = 501:1000;

% 1, 2: ONE input, TWO layers (one hidden layer and one output layer)
% [1; 1]: both 1st and 2nd layer have a bias node
% [1; 0]: the input is a source for the 1st layer
% [0 0; 1 0]: the 1st layer is a source for the 2nd layer
% [0 1]: the 2nd layer is a source for your output
net = network(1, 2, [1; 1], [1; 0], [0 0; 1 0], [0 1]);
net.inputs{1}.size = 16; % input size
net.layers{1}.size = 64; % hidden layer size
net.layers{2}.size = 20; % output layer size

% network training
net.trainFcn = 'trainlm';
net.performFcn = 'mse';
% view(net);
net = train(net, input(:,trainInd), output(:,trainInd));
final_output = net(input)

可以,但是我的问题是如何使Adam优化器适应该网络?以及如何设置他进入这个网络的时代,我尝试过net.trainParam.epochs = 25; %# max number of iterations

但是它给出了一个错误。

0 个答案:

没有答案
相关问题