I am getting an error

3 次查看(过去 30 天)
Neha
Neha 2024-7-25
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

回答(2 个)

Torsten
Torsten 2024-7-25
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 个评论
Neha
Neha 2024-7-25
function output = convolution1dLayer(input, "stride",filtersize, "Padding",1 )
This function is on matlab. I am not creating any convolution1dLayer function
Torsten
Torsten 2024-7-25
编辑:Torsten 2024-7-25
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":

请先登录,再进行评论。


Steven Lord
Steven Lord 2024-7-25
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.

类别

Help CenterFile Exchange 中查找有关 Entering Commands 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by