當前位置: 首頁>>代碼示例>>Python>>正文


Python net.Net方法代碼示例

本文整理匯總了Python中net.Net方法的典型用法代碼示例。如果您正苦於以下問題:Python net.Net方法的具體用法?Python net.Net怎麽用?Python net.Net使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net的用法示例。


在下文中一共展示了net.Net方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: evaluate

# 需要導入模塊: import net [as 別名]
# 或者: from net import Net [as 別名]
def evaluate(args):
    if args.cuda:
        ctx = mx.gpu(0)
    else:
        ctx = mx.cpu(0)
    # images
    content_image = utils.tensor_load_rgbimage(args.content_image,ctx, size=args.content_size, keep_asp=True)
    style_image = utils.tensor_load_rgbimage(args.style_image, ctx, size=args.style_size)
    style_image = utils.preprocess_batch(style_image)
    # model
    style_model = net.Net(ngf=args.ngf)
    style_model.load_parameters(args.model, ctx=ctx)
    # forward
    style_model.set_target(style_image)
    output = style_model(content_image)
    utils.tensor_save_bgrimage(output[0], args.output_image, args.cuda) 
開發者ID:awslabs,項目名稱:dynamic-training-with-apache-mxnet-on-aws,代碼行數:18,代碼來源:main.py

示例2: __init__

# 需要導入模塊: import net [as 別名]
# 或者: from net import Net [as 別名]
def __init__(self):
        super(Predictor, self).__init__()
        num_units = 512
        num_layer = 2
        batch_size = 1
        data_dir = 'data/'
        input_file = 'poetry.txt'
        vocab_file = 'vocab.pkl'
        tensor_file = 'tensor.npy'

        self.data = Data(data_dir, input_file, vocab_file, tensor_file, 
                        is_train=False, batch_size=batch_size)
        self.model = Net(self.data, num_units, num_layer, batch_size)
        self.sess = tf.Session()

        saver = tf.train.Saver(tf.global_variables())
        saver.restore(self.sess, 'model/model')
        print('Load model done.' + '\n') 
開發者ID:stardut,項目名稱:Text-Generate-RNN,代碼行數:20,代碼來源:sample.py

示例3: start

# 需要導入模塊: import net [as 別名]
# 或者: from net import Net [as 別名]
def start():
    global training_data, n, t

    training_data = load_data()

    print 'Data loaded...'

    layers = []
    layers.append({'type': 'input', 'out_sx': 1, 'out_sy': 1, 'out_depth': 255})
    layers.append({'type': 'fc', 'num_neurons': 100, 'activation': 'sigmoid'})
    layers.append({'type': 'softmax', 'num_classes': 255})

    print 'Layers made...'

    n = Net(layers)

    print 'Net made...'
    print n

    t = Trainer(n, {'method': 'adadelta', 'batch_size': 10, 'l2_decay': 0.0001});

    print 'Trainer made...' 
開發者ID:benglard,項目名稱:ConvNetPy,代碼行數:24,代碼來源:next_letter.py

示例4: start

# 需要導入模塊: import net [as 別名]
# 或者: from net import Net [as 別名]
def start():
    global network, sgd

    layers = []
    layers.append({'type': 'input', 'out_sx': 1, 'out_sy': 1, 'out_depth': 7})
    #layers.append({'type': 'fc', 'num_neurons': 30, 'activation': 'relu'})
    #layers.append({'type': 'fc', 'num_neurons': 30, 'activation': 'relu'})
    layers.append({'type': 'softmax', 'num_classes': 2}) #svm works too
    print 'Layers made...'

    network = Net(layers)
    print 'Net made...'
    print network

    sgd = Trainer(network, {'momentum': 0.2, 'l2_decay': 0.001})
    print 'Trainer made...'
    print sgd 
開發者ID:benglard,項目名稱:ConvNetPy,代碼行數:19,代碼來源:titanic.py

示例5: start

# 需要導入模塊: import net [as 別名]
# 或者: from net import Net [as 別名]
def start():
    global network, t

    layers = []
    layers.append({'type': 'input', 'out_sx': 30, 'out_sy': 30, 'out_depth': 1})
    layers.append({'type': 'fc', 'num_neurons': 100, 'activation': 'sigmoid'})
    layers.append({'type': 'softmax', 'num_classes': 7})
    print 'Layers made...'

    network = Net(layers)
    print 'Net made...'
    print network

    t = Trainer(network, {'method': 'adadelta', 'batch_size': 20, 'l2_decay': 0.001})
    print 'Trainer made...'
    print t 
開發者ID:benglard,項目名稱:ConvNetPy,代碼行數:18,代碼來源:faces.py

示例6: start

