Main Content

generateFunction

Class: Autoencoder

Generate a MATLAB function to run the autoencoder

Description

generateFunction(autoenc) generates a complete stand-alone function in the current directory, to run the autoencoder autoenc on input data.

example

generateFunction(autoenc,pathname) generates a complete stand-alone function to run the autoencoder autoenc on input data in the location specified by pathname.

example

generateFunction(autoenc,pathname,Name,Value) generates a complete stand-alone function with additional options specified by the Name,Value pair argument.

Input Arguments

expand all

Trained autoencoder, returned as an object of the Autoencoder class.

Location for generated function, specified as a string.

Example: 'C:\MyDocuments\Autoencoders'

Data Types: char

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Examples

expand all

Load the sample data.

X = iris_dataset;

Train an autoencoder with 4 neurons in the hidden layer.

autoenc = trainAutoencoder(X,4);

Generate the code for running the autoencoder. Show the links to the MATLAB® function.

generateFunction(autoenc)
MATLAB function generated: neural_function.m
To view generated function code: edit neural_function
For examples of using function: help neural_function

Generate the code for the autoencoder in a specific path.

generateFunction(autoenc,'H:\Documents\Autoencoder')
MATLAB function generated: H:\Documents\Autoencoder.m
To view generated function code: edit Autoencoder
For examples of using function: help Autoencoder

Tips

  • If you do not specify the path and the file name, generateFunction, by default, creates the code in an m-file with the name neural_function.m. You can change the file name after generateFunction generates it. Or you can specify the path and file name using the pathname input argument in the call to generateFunction.

Version History

Introduced in R2015b