(self, input_B_Di, input_shape, layerspec_json)
Args:
            layerspec (string): JSON string describing layers
Args:
            layerspec (string): JSON string describing layers
Args : layerspec ( string ) : JSON string describing layers
def __init__(self, input_B_Di, input_shape, layerspec_json):
        '''
        Args:
            layerspec (string): JSON string describing layers
        '''
        assert len(input_shape) >= 1
        self.input_B_Di = input_B_Di

        layerspec = json.loads(layerspec_json)
        util.header('Loading feedforward net specification')
        print json.dumps(layerspec, indent=2, separators=(',', ': '))

        self.layers = []
        with variable_scope(type(self).__name__) as self.__varscope:

            prev_output, prev_output_shape = input_B_Di, input_shape

            for i_layer, ls in enumerate(layerspec):
                with variable_scope('layer_%d' % i_layer):
                    if ls['type'] == 'reshape':
                        _check_keys(ls, ['type', 'new_shape'], [])
                        self.layers.append(ReshapeLayer(prev_output, ls['new_shape']))

                    elif ls['type'] == 'fc':
                        _check_keys(ls, ['type', 'n'], ['initializer'])
                        self.layers.append(AffineLayer(
                            prev_output, prev_output_shape, output_shape=(ls['n'],), initializer=_parse_initializer(ls)))

                    elif ls['type'] == 'nonlin':
                        _check_keys(ls, ['type', 'func'], [])
                        self.layers.append(NonlinearityLayer(prev_output, prev_output_shape, ls['func']))

                    else:
                        raise NotImplementedError('Unknown layer type %s' % ls['type'])

                prev_output, prev_output_shape = self.layers[-1].output, self.layers[-1].output_shape
        self._output, self._output_shape = prev_output, prev_output_shape
def __init__ ( self , input_B_Di , input_shape , layerspec_json ) : assert len ( input_shape ) >= 1 self . input_B_Di = input_B_Di layerspec = json . loads ( layerspec_json ) util . header ( 'Loading feedforward net specification' ) print json . dumps ( layerspec , indent = 2 , separators = ( ',' , ': ' ) ) self . layers = [ ] with variable_scope ( type ( self ) . __name__ ) as self . __varscope : prev_output , prev_output_shape = input_B_Di , input_shape for i_layer , ls in enumerate ( layerspec ) : with variable_scope ( 'layer_%d' % i_layer ) : if ls [ 'type' ] == 'reshape' : _check_keys ( ls , [ 'type' , 'new_shape' ] , [ ] ) self . layers . append ( ReshapeLayer ( prev_output , ls [ 'new_shape' ] ) ) elif ls [ 'type' ] == 'fc' : _check_keys ( ls , [ 'type' , 'n' ] , [ 'initializer' ] ) self . layers . append ( AffineLayer ( prev_output , prev_output_shape , output_shape = ( ls [ 'n' ] , ) , initializer = _parse_initializer ( ls ) ) ) elif ls [ 'type' ] == 'nonlin' : _check_keys ( ls , [ 'type' , 'func' ] , [ ] ) self . layers . append ( NonlinearityLayer ( prev_output , prev_output_shape , ls [ 'func' ] ) ) else : raise NotImplementedError ( 'Unknown layer type %s' % ls [ 'type' ] ) prev_output , prev_output_shape = self . layers [ - 1 ] . output , self . layers [ - 1 ] . output_shape self . _output , self . _output_shape = prev_output , prev_output_shape