# 需要導入模塊: import net [as 別名]
# 或者: from net import Net [as 別名]
def start():
    global training_data, testing_data, network, t, N, labels

    data = load_data()
    shuffle(data)
    size = int(len(data) * 0.01)
    training_data, testing_data = data[size:], data[:size]
    print 'Data loaded...'

    layers = []
    layers.append({'type': 'input', 'out_sx': 1, 'out_sy': 1, 'out_depth': N})
    layers.append({'type': 'fc', 'num_neurons': 10, 'activation': 'sigmoid'})
    layers.append({'type': 'softmax', 'num_classes': len(labels)})
    print 'Layers made...'

    network = Net(layers)

    print 'Net made...'
    print network

    t = Trainer(network, {'method': 'adadelta', 'batch_size': 10, 'l2_decay': 0.0001}); 
開發者ID:benglard,項目名稱:ConvNetPy,代碼行數:23,代碼來源:dialogue.py

示例7: start

# 需要導入模塊: import net [as 別名]
# 或者: from net import Net [as 別名]
def start():
    global training_data, testing_data, n, t

    training_data = load_data()
    testing_data = load_data(False)

    print 'Data loaded...'

    layers = []
    layers.append({'type': 'input', 'out_sx': 28, 'out_sy': 28, 'out_depth': 1})
    layers.append({
        'type': 'capsule', 'num_neurons': 30, 
        'num_recog': 3, 'num_gen': 4, 'num_pose': 2,
        'dx': 1, 'dy': 0
    })
    layers.append({'type': 'regression', 'num_neurons': 28 * 28})
    print 'Layers made...'

    n = Net(layers)

    print 'Net made...'
    print n

    t = Trainer(n, {'method': 'sgd', 'batch_size': 20, 'l2_decay': 0.001})
    print 'Trainer made...' 
開發者ID:benglard,項目名稱:ConvNetPy,代碼行數:27,代碼來源:transforming_autoencoder.py

示例8: start

# 需要導入模塊: import net [as 別名]
# 或者: from net import Net [as 別名]
def start():
    global training_data, network, t, N

    training_data = load_data()
    print 'Data loaded...'

    layers = []
    layers.append({'type': 'input', 'out_sx': 1, 'out_sy': 1, 'out_depth': N})
    layers.append({'type': 'fc', 'num_neurons': 50, 'activation': 'sigmoid'})
    layers.append({'type': 'fc', 'num_neurons': 10, 'activation': 'sigmoid'})
    layers.append({'type': 'fc', 'num_neurons': 50, 'activation': 'sigmoid'})
    layers.append({'type': 'regression', 'num_neurons': N})

    print 'Layers made...'

    network = Net(layers)

    print 'Net made...'
    print network

    t = Trainer(network, {'method': 'adadelta', 'batch_size': 4, 'l2_decay': 0.0001}); 
開發者ID:benglard,項目名稱:ConvNetPy,代碼行數:23,代碼來源:topics.py

示例9: start

# 需要導入模塊: import net [as 別名]
# 或者: from net import Net [as 別名]
def start():
    global training_data, testing_data, n, t

    training_data = load_data()
    testing_data = load_data(False)

    print 'Data loaded...'

    layers = []
    layers.append({'type': 'input', 'out_sx': 28, 'out_sy': 28, 'out_depth': 1})
    layers.append({'type': 'fc', 'num_neurons': 50, 'activation': 'tanh'})
    layers.append({'type': 'fc', 'num_neurons': 50, 'activation': 'tanh'})
    layers.append({'type': 'fc', 'num_neurons': 2, 'activation': 'tanh'})
    layers.append({'type': 'fc', 'num_neurons': 50, 'activation': 'tanh'})
    layers.append({'type': 'fc', 'num_neurons': 50, 'activation': 'tanh'})
    layers.append({'type': 'regression', 'num_neurons': 28 * 28})
    print 'Layers made...'

    n = Net(layers)
    print 'Net made...'
    print n

    t = Trainer(n, {'method': 'adadelta', 'learning_rate': 1.0, 'batch_size': 50, 'l2_decay': 0.001, 'l1_decay': 0.001});
    print 'Trainer made...' 
開發者ID:benglard,項目名稱:ConvNetPy,代碼行數:26,代碼來源:autoencoder_vis.py

示例10: start

# 需要導入模塊: import net [as 別名]
# 或者: from net import Net [as 別名]
def start():
    global training_data, testing_data, network, t, N

    all_data = load_data()
    shuffle(all_data)
    size = int(len(all_data) * 0.1)
    training_data, testing_data = all_data[size:], all_data[:size]
    print 'Data loaded, size: {}...'.format(len(all_data))

    layers = []
    layers.append({'type': 'input', 'out_sx': 1, 'out_sy': 1, 'out_depth': N})
    layers.append({'type': 'fc', 'num_neurons': 50, 'activation': 'sigmoid'})
    layers.append({'type': 'fc', 'num_neurons': 10, 'activation': 'sigmoid'})
    layers.append({'type': 'fc', 'num_neurons': 50, 'activation': 'sigmoid'})
    layers.append({'type': 'softmax', 'num_classes': N})

    print 'Layers made...'

    network = Net(layers)

    print 'Net made...'
    print network

    t = Trainer(network, {'method': 'adadelta', 'batch_size': 10, 'l2_decay': 0.0001}); 
