Initializing the Model. Parameters ---------- inputs : Tensor or list of tensors Input tensor(s), which must come from tl.layers.Input() outputs : Tensor or list of tensors Output tensor(s), which must be the output(s) of some TL laye
(self, inputs=None, outputs=None, name=None)
| 138 | return self._outputs |
| 139 | |
| 140 | def __init__(self, inputs=None, outputs=None, name=None): |
| 141 | """ |
| 142 | Initializing the Model. |
| 143 | |
| 144 | Parameters |
| 145 | ---------- |
| 146 | inputs : Tensor or list of tensors |
| 147 | Input tensor(s), which must come from tl.layers.Input() |
| 148 | outputs : Tensor or list of tensors |
| 149 | Output tensor(s), which must be the output(s) of some TL layers |
| 150 | name : str or None |
| 151 | Name for this network |
| 152 | """ |
| 153 | # Auto naming if the name is not given |
| 154 | self._NameNone = False |
| 155 | global _global_model_name_dict |
| 156 | global _global_model_name_set |
| 157 | if name is None: |
| 158 | self._NameNone = True |
| 159 | prefix = self.__class__.__name__.lower() |
| 160 | if _global_model_name_dict.get(prefix) is not None: |
| 161 | _global_model_name_dict[prefix] += 1 |
| 162 | name = prefix + '_' + str(_global_model_name_dict[prefix]) |
| 163 | else: |
| 164 | _global_model_name_dict[prefix] = 0 |
| 165 | name = prefix |
| 166 | while name in _global_model_name_set: |
| 167 | _global_model_name_dict[prefix] += 1 |
| 168 | name = prefix + '_' + str(_global_model_name_dict[prefix]) |
| 169 | _global_model_name_set.add(name) |
| 170 | else: |
| 171 | if name in _global_model_name_set: |
| 172 | raise ValueError( |
| 173 | 'Model name \'%s\' has already been used by another model. Please change the model name.' % name |
| 174 | ) |
| 175 | _global_model_name_set.add(name) |
| 176 | _global_model_name_dict[name] = 0 |
| 177 | |
| 178 | # Model properties |
| 179 | self.name = name |
| 180 | |
| 181 | # Model state: train or test |
| 182 | self.is_train = None |
| 183 | |
| 184 | # Model weights |
| 185 | self._all_weights = None |
| 186 | self._trainable_weights = None |
| 187 | self._nontrainable_weights = None |
| 188 | |
| 189 | # Model args of all layers, ordered by all_layers |
| 190 | self._config = None |
| 191 | |
| 192 | # Model inputs and outputs |
| 193 | # TODO: note that in dynamic network, inputs and outputs are both None, may cause problem, test needed |
| 194 | self._inputs = inputs |
| 195 | self._outputs = outputs |
| 196 | |
| 197 | # Model converted into a Layer |
nothing calls this directly
no test coverage detected