def __init__( self, cell_size, obj_shape, hidden_size, img_shape, box_range, anchor_shape, F, A, neighbor = 1 ): Sequential.__init__(self) self.add_module('encoder', Encoder( cell_size, obj_shape, hidden_size[:2], img_shape, box_range, anchor_shape, F, A, neighbor )) self.add_module('decoder', Decoder(img_shape, obj_shape, hidden_size[2:], cell_size, A))
def __init__(self, in_shape, out_shape, size, activate=Sigmoid, bias=True): ''' size: int or Iterable. len == 2. activate: activate function to be use. ''' if isinstance(size, int): size = [size] * 2 elif not isinstance(size, Iterable): raise ValueError('size must be Iterable.') else: size = size[:2] if len(size) == 1: size = [size[0]] * 2 Sequential.__init__(self, Linear(in_shape, size[0], bias), activate(), Linear(*size, bias), activate(), Linear(size[1], out_shape, bias) # No activate at last )