---
# System prepended metadata

title: AutoKeras 建置環境 (CPU Version)
tags: [Built Environment]

---

# AutoKeras 建置環境 (CPU Version) 

:::info
AutoKeras 1.0.0a
運行正常，無法給定自己的訓練集。
:::

0. 指令: conda create --name myenv python=3.6   
(建設新環境)

1. install keras by anaconda  (include tensorflow)

2. 指令:conda install pytorch=0.4.1 cuda90 -c pytorch 
    (Because autokeras 1.0.0a need )
3. 指令:conda install git
4. 指令:pip install git+git://github.com/keras-team/autokeras@master#egg=autokeras
    (AutoKeras:  https://autokeras.com/)
    
5. 指令:pip install --upgrade tensorflow 
  (Because tensorflow have tf.keras, need to update tensorflow>1.1.0)
  (or  pip install --upgrade --force-reinstall tensorflow)

```python=
#Test if use gpu or not by TF2.0
import tensorflow as tf
sess=tf.compat.v1.Session(config=tf.compat.v1.ConfigProto(log_device_placement=True))
```


6. Your CPU supports instructions that this TensorFlow binary was not compiled to use.(CPU指令集不支持tensorflow指令的優化，使用cpu訓練效果不佳)
(https://www.itread01.com/content/1515422292.html)

```python=
#shield the warrning
import os
os.environ[‘TF_CPP_MIN_LOG_LEVEL‘] = ‘2‘ 
```


7. TF2.0與先前版本，指令名稱有差異，以下連結可查閱指令
https://docs.google.com/spreadsheets/d/1FLFJLzg7WNP6JHODX5q8BDgptKafq_slHpnHVbJIteQ/edit#gid=0


8. AutoKeras Example
    -  https://gist.github.com/OlegJakushkin/bf5e09da8813fec8bb3435b8fce140e0
    -  Test Example
    
<ul>



```python=
import os 
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'


import autokeras as ak
from keras.datasets import mnist

# Prepare the data.
(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,))

# Search and train the classifier.
clf = ak.ImageClassifier(max_trials=100)
clf.fit(x_train, y_train,validation_split=0.2)
y = clf.predict(x_test, y_test)
```
</ul>

9. 指令:conda install  ipywidgets
(for jupyter)
 AutoKeras 0.4.0 (CPU Version)
 
 ###### tags: `Built Environment`