The addLayer action adds a layer to a deep learning model. It is part of the Deep Learning action set, which provides a comprehensive suite of tools for modeling and scoring with deep neural networks (DNN), convolutional neural networks (CNN), and recurrent neural networks (RNN). This action is fundamental in constructing the architecture of a neural network, allowing for the sequential addition and configuration of various layer types.
| Parameter | Description |
|---|---|
| layer | Specifies the layer type and its related parameters. This is a dictionary where the 'type' key determines the kind of layer (e.g., 'INPUT', 'CONV', 'FC') and other keys specify its configuration. |
| modelTable | Specifies the in-memory table that represents the model to which the layer will be added. |
| name | Specifies a unique name for the layer. This name is used to reference the layer, for instance, in the 'srcLayers' parameter of subsequent layers. |
| nThreads | Specifies the number of threads to use for the computation. |
| replace | When set to True, if a layer with the same name already exists in the model, it will be replaced by this new layer. |
| sharingWeights | Specifies the name of another layer from which to share weights. This is useful for creating models like Siamese networks. |
| srcLayers | Specifies a list of names of the source layers for this new layer. This defines the data flow and connectivity within the network. |
This action does not directly use training data. It operates on a model definition table. However, to build a complete, trainable model, you would typically first load your data (e.g., images, text, or tabular data) into a CAS table.
| 1 | /* No |
| 2 | data creation code is directly associated with addLayer. It modifies a model table. */ |
This example demonstrates how to add a simple 'INPUT' layer to a new model named 'my_model'. This is typically the first step in building a model architecture.
| 1 | PROC CAS; |
| 2 | DEEPLEARN.addLayer / |
| 3 | modelTable={name='my_model'} |
| 4 | layer={type='input', nchannels=3, width=224, height=224} |
| 5 | name='data'; |
| 6 | RUN; |
This example shows how to add a convolutional layer ('CONVO') to an existing model that already has an input layer named 'data'. The 'srcLayers' parameter is used to connect the new convolutional layer to the input layer.
| 1 | PROC CAS; |
| 2 | DEEPLEARN.addLayer / |
| 3 | modelTable={name='my_model'} |
| 4 | name='conv1' |
| 5 | layer={type='convolution', nFilters=32, width=3, height=3, stride=1, act='relu'} |
| 6 | srcLayers={'data'}; |
| 7 | RUN; |
This example illustrates adding a pooling layer and demonstrates a more advanced concept of sharing weights from another layer, although pooling layers themselves do not have weights. The 'sharingWeights' parameter is shown for conceptual understanding, typically used with layers like 'CONV' or 'FC'.
| 1 | PROC CAS; |
| 2 | DEEPLEARN.addLayer / |
| 3 | modelTable={name='my_model'} |
| 4 | name='pool1' |
| 5 | layer={type='pooling', width=2, height=2, stride=2, pool='max'} |
| 6 | srcLayers={'conv1'} |
| 7 | sharingWeights='conv1_shared'; /* Note: Conceptual use for pooling layer */ |
| 8 | RUN; |
A retail company wants to build a Convolutional Neural Network (CNN) to automatically classify images of its products into categories like 'shirts', 'shoes', and 'accessories'. ...
A financial institution needs to verify customer signatures by comparing a new signature image with a reference image on file. This requires a Siamese Network, which uses two id...
A data science team is experimenting with different hyperparameters for a model. They need to replace an existing layer with a new one that has a different configuration. This s...