gpt4 book ai didi

matlab - LSTM Matlab中 `MiniBatchSize`参数的含义是什么

转载 作者:行者123 更新时间:2023-11-30 09:46:14 27 4
gpt4 key购买 nike

我正在使用 LSTM 结构:

layers = [ ...
sequenceInputLayer(1)
bilstmLayer(100,'OutputMode','last')
fullyConnectedLayer(2)
softmaxLayer
classificationLayer
];

options = trainingOptions('adam', ...
'MaxEpochs',30, ...
'MiniBatchSize', 150, ...
'InitialLearnRate', 0.01, ...
'GradientThreshold', 1, ...
'plots','training-progress', ...
'Verbose',false);

net = trainNetwork(XTrain,Ytrain,layers,options);

哪里

  • Xtrain 是 1x100 元胞数组(Xtrain{1,1} 给出大小为 1000x1 的数据数组,Xtrain{1,2} 是另一组大小为 1000x1 等的数据数组。这意味着我有 100 个特征向量示例,每个示例的维度为 1000。

  • Ytrain 是响应变量 0/1,是大小为 100x1 的数组。响应的类型为 double。

我只是假设 MiniBatchSize 参数为 150。我尝试使用其他值以及 50、60、70...似乎没有什么会影响性能。所以我并不完全遵循这个参数的含义以及如何找到它的值。有人可以帮助解释这意味着什么以及理想情况下它应该是什么吗?谢谢你

最佳答案

该参数实际上在 Mathworks documentation page 上有解释:

Size of the mini-batch to use for each training iteration, specified as the comma-separated pair consisting of MiniBatchSize and a positive integer. A mini-batch is a subset of the training set that is used to evaluate the gradient of the loss function and update the weights. See Stochastic Gradient Descent.

至于它是什么,网络上有几个答案,都在 Stackexchange 网站 herehereelsewhere on the web 。一般来说,它会影响优化算法的收敛性,以及计算过程中使用的内存量。
请注意,目前通常首选 to use smaller batch sizes ,只要你没有太多的训练数据。

关于matlab - LSTM Matlab中 `MiniBatchSize`参数的含义是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52415147/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com