why am i getting this error with activation function in my code
조회 수: 7 (최근 30일)
이전 댓글 표시
layers = [fullyConnectedLayer(num_neurons, 'ActivationFunction', activation_function) fullyConnectedLayer(1, 'ActivationFunction', 'purelin')];
i am getting this error
Error using fullyConnectedLayer
layers = [fullyConnectedLayer(num_neurons, 'ActivationFunction', activation_function) fullyConnectedLayer(1, 'ActivationFunction', 'purelin')];
Invalid argument name 'ActivationFunction'. Name must be one of these:
'Name'
'WeightLearnRateFactor'
'BiasLearnRateFactor'
'WeightsInitializer'
'BiasInitializer'
'WeightL2Factor'
'BiasL2Factor'
'Weights'
'Bias'
Error in ann (line 14)
layers = [fullyConnectedLayer(num_neurons, 'ActivationFunction', activation_function) fullyConnectedLayer(1, 'ActivationFunction', 'purelin')];
>> ann
댓글 수: 0
답변 (1개)
Jack
2023년 3월 29일
Hi,
The error message suggests that the argument 'ActivationFunction' is not a valid argument for the fullyConnectedLayer function.
In recent versions of MATLAB (R2020b and later), the ActivationFunction argument has been replaced with Activation. Therefore, the correct syntax to specify the activation function for a fully connected layer in these versions would be:
layers = [fullyConnectedLayer(num_neurons, 'Activation', activation_function)fullyConnectedLayer(1, 'Activation', 'linear')];
Note that the 'purelin' activation function has been replaced with 'linear'.
If you are using an older version of MATLAB, you can try removing the 'ActivationFunction' argument and use the default activation function ('relu'):
layers = [fullyConnectedLayer(num_neurons)fullyConnectedLayer(1, 'ActivationFunction', 'purelin')];
Alternatively, you can specify the activation function using the 'Name' argument, like this:
layers = [fullyConnectedLayer(num_neurons, 'Name', 'fc1', 'ActivationFunction', activation_function) fullyConnectedLayer(1, 'Name', 'output', 'ActivationFunction', 'purelin')];
Here, 'fc1' and 'output' are the layer names, and activation_function is the name of the desired activation function (e.g., 'relu', 'sigmoid', etc.).
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Install Products에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!