singa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <>
Subject [GitHub] [singa] dcslin edited a comment on issue #696: Refactor autograd module
Date Thu, 14 May 2020 03:55:04 GMT

dcslin edited a comment on issue #696:

   Considering the API requirement, and constraints as below:
   API requirement:
   1. [**Model**] multi-input/output (multi loss fn)
   2. [**Model**] Load model from disk, in other words: Model param memory allocation should
be done in `model.__init__`
   API constraints:
   1. [**Model**] graph module buffer first forward call **or** turn off graph module in the
first forward call
   2. [**Layer**] layer param memory allocation & initialization requires input x
   @XJDKC 's scheme 2 and @nudles 's `Placeholder` is close to current implemenation, and
changes required could be small.
   For model building:
   class MyModel(Model):
     def __init__(self, inputs, configs):
       self.linear1=Linear(configs, kernel_init=configs.ker_init)
       super.__init__(inputs) # maybe a bit confuse for user what is this
     def forward(self, inputs):
       return linear1(mylayer(inputs[0], inputs[1]))
   For model running:
   x=PlaceHolder(shape=(batch, shape1, shape2))
   for e in epochs:
     for x, y in data_gen:
       losses = m.loss(y, m(x))
   For Layer building:
   class MyLayer(Layer):
     def __init__(self, configs):
       self.configs = configs
     def __call__(self, inputs):
       if not self.init:
         self.W = Tensor(self.configs, inputs.shape).initializer()
         self.device_check(inputs, self.W)
       return = op1(inputs[0], inputs[1])
   For Module class impl:
   class Module:
     def __init__(self, inputs, configs):
     def __call__(self,inputs):
       return self.forward(*inputs)

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:

View raw message