示例#1
0
文件: nncfg.py 项目: wangqinz/sghmc
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
示例#2
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
示例#3
0
文件: nncfg.py 项目: wangqinz/sghmc
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 = factory.create_olabel()

    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+= [ factory.create_outlayer( o_node, o_label ) ]

    net = nnet.NNetwork( layers, nodes, o_label, factory )    
    return net