Ejemplo n.º 1
0
Archivo: main.py Proyecto: oywc410/MYPG
                 activation='relu',
                 pooling=True,
                 name='conv2')
    net.add_conv(patch_size=3,
                 in_depth=16,
                 out_depth=16,
                 activation='relu',
                 pooling=False,
                 name='conv3')
    net.add_conv(patch_size=3,
                 in_depth=16,
                 out_depth=16,
                 activation='relu',
                 pooling=True,
                 name='conv4')

    # 4 = 两次 pooling, 每一次缩小为 1/2
    # 16 = conv4 out_depth
    net.add_fc(in_num_nodes=(image_size // 4) * (image_size // 4) * 16,
               out_num_nodes=16,
               activation='relu',
               name='fc1')
    net.add_fc(in_num_nodes=16, out_num_nodes=10, activation=None, name='fc2')

    net.define_model()
    net.run(get_chunk, train_samples, train_labels, test_samples, test_labels)

else:
    raise Exception(
        'main.py: Should Not Be Imported!!! Must Run by "python main.py"')
Ejemplo n.º 2
0
    net.add_conv(patch_size=3,
                 in_depth=64,
                 out_depth=128,
                 activation='relu',
                 pooling=False,
                 name='conv4')
    net.add_conv(patch_size=3,
                 in_depth=128,
                 out_depth=128,
                 activation='relu',
                 pooling=True,
                 name='conv5')
    # 4 = 两次 pooling, 每一次缩小为 1/2
    # 64 = conv4 out_depth
    net.add_fc(in_num_nodes=(48 // 8) * (48 // 8) * 128,
               out_num_nodes=1024,
               activation='relu',
               name='fc1')
    net.add_fc(in_num_nodes=1024,
               out_num_nodes=256,
               activation='relu',
               name='fc2')
    net.add_fc(in_num_nodes=256, out_num_nodes=7, activation=None, name='fc3')

    net.define_model()
    #net.run(train_samples, train_labels, test_samples, test_labels, train_data_iterator=train_data_iterator, iteration_steps=3000, test_data_iterator=test_data_iterator)
    net.train(train_samples,
              train_labels,
              data_iterator=train_data_iterator,
              iteration_steps=3000)
    net.test(test_samples, test_labels, data_iterator=test_data_iterator)
    #net.test(val_samples, val_labels, data_iterator=test_data_iterator)
    net = Network(
        train_batch_size=64, test_batch_size=500, pooling_scale=2,
        dropout_rate=0.9,
        base_learning_rate=0.001, decay_rate=0.99)
    net.define_inputs(
        train_samples_shape=(64, image_size, image_size, num_channels),
        train_labels_shape=(64, num_labels),
        test_samples_shape=(500, image_size, image_size, num_channels),
    )
    #
    net.add_conv(patch_size=3, in_depth=num_channels, out_depth=32, activation='relu', pooling=False, name='conv1')
    net.add_conv(patch_size=3, in_depth=32, out_depth=32, activation='relu', pooling=True, name='conv2')
    net.add_conv(patch_size=3, in_depth=32, out_depth=32, activation='relu', pooling=False, name='conv3')
    net.add_conv(patch_size=3, in_depth=32, out_depth=32, activation='relu', pooling=True, name='conv4')

    # 4 = 两次 pooling, 每一次缩小为 1/2
    # 32 = conv4 out_depth
    net.add_fc(in_num_nodes=(image_size // 4) * (image_size // 4) * 32, out_num_nodes=128, activation='relu',
               name='fc1')
    net.add_fc(in_num_nodes=128, out_num_nodes=10, activation=None, name='fc2')

    net.define_model()
    # net.run(train_samples, train_labels, test_samples, test_labels, train_data_iterator=train_data_iterator,
    #         iteration_steps=3000, test_data_iterator=test_data_iterator)
    net.train(train_samples, train_labels, data_iterator=train_data_iterator, iteration_steps=2000)
    net.test(test_samples, test_labels, data_iterator=test_data_iterator)

else:
    raise Exception('main.py: Should Not Be Imported!!! Must Run by "python main.py"')