Generic property that maps func to the layer names into an OrderedDict. Used for top_names and bottom_names. Parameters ---------- func: function id -> [id] field: implementation field name (cache) Returns ------ A one-parameter function that can be set as a p
(func, field)
| 303 | yield padded_batch |
| 304 | |
| 305 | def _Net_get_id_name(func, field): |
| 306 | """ |
| 307 | Generic property that maps func to the layer names into an OrderedDict. |
| 308 | |
| 309 | Used for top_names and bottom_names. |
| 310 | |
| 311 | Parameters |
| 312 | ---------- |
| 313 | func: function id -> [id] |
| 314 | field: implementation field name (cache) |
| 315 | |
| 316 | Returns |
| 317 | ------ |
| 318 | A one-parameter function that can be set as a property. |
| 319 | """ |
| 320 | @property |
| 321 | def get_id_name(self): |
| 322 | if not hasattr(self, field): |
| 323 | id_to_name = list(self.blobs) |
| 324 | res = OrderedDict([(self._layer_names[i], |
| 325 | [id_to_name[j] for j in func(self, i)]) |
| 326 | for i in range(len(self.layers))]) |
| 327 | setattr(self, field, res) |
| 328 | return getattr(self, field) |
| 329 | return get_id_name |
| 330 | |
| 331 | # Attach methods to Net. |
| 332 | Net.blobs = _Net_blobs |