Exemplo n.º 1
0
# Generate inception features
img_side = 299
num_channels = 3
num_train_ex_per_class = 900
num_test_ex_per_class = 300
batch_size = 100

tf.reset_default_graph()
full_model_name = '%s_inception' % dataset_name
full_model = BinaryInceptionModel(img_side=img_side,
                                  num_channels=num_channels,
                                  weight_decay=weight_decay,
                                  num_classes=num_classes,
                                  batch_size=batch_size,
                                  data_sets=image_data_sets,
                                  initial_learning_rate=initial_learning_rate,
                                  keep_probs=keep_probs,
                                  decay_epochs=decay_epochs,
                                  mini_batch=True,
                                  train_dir='output',
                                  log_dir='log',
                                  model_name=full_model_name)

train_inception_features_val = generate_inception_features(
    full_model,
    image_data_sets.train.x,
    image_data_sets.train.labels,
    batch_size=batch_size)
test_inception_features_val = generate_inception_features(
    full_model,
    image_data_sets.test.x,
Exemplo n.º 2
0
# dataset_name = 'dogfish_orig_and_koda'
# data_sets = load_dogfish_with_orig_and_koda()

full_graph = tf.Graph()
top_graph = tf.Graph()

print('*** Full:')
with full_graph.as_default():
    full_model_name = '%s_inception_wd-%s' % (dataset_name, weight_decay)
    full_model = BinaryInceptionModel(
        img_side=img_side,
        num_channels=num_channels,
        weight_decay=weight_decay,
        num_classes=num_classes,
        batch_size=batch_size,
        data_sets=data_sets,
        initial_learning_rate=initial_learning_rate,
        keep_probs=keep_probs,
        decay_epochs=decay_epochs,
        mini_batch=True,
        train_dir='output',
        log_dir='log',
        model_name=full_model_name)

    for data_set, label in [(data_sets.train, 'train'),
                            (data_sets.test, 'test')]:

        inception_features_path = 'output/%s_inception_features_new_%s.npz' % (
            dataset_name, label)
        if not os.path.exists(inception_features_path):

            print('Inception features do not exist. Generating %s...' % label)