BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Odesh2
Calcite | Level 5

I am going through the "Deep Learning using SAS Software" and I am on Lesson 5: Transfer Learning and Customization . 

There is a demo on "Creating a customized Learning Rate Policy using FCMP. "I am referring to the 4th and 5th lines ( please see below) of the proc cas. It says: 

 

fcmpact.addRoutines

                 routineCode = {"

 

< Function Definition  >

endsub

"  

This seems as if we are defining a function within  a subroutine. ( addRoutines  ..endsub).  Can we not define a function directly without a subroutine "wrapper" type  of construct ?

 

Thanks.

Odesh.

 

 

 

 

 

 

  1. Odesh2_0-1606172968663.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
AriZitin
SAS Employee

In this example we are using the FCMPACT CAS Action to create an FCMP routine which can be stored in a table. We are doing this because we will need to use the FCMP routine later in the example as part of the Deep Learning Action set.

 

PROC CAS has the ability to directly create user defined functions without using FCMP and thus without a subroutine wrapper (as described in this documentation page: https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.5&docsetId=caslpg&docsetTarget=n1...

Although these functions defined directly in PROC CAS can be used for some tasks in PROC CAS, they cannot be used in all CAS Actions.

In particular we are trying to create a custom learning rate function which will be used in the algorithm statement in the dlTrain CAS Action. The algorithm statement has an option fcmplearningrate, which allows us to specify a FCMP function to use to adjust the learning rate. The syntax here in dlTrain does not support functions defined in CAS without the use of FCMP, so we are forced to define our function using the FCMP subroutine as a wrapper. This is due to the syntax expectations of the dlTrain CAS Action.

 

Here is the snippet of code I was pointing out from the course notes in section 5.5:

 

 

proc cas; 
    dlTrain / table={name='Encoders', where='_PartInd_=1'} model='ConVNN3' 
        modelWeights={name='ConVTrainedWeights_d', replace=1} 
        bestweights={name='ConVbestweights', replace=1} 
        dataSpecs={ {data={'_LayerAct_0_IMG_0_'}, layer='data1', type='Image'} {data={'_LayerAct_11_IMG_0_'}, layer='data2', type='Image'} {data='_label_', layer='outlayer', type='numericNominal'} }
        GPU=True ValidTable={name='Encoders', where='_PartInd_=2'} 
        optimizer={minibatchsize=80, 
        algorithm={method='Momentum', gamma=1.006, fcmplearningrate='CusLR' , learningrate=.01} loglevel=2 maxepochs=160} 
        seed=12345; 
Quit;

 

 

Since the dlTrain action explicitly expects a custom learning rate function in the form of an FCMP routine (the fcmplearningrate parameter above) we must define our function using the FCMP subroutine.

 

Great question!

 

-Ari Zitin

View solution in original post

2 REPLIES 2
AriZitin
SAS Employee

In this example we are using the FCMPACT CAS Action to create an FCMP routine which can be stored in a table. We are doing this because we will need to use the FCMP routine later in the example as part of the Deep Learning Action set.

 

PROC CAS has the ability to directly create user defined functions without using FCMP and thus without a subroutine wrapper (as described in this documentation page: https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.5&docsetId=caslpg&docsetTarget=n1...

Although these functions defined directly in PROC CAS can be used for some tasks in PROC CAS, they cannot be used in all CAS Actions.

In particular we are trying to create a custom learning rate function which will be used in the algorithm statement in the dlTrain CAS Action. The algorithm statement has an option fcmplearningrate, which allows us to specify a FCMP function to use to adjust the learning rate. The syntax here in dlTrain does not support functions defined in CAS without the use of FCMP, so we are forced to define our function using the FCMP subroutine as a wrapper. This is due to the syntax expectations of the dlTrain CAS Action.

 

Here is the snippet of code I was pointing out from the course notes in section 5.5:

 

 

proc cas; 
    dlTrain / table={name='Encoders', where='_PartInd_=1'} model='ConVNN3' 
        modelWeights={name='ConVTrainedWeights_d', replace=1} 
        bestweights={name='ConVbestweights', replace=1} 
        dataSpecs={ {data={'_LayerAct_0_IMG_0_'}, layer='data1', type='Image'} {data={'_LayerAct_11_IMG_0_'}, layer='data2', type='Image'} {data='_label_', layer='outlayer', type='numericNominal'} }
        GPU=True ValidTable={name='Encoders', where='_PartInd_=2'} 
        optimizer={minibatchsize=80, 
        algorithm={method='Momentum', gamma=1.006, fcmplearningrate='CusLR' , learningrate=.01} loglevel=2 maxepochs=160} 
        seed=12345; 
Quit;

 

 

Since the dlTrain action explicitly expects a custom learning rate function in the form of an FCMP routine (the fcmplearningrate parameter above) we must define our function using the FCMP subroutine.

 

Great question!

 

-Ari Zitin

Odesh2
Calcite | Level 5

Thanks Ari.

Nice clear explanation.

 

Odesh.