stepEnd = stepStart + chunkSize if stepEnd < len(samples): yield i, samples[stepStart:stepEnd], labels[stepStart:stepEnd] i += 1 stepStart = stepEnd net = Network(train_batch_size=64, test_batch_size=500, pooling_scale=2) 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=16, activation='relu', pooling=False, name='conv1') net.add_conv(patch_size=3, in_depth=16, out_depth=16, 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,
net = Network(train_batch_size=128, test_batch_size=100, pooling_scale=2, dropout_rate=0.90, base_learning_rate=0.008, decay_rate=0.99) net.define_inputs( train_samples_shape=(128, 48, 48, 1), train_labels_shape=(128, 7), test_samples_shape=(100, 48, 48, 1), ) # net.add_conv(patch_size=3, in_depth=1, out_depth=32, activation='relu', pooling=True, name='conv1') net.add_conv(patch_size=3, in_depth=32, out_depth=64, activation='relu', pooling=True, name='conv2') net.add_conv(patch_size=3, in_depth=64, out_depth=64, activation='relu', pooling=False, name='conv3') net.add_conv(patch_size=3,
yield i, samples[stepStart:stepEnd], labels[stepStart:stepEnd] i += 1 stepStart = stepEnd 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)