Caffe2 - Python API
A deep learning, cross platform ML framework
net_modifier.py
1 from __future__ import absolute_import
2 from __future__ import division
3 from __future__ import print_function
4 from __future__ import unicode_literals
5 
6 import abc
7 import six
8 
9 
10 class NetModifier(six.with_metaclass(abc.ABCMeta, object)):
11  """
12  An abstraction class for supporting modifying a generated net.
13  Inherited classes should implement the modify_net method where
14  related operators are added to the net.
15 
16  Example usage:
17  modifier = SomeNetModifier(opts)
18  modifier(net)
19  """
20 
21  def __init__(self):
22  pass
23 
24  @abc.abstractmethod
25  def modify_net(self, net, init_net=None, grad_map=None, blob_to_device=None):
26  pass
27 
28  def __call__(self, net, init_net=None, grad_map=None, blob_to_device=None,
29  modify_output_record=False):
30  self.modify_net(
31  net,
32  init_net=init_net,
33  grad_map=grad_map,
34  blob_to_device=blob_to_device,
35  modify_output_record=modify_output_record)