当前位置: 首页>>代码示例>>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;未经允许,请勿转载。