コード例 #1
0
def create_model(**kwargs):
    model = Model(**kwargs)
    model.add(number_of_neurons=6)
    model.add(number_of_neurons=3)
    model.add(number_of_neurons=1)

    return model
コード例 #2
0
ファイル: train_tf_conv.py プロジェクト: Pduhard/protodeep
        "optimizer": parse_option_value("-o", dflt=None),
        "epoch": parse_option_value("-e", dflt="100")
        }
    if check_option(options) is False:
        usage()
    return options


if __name__ == "__main__":
    options = parse_options()
    # print(options)
    # dataset = Dataset("../data_training.csv")
    # dataset_test = Dataset("../data_test.csv")
    dataset = Dataset(None, 0.2)
    model = Model()
    model.add(Dense(64, activation="relu"))
    model.add(Dense(32, activation="relu"))
    model.add(Dense(2, activation="softmax"))
    # model.add(64, activation="relu")
    # model.add(32, activation="relu")
    # model.add(2, activation="softmax")
    model.compile(30, metrics=["accuracy"], optimizer="Adam")
    print(dataset.features.shape)
    print(dataset.test_features.shape)
    # print(dataset.features.shape)
    # print(numpy.min(model.weights[0]))
    history = model.fit(
        features=dataset.features,
        targets=dataset.targets,
        epochs=500,
        batch_size=32,
コード例 #3
0
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

import numpy as np
from layers.activation import Activation
from layers.dense import Dense
from model.model import Model

X_train = np.array([[[0, 0]], [[0, 1]], [[1, 0]], [[1, 1]]])
y_train = np.array([
    [[0]],  # F
    [[1]],  # M
    [[1]],  # M
    [[0]]  # F
])

model = Model()

model.add(Dense(2, 2))
model.add(Activation('tanh'))
model.add(Dense(2, 2))
model.add(Activation('tanh'))
model.add(Activation('softmax'))

model.fit(X_train, y_train, epochs=1000, learning_rate=0.1)

frank = np.array(X_train)  # 155 pounts, 68 inches

pred = model.predict(frank)

print(np.array(pred))