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

조회 수: 2 (최근 30일)
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?

채택된 답변

Matt J
Matt J 2023년 12월 1일
If it will not have any learnable parameters, you can use a functionLayer.
  댓글 수: 8
Matt J
Matt J 2023년 12월 8일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Build Deep Neural Networks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by