![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1566544/image.png)
machine learning toolにて、データ長長さのエラー発生しています。
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
SHromaneko
el 6 de Dic. de 2023
Respondida: SHromaneko
el 13 de Dic. de 2023
機械学習を勧めていますが、convolution1dLayerにて下記のエラーが発生します。
Error using trainNetwork
Invalid network
Caused by: Network: Incompatible input and output sequence lengths. The network must return sequences with the same length as the input data or a sequence with length one.
私の環境で使っている学習用データを添付します。
添付の通り、学習データのインプットとアウトプットの長さは同じはずですが、これで実行してもエラーになってしまいます。
原因わかりますでしょうか?
[numChannels_in, ~] = size(XdTrain_loading{1});
[numChannels_out, ~] = size(TdTrain_loading{1});
options.MaxEpochs = 50;
% トレーニングデータの最短シーケンスの長さを取得
minLength = min(cellfun(@(x) size(x, 2), XdTrain_loading));
layers = [
sequenceInputLayer(numChannels_in,'MinLength', minLength)
convolution1dLayer(11, 96)
fullyConnectedLayer(numChannels_out)
regressionLayer
];
net_loading_diff = trainNetwork(XdTrain_loading,TdTrain_loading,layers,options);
0 comentarios
Respuesta aceptada
Aiswarya
el 12 de Dic. de 2023
こんにちは、私は英語で質問に答えます。
I understand that you are getting an error regarding incompatible input and output sequence length. You can ensure that the output is the same size as input by using padding.
You can view the size of the different layers in your network using the below command (https://www.mathworks.com/help/deeplearning/ref/analyzenetwork.html) :
analyzeNetwork(layers)
On using this command on your 'layers' variable, the output obtained is given below:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1566544/image.png)
Note that the regressionoutput is not of the same length(1229) as the sequenceinput layer(1239). This is the reason why you are getting the error. To avoid this you can use "casual" padding in your 1D Convolution layer, which left pads the input to make the input and output sequence length equal. You can modify your "layers" variable as follows:
layers = [
sequenceInputLayer(numChannels_in,'MinLength', minLength)
convolution1dLayer(11, 96,Padding='causal')
fullyConnectedLayer(numChannels_out)
regressionLayer
];
This resolves the error. Refer to the following link to know more about the padding options: https://www.mathworks.com/help/deeplearning/ref/nnet.cnn.layer.convolution1dlayer.html#mw_98aaf581-4b5c-4aff-b971-214dcd2b5e2b_sep_mw_9caacea0-dbc4-4f3d-baad-5a910aa4c92d
0 comentarios
Más respuestas (1)
Ver también
Categorías
Más información sobre イメージを使用した深層学習 en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!