windows anaconda python 3.7 安装 autokeras
注意1:autokeras 需要先安装pytorch,pytorch的安装参考这篇文章:windows anaconda python 3.7 安装 pytorch-gpu
注意2:autokeras 会帮你安装tensorflow的CPU版,如果你想使用tensorflow的GPU版,请参考这篇文章:windows anaconda python 3.7 安装keras-gpu tensorflow-gpu
autokeras 支持pip 安装:
pip install autokeras
但是pip的包不是最新的,很可能在安装过程中报错,推荐使用GitHub进行安装:
git clone https://github.com/keras-team/autokeras.git
cd autokeras
pip install .
测试代码:
from keras.datasets import mnist
from autokeras import ImageClassifier
from autokeras.constant import Constant
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=30 * 60)
clf.final_fit(x_train, y_train, x_test, y_test, retrain=True)
y = clf.evaluate(x_test, y_test)
print(y * 100)
注意:推荐使用命令行跑,使用spyder跑程序会报错
运行结果如下:
Using TensorFlow backend.
Better speed can be achieved with apex installed from https://www.github.com/nvidia/apex.
Saving Directory: C:\Users\peter\AppData\Local\Temp\autokeras_PIWS45
Preprocessing the images.
Preprocessing finished.
Initializing search.
Initialization finished.
+-------------------------------------------