開發者ID:benglard,項目名稱:ConvNetPy,代碼行數:26,代碼來源:next_word.py

示例11: train2

# 需要導入模塊: import net [as 別名]
# 或者: from net import Net [as 別名]
def train2():
    global training_data2, n2, t2

    layers = []
    layers.append({'type': 'input', 'out_sx': 28, 'out_sy': 28, 'out_depth': 1})
    layers.append({'type': 'fc', 'num_neurons': 100, 'activation': 'sigmoid'})
    layers.append({'type': 'softmax', 'num_classes': 10})
    print 'Layers made...'

    n2 = Net(layers)
    print 'Net made...'
    print n2

    t2 = Trainer(n2, {'method': 'adadelta', 'batch_size': 20, 'l2_decay': 0.001});
    print 'Trainer made...' 

    print 'In training of smaller net...'
    print 'k', 'time\t\t  ', 'loss\t  ', 'training accuracy'
    print '----------------------------------------------------'
    try:
        for x, y in training_data2: 
            stats = t2.train(x, y)
            print stats['k'], stats['time'], stats['loss'], stats['accuracy']
    except: #hit control-c or other
        return 
開發者ID:benglard,項目名稱:ConvNetPy,代碼行數:27,代碼來源:darkencoder.py

示例12: start

# 需要導入模塊: import net [as 別名]
# 或者: from net import Net [as 別名]
def start():
    global training_data, testing_data, n, t

    training_data = load_data()
    testing_data = load_data(False)

    print 'Data loaded...'

    layers = []
    layers.append({'type': 'input', 'out_sx': 1, 'out_sy': 1, 'out_depth': 10})
    layers.append({'type': 'fc', 'num_neurons': 100, 'activation': 'sigmoid'})
    layers.append({'type': 'regression', 'num_neurons': 28 * 28})
    print 'Layers made...'

    n = Net(layers)
    print 'Net made...'
    print n

    t = Trainer(n, {'method': 'sgd', 'batch_size': 20, 'l2_decay': 0.001});
    print 'Trainer made...'
    print t 
開發者ID:benglard,項目名稱:ConvNetPy,代碼行數:23,代碼來源:num2img.py

示例13: __init__

# 需要導入模塊: import net [as 別名]
# 或者: from net import Net [as 別名]
def __init__(self, worker_id, env, global_ep, args):
        self.name = 'worker_' + str(worker_id)
        self.env = env
        self.global_ep = global_ep
        self.args = args
        self.learning_rate = 1e-4
        self.gamma = 0.99
        self.trainer = tf.train.AdamOptimizer(self.learning_rate)

        # create local copy of AC network
        self.local_net = Net(self.env.state_dim,
                             self.env.action_dim,
                             scope=self.name,
                             trainer=self.trainer)

        self.update_local_op = self._update_local_params() 
開發者ID:borgwang,項目名稱:reinforce_py,代碼行數:18,代碼來源:worker.py

示例14: evaluate

# 需要導入模塊: import net [as 別名]
# 或者: from net import Net [as 別名]
def evaluate(args):
    if args.cuda:
        ctx = mx.gpu(0)
    else:
        ctx = mx.cpu(0)
    # images
    content_image = utils.tensor_load_rgbimage(args.content_image,ctx, size=args.content_size, keep_asp=True)
    style_image = utils.tensor_load_rgbimage(args.style_image, ctx, size=args.style_size)
    style_image = utils.preprocess_batch(style_image)
    # model
    style_model = net.Net(ngf=args.ngf)
    style_model.load_params(args.model, ctx=ctx)
    # forward
    style_model.set_target(style_image)
    output = style_model(content_image)
    utils.tensor_save_bgrimage(output[0], args.output_image, args.cuda) 
開發者ID:StacyYang,項目名稱:MXNet-Gluon-Style-Transfer,代碼行數:18,代碼來源:main.py

示例15: evaluate

# 需要導入模塊: import net [as 別名]
# 或者: from net import Net [as 別名]
def evaluate(args):
    if args.cuda:
        ctx = mx.gpu(0)
    else:
        ctx = mx.cpu(0)
    # images
    content_image = utils.tensor_load_rgbimage(args.content_image,ctx, size=args.content_size, keep_asp=True)
    style_image = utils.tensor_load_rgbimage(args.style_image, ctx, size=args.style_size)
    style_image = utils.preprocess_batch(style_image)
    # model
    style_model = net.Net(ngf=args.ngf)
    style_model.load_params(args.model, ctx=ctx)
    # forward
    style_model.setTarget(style_image)
    output = style_model(content_image)
    utils.tensor_save_bgrimage(output[0], args.output_image, args.cuda) 
開發者ID:mahyarnajibi,項目名稱:SNIPER-mxnet,代碼行數:18,代碼來源:main.py


注:本文中的net.Net方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。