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
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
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