My Custom Deep learning Layer is giving me an error

5 ビュー (過去 30 日間)
Muhammad Nabi
Muhammad Nabi 2019 年 9 月 15 日
回答済み: Lucas Teng 2020 年 8 月 7 日
I am using CNN of time series data from 8 channels with 500 time samples. My Deep learning architecture consists of the following layers. In the First step i perform 1D convolution across the channels (input size [500 8 1 ])so I get 16, [500 x 1 ] arrays and the output size becomes [500 x 1 x 16].
I wrote a custom function to reshape its size to [500 x 16 ] but it gives me an error when i train the network.
please just see the pictures and help me out. I have tried my best to explain it as far as I can. Thanks
Picture1.png
When I Analyzed the network using analyzeNetwork(layers). It showed that my Architecture is correct Here are the results of it
Capture.JPG
But When I start training the Network It gives me the following error
Capture.JPG
Here is the code to the Reshape Layer which I wrote:
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
  1 件のコメント
Paola HUMBERT
Paola HUMBERT 2020 年 6 月 8 日
Hello,
Could you find the error in your code ? The answer would interest me.
Thank you.

サインインしてコメントする。

回答 (1 件)

Lucas Teng
Lucas Teng 2020 年 8 月 7 日
Update your matlab version to at least 2020a and enter the following code into command:
edit(fullfile(matlabroot,'examples','nnet','main','projectAndReshapeLayer.m'))
You'll learn it.

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by