How to use the autokeras.AutoModel function in autokeras

To help you get started, we’ve selected a few autokeras examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github keras-team / autokeras / tests / test_auto_model.py View on Github external
def test_auto_model_basic(_, tmp_dir):
    x_train = np.random.rand(100, 32, 32, 3)
    y_train = np.random.rand(100, 1)

    auto_model = ak.AutoModel(ak.ImageInput(),
                              ak.RegressionHead(),
                              directory=tmp_dir,
                              max_trials=2)
    auto_model.fit(x_train, y_train, epochs=2, validation_split=0.2)
github keras-team / autokeras / examples / cifar10.py View on Github external
def io_api():
    (x_train, y_train), (x_test, y_test) = cifar10.load_data()
    clf = ak.AutoModel(ak.ImageInput(),
                       ak.ClassificationHead(),
                       seed=5,
                       max_trials=3)
    clf.fit(x_train, y_train, validation_split=0.2)
    return clf.evaluate(x_test, y_test)
github keras-team / autokeras / examples / imdb.py View on Github external
(x_train, y_train), (x_test, y_test) = tf.keras.datasets.imdb.load_data(
        num_words=max_features,
        index_from=3)
    x_train = tf.keras.preprocessing.sequence.pad_sequences(
        x_train, maxlen=max_words)
    x_test = tf.keras.preprocessing.sequence.pad_sequences(x_test, maxlen=max_words)
    print(x_train.dtype)
    print(x_train[:10])
    input_node = ak.Input()
    output_node = input_node
    output_node = ak.EmbeddingBlock(max_features=max_features)(output_node)
    output_node = ak.ConvBlock()(output_node)
    output_node = ak.SpatialReduction()(output_node)
    output_node = ak.DenseBlock()(output_node)
    output_node = ak.ClassificationHead()(output_node)
    clf = ak.AutoModel(input_node, output_node, seed=5, max_trials=3)
    clf.fit(x_train, y_train, validation_split=0.2)
    return clf.evaluate(x_test, y_test)
github keras-team / autokeras / examples / mnist.py View on Github external
def io_api():
    (x_train, y_train), (x_test, y_test) = mnist.load_data()
    clf = ak.AutoModel(ak.ImageInput(),
                       ak.ClassificationHead(),
                       seed=5,
                       max_trials=3)
    clf.fit(x_train, y_train, validation_split=0.2)
    return clf.evaluate(x_test, y_test)
github keras-team / autokeras / examples / cifar10.py View on Github external
def functional_api():
    (x_train, y_train), (x_test, y_test) = cifar10.load_data()
    input_node = ak.ImageInput()
    output_node = input_node
    output_node = ak.Normalization()(output_node)
    output_node = ak.ImageAugmentation()(output_node)
    output_node = ak.ResNetBlock(version='next')(output_node)
    output_node = ak.SpatialReduction()(output_node)
    output_node = ak.DenseBlock()(output_node)
    output_node = ak.ClassificationHead()(output_node)
    clf = ak.AutoModel(input_node, output_node, seed=5, max_trials=3)
    clf.fit(x_train, y_train, validation_split=0.2)
    return clf.evaluate(x_test, y_test)
github keras-team / autokeras / examples / io_api.py View on Github external
y_test = y_test[:data_slice]
x_train = x_train.astype(np.float64)
x_test = x_test.astype(np.float64)
print(x_train.dtype)
# x_image = np.reshape(x_train, (200, 28, 28, 1))
# x_test = np.reshape(x_test, (200, 28, 28, 1))
x_image = x_train.reshape(x_train.shape + (1,))
x_test = x_test.reshape(x_test.shape + (1,))
'''x_structured = np.random.rand(x_train.shape[0], 100)
y_regression = np.random.rand(x_train.shape[0], 1)'''
x_structured = np.random.rand(x_train.shape[0], 100)
y_regression = np.random.rand(x_train.shape[0], 1)
y_classification = y_classification.reshape(-1, 1)
# y_classification = np.reshape(y_classification, (-1, 1))
# Build model and train.
automodel = ak.AutoModel(
    inputs=[ak.ImageInput(),
            ak.StructuredDataInput()],
    outputs=[ak.RegressionHead(metrics=['mae']),
             ak.ClassificationHead(loss='categorical_crossentropy',
                                   metrics=['accuracy'])])
automodel.fit([x_image, x_structured],
              [y_regression, y_classification],
              validation_split=0.2)
github keras-team / autokeras / examples / mnist.py View on Github external
def functional_api():
    (x_train, y_train), (x_test, y_test) = mnist.load_data()
    input_node = ak.ImageInput()
    output_node = input_node
    output_node = ak.Normalization()(output_node)
    output_node = ak.ConvBlock()(output_node)
    output_node = ak.SpatialReduction()(output_node)
    output_node = ak.DenseBlock()(output_node)
    output_node = ak.ClassificationHead()(output_node)
    clf = ak.AutoModel(input_node, output_node, seed=5, max_trials=3)
    clf.fit(x_train, y_train, validation_split=0.2)
    return clf.evaluate(x_test, y_test)