如何在MATLAB中使用自定义神经网络功能获取图像 [英] How to use the custom neural network function in the MATLAB for images

查看:597
本文介绍了如何在MATLAB中使用自定义神经网络功能获取图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在Matlab(2-10-2)中建立一个简单的3层神经网络.

I have to make a simple 3 layer neural network in Matlab (2-10-2).

我已经在Matlab中研究卷积神经网络,并希望将其与简单的神经网络体系结构进行比较.

I have worked on Convolution Neural Network in Matlab and want to compare that with simple neural network architecture.

我每个类别有14000张图像,输入有两个类别,输出有两个类别.输入端的图像尺寸为56x56 = 3136.
1)如何制作2-10-2 NN架构.

I have 14000 images of each class and there are two classes at the input and two classes will be at the output. Image size at the input in 56x56=3136.
1) How to make 2-10-2 NN architecture.

2)同样,我拥有的图像是RGB,因此其56x56x3因此输入矩阵将为9408?关于输入x是否为两类.对于每个类别,x1的大小为3161x700,x2的大小为9408x700,x输入的最终大小为9408x1400,标签为1x1400?

2) Also the images i have are RGB so its 56x56x3 so input matrix will be 9408?Regarding in the input x if two classes. for each class x1 will have the size 3161x700 and x2 will have the size 9408x700, the x input will have the final size of 9408x1400 and label will be 1x1400?

推荐答案

如果您查看feedforwardnet MATLAB帮助页面有以下示例:

If you look at the feedforwardnet MATLAB help page there is this example:

[x,t] = simplefit_dataset;
net = feedforwardnet(10);
net = train(net,x,t);
view(net)
y = net(x);
perf = perform(net,y,t)

这几乎是您想要的. feedforwardnet可以采用不同隐藏层大小的数组,因此我们可以这样做:

This is almost what you want. The feedforwardnet can take an array of different hidden layer sizes, so we can do:

    net = feedforwardnet([2 10 2]);

获得所需的体系结构.您无需担心输入层大小或输出层大小.那些被设置为"0",并根据您在训练期间提供给网络的输入和输出(示例中为net)自动设置为正确的大小.您可以将56x56矩阵重塑为3136x1向量:

to get the architecture you want. You don't need to worry about the input layer size or output layer sizes. Those are set to '0' and automatically set to the right size based on the inputs and outputs you provide to the network (net in the example) during training. In your case, you can reshape your 56x56 matrix into a 3136x1 vector:

x = reshape(x,3161,1);

因此,按照上面的示例,请确保您的类/目标标签在t中,而相应的输入在x中,您一切顺利.

So, following the above example, make sure your class/target labels are in t and your corresponding inputs in x and you're good to go.

话虽这么说,我不会使用这些网络之一对图像进行分类.通常,ConvNets是必经之路.

That being said, I would not use one of these networks to classify images. ConvNets are generally the way to go.

要将输入数据(x和t)分为训练集,验证集和测试集,并具有训练功能,可以自动照顾像这样的泛化能力,请在训练前执行以下操作:

To split the input data (x and t) into training, validation and test sets and have the training function automatically take care of generalization ability like that, do this before training:

net.divideFcn = 'dividerand';
net.divideParam.trainRatio = 0.7;
net.divideParam.valRatio = 0.15;
net.divideParam.testRatio = 0.15;

将其放在一起,我们有:

Putting it together, we have:

[x,t] = simplefit_dataset;
net = feedforwardnet(10);
net.divideFcn = 'dividerand';
net.divideParam.trainRatio = 0.7;
net.divideParam.valRatio = 0.15;
net.divideParam.testRatio = 0.15;
net = train(net,x,t);
view(net)
y = net(x);
perf = perform(net,y,t)

这篇关于如何在MATLAB中使用自定义神经网络功能获取图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