matlab神经网络训练批量
我正在尝试使用不同的批量大小来训练神经网络,但我不确定如何将生成的网络合并在一起 以下是我编写的代码,用于训练以批量大小为参数的网络matlab神经网络训练批量,matlab,neural-network,Matlab,Neural Network,我正在尝试使用不同的批量大小来训练神经网络,但我不确定如何将生成的网络合并在一起 以下是我编写的代码,用于训练以批量大小为参数的网络 %% Train the Network using batches batch_size = 50; total_size = size(inputs,2); batch_num = ceil(total_size / batch_size); for i = 1:batch_num start_index = i + batch_size * (i
%% Train the Network using batches
batch_size = 50;
total_size = size(inputs,2);
batch_num = ceil(total_size / batch_size);
for i = 1:batch_num
start_index = i + batch_size * (i - 1);
end_index = batch_size + batch_size * (i - 1);
if i == batch_num
end_index = total_size;
end
[net,tr] = train(net,inputs(:,start_index:end_index), targets(:,start_index:end_index));
end
这是net和tr的结构
tr=
网=
在所有批处理完成后,如何获取结果
net
变量以保存结果神经网络?如果我理解正确,您正在覆盖变量net
和tr
。只需使用单元格数组:
在开始时使用以下命令进行声明:
net = {};
tr = {};
并将相关行更改为:
[net{end+1},tr{end+1}] = ...
嗯,看起来net和tr更复杂,但无论如何都应该工作,因为你可以制作任何类型的对象的单元数组,不管它有多复杂。它能工作吗?不幸的是,no.net是1x1网络。这就是我得到的错误:???逗号分隔列表扩展具有非单元格数组的单元格语法。分类错误==>122[net{end+1},tr{end+1}]=train(net,输入(:,开始索引:结束索引),目标(:,开始索引:结束索引));还是不行。我想我可以继续使用net,它不会覆盖它,因为我也将它用作输入参数。对于tr,我想我将在第一次迭代中得到它,并停止为下一次迭代生成它。谢谢你的帮助
net = {};
tr = {};
[net{end+1},tr{end+1}] = ...