Example #1
0
def mlp3layer( param ):
    factory = NNFactory( param )
    # setup network for 2 layer perceptron
    i_node = np.zeros( (param.batch_size, param.input_size), 'float32' )
    o_node = np.zeros( (param.batch_size, param.num_class), 'float32' )
    h1_node = np.zeros( (param.batch_size, param.num_hidden), 'float32' )
    h2_node = np.zeros_like( h1_node )

    h1_node2 = np.zeros( (param.batch_size, param.num_hidden2), 'float32' )
    h2_node2 = np.zeros_like( h1_node2 )
    
    o_label = factory.create_olabel()

    nodes = [ i_node, h1_node, h2_node, h1_node2, h2_node2, o_node ]

    layers = [ nnet.FullLayer( i_node, h1_node, param.init_sigma, param.rec_gsqr() )  ]
    layers+= [ nnet.ActiveLayer( h1_node, h2_node, param.node_type )   ]

    layers+= [ nnet.FullLayer( h2_node, h1_node2, param.init_sigma, param.rec_gsqr() )  ]
    layers+= [ nnet.ActiveLayer( h1_node2, h2_node2, param.node_type )   ]

    layers+= [ nnet.FullLayer( h2_node2, o_node, param.init_sigma, param.rec_gsqr() )  ]

    layers+= [ factory.create_outlayer( o_node, o_label ) ]
    return net
Example #2
0
def mlp2layer(param):
    factory = NNFactory(param)
    # setup network for 2 layer perceptron
    i_node = np.zeros((param.batch_size, param.input_size), 'float32')
    o_node = np.zeros((param.batch_size, param.num_class), 'float32')
    h1_node = np.zeros((param.batch_size, param.num_hidden), 'float32')
    h2_node = np.zeros_like(h1_node)
    o_label = np.zeros((param.batch_size), 'int8')

    nodes = [i_node, h1_node, h2_node, o_node]
    layers = [
        nnet.FullLayer(i_node, h1_node, param.init_sigma, param.rec_gsqr())
    ]
    layers += [nnet.ActiveLayer(h1_node, h2_node, param.node_type)]
    layers += [
        nnet.FullLayer(h2_node, o_node, param.init_sigma, param.rec_gsqr())
    ]
    layers += [nnet.SoftmaxLayer(o_node, o_label)]

    net = nnet.NNetwork(layers, nodes, o_label, factory)
    return net
Example #3
0
def softmax( param ):
    factory = NNFactory( param )
    # setup network for softmax
    i_node = np.zeros( (param.batch_size, param.input_size), 'float32' )
    o_node = np.zeros( (param.batch_size, param.num_class), 'float32' )
    o_label = factory.create_olabel()

    nodes = [ i_node, o_node ]
    layers = [ nnet.FullLayer( i_node, o_node, param.init_sigma, param.rec_gsqr() )  ]

    layers+= [ factory.create_outlayer( o_node, o_label ) ]
    net = nnet.NNetwork( layers, nodes, o_label, factory ) 
    return net
Example #4
0
def softmax(param):
    # setup network for softmax
    i_node = np.zeros((param.batch_size, param.input_size), 'float32')
    o_node = np.zeros((param.batch_size, param.num_class), 'float32')
    o_label = np.zeros((param.batch_size), 'int8')

    nodes = [i_node, o_node]
    layers = [
        nnet.FullLayer(i_node, o_node, param.init_sigma, param.rec_gsqr())
    ]

    layers += [nnet.SoftmaxLayer(o_node, o_label)]
    net = nnet.NNetwork(layers, nodes, o_label, factory)
    return net