2018年8月8日 星期三

My study note of MNIST and Keras

1. To copy source code and how to use keras as below link.
https://fgc.stpi.narl.org.tw/activity/videoDetail/4b1141305d9cd231015d9d03cfd10027

2. To save training model as below.
    model.save("keras_1_save.h5") #save model
    model.save_weights('keras_1_save_weights.h5')

3. To load training model as below.
    model = load_model('keras_1_save.h5')

4. To online your AI after Machine Learning by predict.

def myPredict(data):
#open image by PIL https://stackoverflow.com/questions/7762948/how-to-convert-an-rgb-image-to-numpy-array
    data=np.reshape(data,(28*28))
    data = np.expand_dims(data, axis=0)    
    result=model.predict(data, batch_size=None, verbose=0, steps=None)
    print("result: ",result)
    print("data:",data)
    print("shape: ",data.shape)
    return data
 myPredict(x_train[1])

5. Summary.
    Due to the MNIST data is difference with my create data by paint.exe in windows. so it still need some of transfer to match MNIST format, because I do not have a lot train/test data.


-------my created data start -----------------------------------------------------------------------
img: <PIL.Image.Image image mode=L size=28x28 at 0x9F73908>
data: [[[1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.]]
[[1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.]]
[[1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.]]
[[1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.]]
[[1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.]]
[[1.][1.][1.][1.][1.][1.][1.][1.][0.][0.][0.][0.][0.][0.][0.][0.][0.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.]]
[[1.][1.][1.][1.][1.][1.][1.][0.][0.][1.][1.][1.][1.][1.][1.][1.][1.][0.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.]]
[[1.][1.][1.][1.][1.][1.][1.][0.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][0.][1.][1.][1.][1.][1.][1.][1.][1.][1.]]
[[1.][1.][1.][1.][1.][1.][0.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][0.][0.][1.][1.][1.][1.][1.][1.][1.][1.]]
[[1.][1.][1.][1.][1.][1.][0.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][0.][0.][1.][1.][1.][1.][1.][1.][1.][1.]]
[[1.][1.][1.][1.][1.][1.][0.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][0.][1.][1.][1.][1.][1.][1.][1.][1.]]
[[1.][1.][1.][1.][1.][1.][0.][0.][0.][1.][1.][1.][1.][1.][1.][1.][1.][1.][0.][0.][1.][1.][1.][1.][1.][1.][1.][1.]]
[[1.][1.][1.][1.][1.][1.][1.][1.][1.][0.][0.][0.][0.][0.][0.][0.][0.][0.][0.][0.][1.][1.][1.][1.][1.][1.][1.][1.]]
[[1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][0.][1.][1.][1.][1.][1.][1.][1.][1.]]
[[1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][0.][1.][1.][1.][1.][1.][1.][1.][1.]]
[[1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][0.][1.][1.][1.][1.][1.][1.][1.][1.]]
[[1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][0.][1.][1.][1.][1.][1.][1.][1.][1.]]
[[1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][0.][1.][1.][1.][1.][1.][1.][1.][1.]]
[[1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][0.][1.][1.][1.][1.][1.][1.][1.][1.]]
[[1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][0.][1.][1.][1.][1.][1.][1.][1.][1.][1.]]
[[1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][0.][1.][1.][1.][1.][1.][1.][1.][1.][1.]]
[[1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][0.][1.][1.][1.][1.][1.][1.][1.][1.][1.]]
[[1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][0.][1.][1.][1.][1.][1.][1.][1.][1.][1.]]
[[1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][0.][0.][1.][1.][1.][1.][1.][1.][1.][1.][1.]]
[[1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.]]
[[1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.]]
[[1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.]]
[[1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.][1.]]]
[[1.5385496e-05 1.9843709e-08 9.8800381e-09 2.5987378e-03 2.1317775e-109.0811986e-01 8.7126344e-02 2.9842662e-09 2.1397399e-03 1.7077168e-08]]
-------my created data end -----------------------------------------------------------------------




2018年5月17日 星期四

Tensorflow and CUDA install conditions



Tensorflow 1.8 + Cuda capability is 3.0
    1. Install CUDA, patch and cudnn
        cuda_9.0.176_win10_network ( custom install CUDA only, if install get failed)
        cuda_9.0.176.1_windows
        cuda_9.0.176.2_windows
        cudnn-9.0-windows10-x64-v7.1
            unzip to relate cuda folder

    2. CUDA for Python (Install for anaconda)
        conda update conda
        conda install numba
        conda install cudatoolkit

    3. Check CUDA version
        nvcc -V

Geforce 525M is CUDA 2.1