コード例 #1
0
ファイル: load.py プロジェクト: zerocurve/autokeras
def load_images():
    x_train, y_train = load_image_dataset(csv_file_path="train/label.csv",
                                          images_path="train")
    print(x_train.shape)
    print(y_train.shape)

    x_test, y_test = load_image_dataset(csv_file_path="test/label.csv",
                                        images_path="test")
    print(x_test.shape)
    print(y_test.shape)
    return x_train, y_train, x_test, y_test
コード例 #2
0
def train_model():

    clf = ak.ImageClassifier()
    train_data, train_labels = load_image_dataset(
        csv_file_path=train_data_dir + "/label.csv",
        images_path=train_data_dir)
    validation_data, validation_labels = load_image_dataset(
        csv_file_path=validation_data_dir + "/label.csv",
        images_path=validation_data_dir)
    clf.fit(train_data, train_labels)
    clf.final_fit(train_data,
                  train_labels,
                  validation_data,
                  validation_labels,
                  retrain=True)
    y = clf.evaluate(validation_data, validation_labels)
    print("auto CNN classifier accuracy: %f" % y)
    clf.load_searcher().load_best_model().produce_keras_model().save(
        'shallowCNN_model.h5')
# (Version 0.2.13 as of 9/8/18)

from autokeras.image_supervised import ImageClassifier, load_image_dataset

train_path = 'datasets/dogsCats/dogCat128rgb_train'
train_labels = 'datasets/dogsCats/dogsCats_train.csv'

validation_path = 'datasets/dogsCats/dogCat128rgb_val'
validation_labels = 'datasets/dogsCats/dogsCats_val.csv'

from os import listdir
from os.path import isfile, join
files = [f for f in listdir(train_path) if isfile(join(train_path, f))]
print(files)

x_train, y_train = load_image_dataset(csv_file_path=train_labels,
                                      images_path=train_path)
print(x_train.shape)
print(y_train.shape)

x_val, y_val = load_image_dataset(csv_file_path=validation_labels,
                                  images_path=validation_path)

print(x_val.shape)
print(y_val.shape)

# Searching for the Best Model
clf = ImageClassifier(verbose=True,
                      searcher_args={'trainer_args': {
                          'max_iter_num': 25
                      }})
clf.fit(x_train, y_train,
コード例 #4
0
                    elif action_value_list[2].replace('\t', '') == 'false':
                        rule_value_list.append(0.0)
                    else:
                        sys.exit("Invalid rule!!")

                rule_list.append(rule_value_list)

            line = fp.readline()

    my_file = Path(output_keras_mode)
    if agent_skip_autokeras is True and my_file.is_file() is True:
        print('Skip running AutoKeras ...\n')
    else:
        if test_csv_file_path is not None and test_images_path is not None:
            x_train, y_train = load_image_dataset(
                csv_file_path=train_csv_file_path,
                images_path=train_images_path)
        else:
            sys.exit("No train data input!!")

        if test_csv_file_path is not None and test_images_path is not None:
            x_test, y_test = load_image_dataset(
                csv_file_path=test_csv_file_path, images_path=test_images_path)
            do_evaluate = True
        else:
            do_evaluate = False

        if agent_percept == 'image' and agent_func_interpert_input == 'autokeras':
            clf = ImageClassifier(verbose=True)
            clf.fit(x_train, y_train, time_limit=autokeras_timeout)
            clf.final_fit(x_train, y_train, x_test, y_test, retrain=True)
コード例 #5
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 27 16:46:35 2018

@author: Mohamed Laradji
"""

from autokeras.image_supervised import ImageClassifier, load_image_dataset

x_train, y_train = load_image_dataset(csv_file_path="data/train/labels.csv",
                                      images_path="data/train")

x_val, y_val = load_image_dataset(csv_file_path="data/val/labels.csv",
                                  images_path="data/val")

if __name__ == '__main__':

    clf = ImageClassifier(verbose=True)
    clf.fit(x_train, y_train,
            time_limit=12 * 60 * 60)  # Currently results in errors.
    clf.final_fit(x_train, y_train, x_val, y_val, retrain=True)
    y = clf.evaluate(x_val, y_val)
コード例 #6
0
ファイル: ivv-train.py プロジェクト: seanlee10/gym
    # (x_train, y_train), (x_test, y_test) = mnist.load_data()

    # print(x_train.shape, x_train[0].shape, x_train.reshape(x_train.shape + (1,)).shape)

    NB_EPOCH = 200
    BATCH_SIZE = 128
    VERBOSE = 1
    NB_CLASSES = 3
    OPTIMIZER = RMSprop()  # optimizer, explainedin this chapter
    N_HIDDEN = 128
    VALIDATION_SPLIT = 0.2  # how much TRAIN is reserved for VALIDATION
    DROPOUT = 0.3

    RESHAPED = 7575

    x_train, y_train = load_image_dataset(csv_file_path="train.csv",
                                          images_path="images")
    # print('x_train', x_train[0].shape, type(x_train))

    # x_train = x_train.reshape(x_train.shape[0], 396, 532, 4)

    print('x_train', x_train.shape)
    # print('y_train', y_train.shape)

    x_test, y_test = load_image_dataset(csv_file_path="test.csv",
                                        images_path="images")
    # print(x_test.shape)
    # print(y_test.shape)

    x_train = x_train.reshape(3077, RESHAPED)
    x_test = x_test.reshape(1025, RESHAPED)