我正在使用来自500个样本的8个通道的时间序列数据的CNN。我的深度学习架构包括以下几层。在第一步中,我跨通道执行1D卷积(输入大小[500 8 1]),因此我得到16个[500 x 1]数组,输出大小变为[500 x 1 x 16]。 我编写了一个自定义函数以将其大小调整为[500 x 16],但是在训练网络时却给了我一个错误。 请只看图片帮我。我已尽我所能解释。谢谢
建筑形象: https://www.mathworks.com/matlabcentral/answers/uploaded_files/238391/Picture1.png
当我使用analyzeNetwork(layers)分析网络时。它表明我的体系结构是正确的,这是它的结果 https://www.mathworks.com/matlabcentral/answers/uploaded_files/238392/Capture.jpeg
但是当我开始训练网络时,出现以下错误 https://www.mathworks.com/matlabcentral/answers/uploaded_files/238393/Capture.jpeg
这是我写的“重塑层”的代码:
classdef reshapeLayer < nnet.layer.Layer
properties
end
methods
function layer = reshapeLayer(Name)
layer.Name = Name;
end
function [Z] = predict(layer, X)
sz = [size(X,1) size(X,2)*size(X,3) size(X,4)];
Z = reshape(X , sz);
end
function [dldx] = backward(layer,~,~,dldz,~)
sz = [size(dldz,1) , 1 , size(dldz,2) , size(dldz,3)];
dldx = reshape(dldz , sz);
end
end
end