Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Train neural network for deep learning

Use `trainNetwork`

to train a convolutional neural network
(ConvNet, CNN) or long short-term memory networks (LSTM or BiLSTM networks) for deep
learning classification and regression problems. You can train a network on either a CPU
or a GPU. For image classification and image regression, you can train using multiple
GPUs, or in parallel. Using GPU, multi-GPU, and parallel options requires Parallel Computing Toolbox™. To use a GPU for deep
learning, you must also have a CUDA^{®} enabled NVIDIA^{®} GPU with compute capability 3.0 or higher. Specify training options, including options for the execution environment,
by using `trainingOptions`

.

`trainedNet = trainNetwork(imds,layers,options)`

`trainedNet = trainNetwork(mbds,layers,options)`

`trainedNet = trainNetwork(X,Y,layers,options)`

`trainedNet = trainNetwork(C,Y,layers,options)`

`trainedNet = trainNetwork(tbl,layers,options)`

`trainedNet = trainNetwork(tbl,responseName,layers,options)`

```
[trainedNet,traininfo]
= trainNetwork(___)
```

trains a network for image classification problems. `trainedNet`

= trainNetwork(`imds`

,`layers`

,`options`

)`imds`

stores the input image data, `layers`

defines the network
architecture, and `options`

defines the training
options.

trains a network for image classification and regression problems.
`trainedNet`

= trainNetwork(`mbds`

,`layers`

,`options`

)`mdbs`

is a type of mini-batch datastore, such as an
augmented image datastore, that preprocesses images for deep learning.

trains a network for image classification and regression problems.
`trainedNet`

= trainNetwork(`X`

,`Y`

,`layers`

,`options`

)`X`

contains the predictor variables and
`Y`

contains the categorical labels or numeric
responses.

trains an LSTM or BiLSTM network for classification and regression problems.
`trainedNet`

= trainNetwork(`C`

,`Y`

,`layers`

,`options`

)`C`

is a cell array containing sequence or time series
predictors and `Y`

contains the responses. For classification
problems, `Y`

is a categorical vector or cell array of
categorical sequences. For regression problems, `Y`

is a
matrix of targets, or a cell array of numeric sequences.

trains a network for classification and regression problems.
`trainedNet`

= trainNetwork(`tbl`

,`layers`

,`options`

)`tbl`

contains numeric data or file paths to the data.
The predictors must be in the first column of `tbl`

. For
information on the targets or response variables, see the tbl argument
description.

trains a network for classification and regression problems. The predictors must
be in the first column of `trainedNet`

= trainNetwork(`tbl`

,`responseName`

,`layers`

,`options`

)`tbl`

. The
`responseName`

argument specifies the response variables
in the table `tbl`

.

`[`

also returns information on the training for any of the input arguments.`trainedNet`

,`traininfo`

]
= trainNetwork(___)

[1] M. Kudo, J. Toyama, and M. Shimbo. "Multidimensional Curve Classification Using Passing-Through Regions." Pattern Recognition Letters. Vol. 20, No. 11–13, pages 1103–1111.

[2] UCI Machine Learning Repository: Japanese Vowels Dataset. https://archive.ics.uci.edu/ml/datasets/Japanese+Vowels

`DAGNetwork`

| `LayerGraph`

| `SeriesNetwork`

| `analyzeNetwork`

| `classify`

| `predict`

| `trainingOptions`

Was this topic helpful?