DeepLearning - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


DeepLearning

A substantial effort was put into Deep Learning for Maple 2021, including offering a variety of new specialty forms of neural networks.

withDeepLearning:

 

New commands

Examples

Details

New commands

These commands are new for Maple 2021:

• 

BidirectionalLayer

• 

EmbeddingLayer

• 

LongShortTermMemoryLayer

• 

ConvolutionLayer

• 

FlattenLayer

• 

MaxPoolLayer

• 

DenseLayer

• 

GatedRecurrentUnitLayer

• 

Sequential

• 

DropoutLayer

• 

GetEagerExecution

• 

SetEagerExecution

New types of neural networks

The addition of Layer objects offers an easy mechanism for building specialized types of neural networks, including the following:

• 

Convolutional neural networks: using ConvolutionLayer. These networks are often used for tasks such as image and video recognition.

• 

Recurrent neural networks: using GatedRecurrentUnitLayer or LongShortTermMemoryLayer. These networks are often used for text processing or classification.

The new Sequential command allows one or more Layers to be stacked together, feeding the output from one layer into the next as input. This allows you to build sophisticated special-purpose neural networks by composing layers of different types.

Both Layer objects and the composite models created by the Sequential command are examples of Model objects. A Model can be fed new data to generate predictions and can also be saved to a file in the standard HDF5 file format.

 

Examples

Sequential Model: The Pima Diabetes Dataset

In this example we build a Sequential model with DenseLayers to model the Pima diabetes dataset, generating predictions about whether individuals will be diagnosed with a diabetes based on other diagnostic measurements included in the dataset.

 

This dataset is originally from the United States National Institute of Diabetes and Digestive and Kidney Diseases. All patients here are females at least 21 years old of Pima Indian heritage.

Source:
Pima Indian Diabetes Database, https://www.kaggle.com/uciml/pima-indians-diabetes-database.  Data originally published in:

• 

Smith, J.W., Everhart, J.E., Dickson, W.C., Knowler, W.C., & Johannes, R.S. (1988). Using the ADAP learning algorithm to forecast the onset of diabetes mellitus. In Proceedings of the Symposium on Computer Applications and Medical Care (pp. 261--265). IEEE Computer Society Press.

 

We first load the data into a DataFrame:

datasetImportdatasets/pima-epidemiology-diabetes.csv,base=datadir

As before, we divide the dataset into training and test data.  We are attempting to predict the last column, Outcome.

training_data,test_datadataset1..600,..,dataset601..1,..

We define a neural network using the Sequential command which stacks one or more neural network layers.

modelSequentialDenseLayer12,activation=relu,DenseLayer8,activation=relu,DenseLayer1,activation=sigmoid

modelDeepLearning Model<tensorflow.python.keras.engine.sequential.Sequential object at 0x138244bb0>

(2.1.1)

model:-Compileloss=binary_crossentropy&comma;optimizer=adam&comma;metrics=accuracy

Python:−None

(2.1.2)

We can train the data easily with the Fit command:

model:-Fittraining_data..,1..8&comma;training_dataOutcome&comma;epochs=150&comma;batchsize=10

<Python object: <tensorflow.python.keras.callbacks.History object at 0x13838f430>>

(2.1.3)

 

We now have a trained model whose accuracy we can test against the test data  or against any new data. The accuracy is not especially high but nevertheless useful for predictive purposes.

model:-Evaluatetest_data..,1..8&comma;test_dataOutcome

loss=0.613269329071045&comma;accuracy=0.690476179122925

(2.1.4)

 

To get a sense of what how this model behaves on individuals within the dataset, we can take a slice from the test data and compare the observed vs. predicted outcome.

predictionsmodel:-Predicttest_data760..768,1..8

predictions0.2222759127616880.1320905089378360.5618885755538940.1092223823070530.3004200160503390.2347947061061860.2265433967113490.1627641916275020.144395038485527

(2.1.5)

test_data760..768,Outcome,predictions

760176107621763076407650766076717680,0.2222759127616880.1320905089378360.5618885755538940.1092223823070530.3004200160503390.2347947061061860.2265433967113490.1627641916275020.144395038485527

(2.1.6)

Details

• 

The DeepLearning package is implemented using Google TensorFlow™ and now provides access to a subset of the TensorFlow Python API, version 2.2.0.

• 

The DeepLearning package is currently not supported on the following platforms: Macs powered by Apple's M1 chip (Apple Silicon).