Clear Filters
Clear Filters

I am getting an error

24 views (last 30 days)
Neha
Neha on 25 Jul 2024 at 12:32
Edited: Walter Roberson on 25 Jul 2024 at 16:20
I am getting an error in my code specially in line convolution1dLayer(128,10,"Name","conv1d","Padding","same").
The error is
File: convolution1dLayer.m
Line: 1 Column: 45 Invalid use of operator.
which leads to
function output = convolution1dLayer(input, "stride",filtersize, "Padding",1 )
I am unable to solve the problem.
Please help

Answers (2)

Torsten
Torsten on 25 Jul 2024 at 13:28
Do you want to overwrite the MATLAB function "convolution1dLayer" by your own function ?
function output = convolution1dLayer(input, "stride",filtersize, "Padding",1 )
If this is the definition of your newly created function, it's wrong because you cannot hardcode inputs ("stride", "Padding", 1).
  2 Comments
Neha
Neha on 25 Jul 2024 at 14:49
function output = convolution1dLayer(input, "stride",filtersize, "Padding",1 )
This function is on matlab. I am not creating any convolution1dLayer function
Torsten
Torsten on 25 Jul 2024 at 14:52
Edited: Torsten on 25 Jul 2024 at 14:54
This line is (ignoring the incorrect definition of inputs) a definition of a new function:
function output = convolution1dLayer(input, "stride",filtersize, "Padding",1 )
If you want to call the MATLAB function "convolution1dLayer", look at the documentation how to call a function and what input arguments are needed for "convolution1dLayer":

Sign in to comment.


Steven Lord
Steven Lord on 25 Jul 2024 at 13:53
This line of code:
function output = convolution1dLayer(input, "stride",filtersize, "Padding",1 )
is not a valid definition of the convolution1dLayer function. The only things that can appear in the input arguments section of a function definition are variable names not literal values. [And as Torsten called out, you shouldn't call your function convolution1dLayer as convolution1dLayer already has a meaning in Deep Learning Toolbox.] If you eliminated the function keyword from that line of code (and if input and filtersize were defined) it could be a valid call to the convolution1dLayer function.
This documentation page shows how to define functions (note that the "Input arguments" must be variable names not literal data) and this one shows how to call functions. You're trying to combine the two and that's not going to work.

Categories

Find more on Entering Commands in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!