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), a long short-term memory (LSTM) network, or a bidirectional LSTM
(BiLSTM) network 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(ds,layers,options)`

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

`trainedNet = trainNetwork(sequences,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 using datastore `trainedNet`

= trainNetwork(`ds`

,`layers`

,`options`

)`ds`

that returns read data
in a two-column table or two-column cell array. The two columns specify the
network inputs and expected responses, respectively.

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(`sequences`

,`Y`

,`layers`

,`options`

)`sequences`

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

contains the responses. For
classification problems, `Y`

is a categorical vector or a
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 tbl.

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 `tbl`

.

`[`

also returns information on the training using any of the input arguments in the
previous syntaxes.`trainedNet`

,`traininfo`

]
= trainNetwork(___)

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

[2] Kudo, M., J. Toyama, and M.
Shimbo. *Japanese Vowels Data Set*.
https://archive.ics.uci.edu/ml/datasets/Japanese+Vowels

`DAGNetwork`

| `LayerGraph`

| `SeriesNetwork`

| `analyzeNetwork`

| `assembleNetwork`

| `classify`

| `predict`

| `trainingOptions`