Exemplo n.º 1
0
def run():
    x_train, y_train, x_test, y_test = load_images()
    #After loading train and evaluate classifier.
    clf = ImageClassifier(verbose=True, augment=False)
    clf.fit(x_train, y_train, time_limit=12 * 60 * 60)
    clf.final_fit(x_train, y_train, x_test, y_test, retrain=True)
    y = clf.evaluate(x_test, y_test)
    print(y * 100)
Exemplo n.º 2
0
def run():
    x_train, y_train, x_test, y_test = load_images()
    # After loading train and evaluate classifier.
    clf = ImageClassifier(verbose=True, augment=False)
    clf.fit(x_train, y_train, time_limit=12 * 60 * 60)
    clf.final_fit(x_train, y_train, x_test, y_test, retrain=True)
    y = clf.evaluate(x_test, y_test)
    print(y * 100)
Exemplo n.º 3
0
from keras.datasets import mnist
from autokeras import ImageClassifier
import tensorflow

if __name__ == '__main__':
    print(tensorflow.__version__)
    (x_train, y_train), (x_test, y_test) = mnist.load_data()
    x_train = x_train.reshape(x_train.shape + (1, ))
    x_test = x_test.reshape(x_test.shape + (1, ))
    clf = ImageClassifier(verbose=True, augment=False)
    clf.fit(x_train, y_train, time_limit=2 * 60)
    # clf.final_fit(x_train, y_train, x_test, y_test, retrain=True)
    y = clf.evaluate(x_test, y_test)
    print(y * 100)
Exemplo n.º 4
0
    plt.imshow(img,cmap='gray')
    plt.xticks([])
    plt.yticks([])
plt.show()
'''

if __name__ == '__main__':
    start = time.time()
    # 模型构建
    model = ImageClassifier(verbose=True)
    # 搜索网络模型
    model.fit(x_train, y_train, time_limit=1 * 60)
    # 验证最优模型
    model.final_fit(x_train, y_train, x_train, y_train, retrain=True)
    # 给出评估结果
    score = model.evaluate(x_train, y_train)
    # 识别结果
    y_predict = model.predict(x_train)
    # y_pred = np.argmax(y_predict,axis=1)
    # 精确度
    accuracy = accuracy_score(y_train, y_predict)
    # 打印出score与accuracy
    print('score:', score, '  accuracy:', accuracy)
    print(y_predict, y_train)
    model_dir = r'./trainer/new_auto_learn_Model.h5'
    model_img = r'./trainer/imgModel_ST.png'

    # 保存可视化模型
    # model.load_searcher().load_best_model().produce_keras_model().save(model_dir)
    pickle_to_file(model, model_dir)
    # 加载模型
Exemplo n.º 5
0
from autokeras import ImageClassifier
from tensorflow.keras.datasets import fashion_mnist as fm

(X_train, y_train), (X_test, y_test) = fm.load_data()
X_train = X_train.astype('float32') / 255.0
X_test = X_test.astype('float32') / 255.0

EPOCHS = 10

classifier = ImageClassifier(seed=9, max_trials=10)
classifier.fit(X_train, y_train, epochs=EPOCHS, verbose=2)
print(classifier.evaluate(X_test, y_test))
Exemplo n.º 6
0
from keras.datasets import mnist
from autokeras import ImageClassifier

if __name__ == '__main__':
    (x_train, y_train), (x_test, y_test) = mnist.load_data()
    x_train = x_train.reshape(x_train.shape + (1,))
    x_test = x_test.reshape(x_test.shape + (1,))

    clf = ImageClassifier(verbose=True, augment=False)
    clf.fit(x_train, y_train, time_limit=12 * 60 * 60)
    clf.final_fit(x_train, y_train, x_test, y_test, retrain=True)
    y = clf.evaluate(x_test, y_test)
    print(y * 100)
Exemplo n.º 7
0
testX = np.array(testX, dtype="float16") / 255.0
trainY = np.array(trainY)
testY = np.array(testY)
print("[INFO] data  matrix: {:.2f}MB".format(trainX.nbytes / (1024 * 1000.0)))
print("[INFO] data  shape : {}".format(trainX.shape))
print("[INFO] label shape : {}".format(trainY.shape))

# trainX = trainX.reshape(trainX.shape + (1,))
# testX = testX.reshape(testX.shape + (1,))

print(trainX.shape, trainY.shape, testX.shape, testY.shape)

clf = ImageClassifier(path='autokeras_output/', verbose=True, augment=False)
clf.fit(trainX, trainY, time_limit=12 * 60 * 60)
clf.final_fit(trainX, trainY, testX, testY, retrain=True)
y = clf.evaluate(testX, testY)

print(y * 100)

joblib.dump(clf, 'wfc3_autokeras_model.joblib.save')
'''
from keras.datasets import mnist
from autokeras import ImageClassifier

if __name__ == '__main__':
    (x_train, y_train), (x_test, y_test) = mnist.load_data()
    x_train = x_train.reshape(x_train.shape + (1,))
    x_test = x_test.reshape(x_test.shape + (1,))
	
    clf = ImageClassifier(verbose=True, augment=False)
    clf.fit(x_train, y_train, time_limit=12 * 60 * 60)
Exemplo n.º 8
0
    model.add(Dense(numclasses))
    model.add(Activation('softmax'))

    model.compile(loss='sparse_categorical_crossentropy', optimizer='adam', metrics=["accuracy"])
    #model.fit(X,y,batch_size=1,epochs=30, validation_split=0.1)
    return model
#rock_classifier()
"""



clf = ImageClassifier(verbose=True, augment=False)
clf.fit(X_train, y_train, time_limit=12 * 60 * 60)
clf.final_fit(X_train, y_train, X_test, y_test, retrain=True)

y = clf.evaluate(X_test, y_test)
print(y * 100)



#X.shape[0:]


# ### CV accuracy



"""
from keras.wrappers.scikit_learn import KerasClassifier
from keras.utils import np_utils
from sklearn.model_selection import cross_val_score