Exemplo n.º 1
0
def create_model():
    if args.model == 'myVGG':
        model = myMethod.create_myVGG()
    else:
        model = myMethod.create_myModel()

    model.compile(optimizer='adam',
                  loss='categorical_crossentropy',
                  metrics=["accuracy"])

    load_path = args.load_path
    model.load_weights(load_path)
    model.summary()
    return model
Exemplo n.º 2
0
def singleGPU():
    if args.model == 'myVGG':
        model = myMethod.create_myVGG()
    else:
        model = myMethod.create_myModel()

    model.compile(optimizer='adam',
                  loss='categorical_crossentropy',
                  metrics=["accuracy"])
    model.summary()

    model.fit(train_data, epochs=TOTAL_EPOCHS, steps_per_epoch=TOTAL_TRAIN // BATCH_SIZE_TRAIN,
              callbacks=[tensorboard_callback, cp_callback],
              validation_data=public_test_data,
              validation_steps=TOTAL_TEST // BATCH_SIZE_TRAIN)
    model.evaluate(private_test_data, steps=TOTAL_TEST // BATCH_SIZE_TRAIN)
Exemplo n.º 3
0
def multiGPUs():
    GPUS = args.gpus
    strategy = tf.distribute.MirroredStrategy()

    with strategy.scope():
        if args.model == 'myVGG':
            model = myMethod.create_myVGG()
        else:
            model = myMethod.create_myModel()

        model.compile(optimizer='adam',
                      loss='categorical_crossentropy',
                      metrics=["accuracy"])

    model.fit(train_data, epochs=TOTAL_EPOCHS, steps_per_epoch=TOTAL_TRAIN // BATCH_SIZE_TRAIN // GPUS,
              callbacks=[tensorboard_callback, cp_callback],
              validation_data=public_test_data,
              validation_steps=TOTAL_TEST // BATCH_SIZE_TRAIN // GPUS)
    model.evaluate(private_test_data, steps=TOTAL_TEST // BATCH_SIZE_TRAIN // GPUS)
Exemplo n.º 4
0
private_test_data = private_test_data.map(myMethod.preprocess_DAtestdata)

# get standard result
correct_answer = np.loadtxt(test_private_path,
                            dtype=np.int,
                            delimiter=',',
                            skiprows=1,
                            usecols=(0),
                            encoding='utf-8')

# correct_answer = correct_answer.repeat(10)

if args.model == 'myVGG':
    model = myMethod.create_myVGG()
else:
    model = myMethod.create_myModel()

model.compile(optimizer='adam',
              loss='categorical_crossentropy',
              metrics=["accuracy"])


def get_acc_predict(load_path):
    model.load_weights(load_path)
    x = model.predict(private_test_data,
                      steps=TOTAL_TEST // BATCH_SIZE_TEST_DA)
    predict_result = np.zeros(shape=(3589, 7))
    for i in range(0, 3589):
        sum = np.zeros(shape=(1, 7))
        for j in range(0, 10):
            sum += x[10 * i + j]