필터 지우기
필터 지우기

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 CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by