Is there any layer defined in matlab for sine activation function? Or else can we define the layer using functionLayer?

2 visualizzazioni (ultimi 30 giorni)
How we can use a layer with sine activation function? Is it possible to use the functionLayer to define a sine activation function or should I define a class for creating the layer as shown in https://in.mathworks.com/help/deeplearning/ug/define-custom-deep-learning-intermediate-layers.html?

Risposta accettata

Matt J
Matt J il 1 Dic 2023
If it will not have any learnable parameters, you can use a functionLayer.
  8 Commenti
Matt J
Matt J il 8 Dic 2023
Does this make any more sense?
layer=CoAtten(Name="atten");
validInputSize = [1 14 1024];
layout = networkDataLayout(validInputSize,"CBT");
layer = initialize(layer,layout);
checkLayer(layer,layout,ObservationDimension=2)
Skipping GPU tests. No compatible GPU device found. Skipping code generation compatibility tests. To check validity of the layer for code generation, specify the CheckCodegenCompatibility and ObservationDimension options. Running nnet.checklayer.TestLayerWithoutBackward .. ================================================================================ nnet.checklayer.TestLayerWithoutBackward/formattableLayerPredictIsFormatted(Observations=one) was filtered. Test Diagnostic: Test did not run because 'predict' threw an error. ================================================================================ . ================================================================================ nnet.checklayer.TestLayerWithoutBackward/formattableLayerPredictIsFormatted(Observations=multiple) was filtered. Test Diagnostic: Test did not run because 'predict' threw an error. ================================================================================ .... ================================================================================ Verification failed in nnet.checklayer.TestLayerWithoutBackward/predictDoesNotError(Observations=one). ---------------- Test Diagnostic: ---------------- Test failure may be due to the layer not being initialized. If the layer is not initialized, then initialize it by calling its initialize method. --------------------- Framework Diagnostic: --------------------- The function 'predict' threw an error: Undefined function 'initializeGlorot' for input arguments of type 'double'. Error in CoAtten/predict (line 57) weights=initializeGlorot(sz,numout,numin); ------------------ Stack Information: ------------------ In /MATLAB/toolbox/nnet/cnn/+nnet/+checklayer/TestLayerWithoutBackward.m (TestLayerWithoutBackward.predictDoesNotError) at 26 ================================================================================ . ================================================================================ Verification failed in nnet.checklayer.TestLayerWithoutBackward/predictDoesNotError(Observations=multiple). ---------------- Test Diagnostic: ---------------- Test failure may be due to the layer not being initialized. If the layer is not initialized, then initialize it by calling its initialize method. --------------------- Framework Diagnostic: --------------------- The function 'predict' threw an error: Undefined function 'initializeGlorot' for input arguments of type 'double'. Error in CoAtten/predict (line 57) weights=initializeGlorot(sz,numout,numin); ------------------ Stack Information: ------------------ In /MATLAB/toolbox/nnet/cnn/+nnet/+checklayer/TestLayerWithoutBackward.m (TestLayerWithoutBackward.predictDoesNotError) at 26 ================================================================================ .. .... ================================================================================ nnet.checklayer.TestLayerWithoutBackward/predictIsConsistentInType(Precision=single,Device=cpu) was filtered. Test Diagnostic: Test did not run because 'predict' threw an error. ================================================================================ . ================================================================================ nnet.checklayer.TestLayerWithoutBackward/predictIsConsistentInType(Precision=double,Device=cpu) was filtered. Test Diagnostic: Test did not run because 'predict' threw an error. ================================================================================ ..... .. ================================================================================ nnet.checklayer.TestLayerWithoutBackward/backwardPropagationDoesNotError(Observations=one) was filtered. Test Diagnostic: Test did not run because 'predict' threw an error. ================================================================================ . ================================================================================ nnet.checklayer.TestLayerWithoutBackward/backwardPropagationDoesNotError(Observations=multiple) was filtered. Test Diagnostic: Test did not run because 'predict' threw an error. ================================================================================ . Done nnet.checklayer.TestLayerWithoutBackward __________ Failure Summary: Name Failed Incomplete Reason(s) ================================================================================================================================================= nnet.checklayer.TestLayerWithoutBackward/formattableLayerPredictIsFormatted(Observations=one) X Filtered by assumption. ------------------------------------------------------------------------------------------------------------------------------------------------- nnet.checklayer.TestLayerWithoutBackward/formattableLayerPredictIsFormatted(Observations=multiple) X Filtered by assumption. ------------------------------------------------------------------------------------------------------------------------------------------------- nnet.checklayer.TestLayerWithoutBackward/predictDoesNotError(Observations=one) X Failed by verification. ------------------------------------------------------------------------------------------------------------------------------------------------- nnet.checklayer.TestLayerWithoutBackward/predictDoesNotError(Observations=multiple) X Failed by verification. ------------------------------------------------------------------------------------------------------------------------------------------------- nnet.checklayer.TestLayerWithoutBackward/predictIsConsistentInType(Precision=single,Device=cpu) X Filtered by assumption. ------------------------------------------------------------------------------------------------------------------------------------------------- nnet.checklayer.TestLayerWithoutBackward/predictIsConsistentInType(Precision=double,Device=cpu) X Filtered by assumption. ------------------------------------------------------------------------------------------------------------------------------------------------- nnet.checklayer.TestLayerWithoutBackward/backwardPropagationDoesNotError(Observations=one) X Filtered by assumption. ------------------------------------------------------------------------------------------------------------------------------------------------- nnet.checklayer.TestLayerWithoutBackward/backwardPropagationDoesNotError(Observations=multiple) X Filtered by assumption. Test Summary: 16 Passed, 2 Failed, 6 Incomplete, 10 Skipped. Time elapsed: 1.3986 seconds.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by