Main Content

generateFunction

Class:Autoencoder

Generate a MATLAB function to run the autoencoder

Description

example

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

example

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

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

Input Arguments

expand all

Trained autoencoder, returned as an object of theAutoencoderclass.

Location for generated function, specified as a string.

Example:'C:\MyDocuments\Autoencoders'

Data Types:char

Name-Value Arguments

Specify optional pairs of arguments asName1=Value1,...,NameN=ValueN, whereNameis the argument name andValueis 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 encloseNamein 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 nameneural_function.m. You can change the file name aftergenerateFunctiongenerates it. Or you can specify the path and file name using thepathnameinput argument in the call togenerateFunction.

版本历史

Introduced in R2015b