The :class:`Model` class represents a neural network. It should be subclassed when implementing a dynamic model, where 'forward' method must be overwritten. Otherwise, please specify 'inputs' tensor(s) and 'outputs' tensor(s) to create a static model. In that case, 'inputs' tensors
| 19 | |
| 20 | |
| 21 | class Model(object): |
| 22 | """The :class:`Model` class represents a neural network. |
| 23 | |
| 24 | It should be subclassed when implementing a dynamic model, |
| 25 | where 'forward' method must be overwritten. |
| 26 | Otherwise, please specify 'inputs' tensor(s) and 'outputs' tensor(s) |
| 27 | to create a static model. In that case, 'inputs' tensors should come |
| 28 | from tl.layers.Input(). |
| 29 | |
| 30 | Parameters |
| 31 | ----------- |
| 32 | inputs : a Layer or list of Layer |
| 33 | The input(s) to the model. |
| 34 | outputs : a Layer or list of Layer |
| 35 | The output(s) to the model. |
| 36 | name : None or str |
| 37 | The name of the model. |
| 38 | |
| 39 | Methods |
| 40 | --------- |
| 41 | __init__(self, inputs=None, outputs=None, name=None) |
| 42 | Initializing the Model. |
| 43 | inputs() |
| 44 | Get input tensors to this network (only avaiable for static model). |
| 45 | outputs() |
| 46 | Get output tensors to this network (only avaiable for static model). |
| 47 | __call__(inputs, is_train=None, **kwargs) |
| 48 | Forward input tensors through this network. |
| 49 | all_layers() |
| 50 | Get all layer objects of this network in a list of layers. |
| 51 | weights() |
| 52 | Get the weights of this network in a list of tensors. |
| 53 | train() |
| 54 | Set this network in training mode. (affect layers e.g. Dropout, BatchNorm). |
| 55 | eval() |
| 56 | Set this network in evaluation mode. |
| 57 | as_layer() |
| 58 | Set this network as a ModelLayer so that it can be integrated into another Model. |
| 59 | release_memory() |
| 60 | Release the memory that was taken up by tensors which are maintained by this network. |
| 61 | save_weights(self, filepath, format='hdf5') |
| 62 | Save the weights of this network in a given format. |
| 63 | load_weights(self, filepath, format=None, in_order=True, skip=False) |
| 64 | Load weights into this network from a specified file. |
| 65 | save(self, filepath, save_weights=True) |
| 66 | Save the network with/without weights. |
| 67 | load(filepath, save_weights=True) |
| 68 | Load the network with/without weights. |
| 69 | |
| 70 | Examples |
| 71 | --------- |
| 72 | >>> import tensorflow as tf |
| 73 | >>> import numpy as np |
| 74 | >>> from tensorlayer.layers import Input, Dense, Dropout |
| 75 | >>> from tensorlayer.models import Model |
| 76 | |
| 77 | Define static model |
| 78 |
no outgoing calls
searching dependent graphs…