[Keras] get train accuracy, test accuracy

Keras에서 정확도를 측정하고 변수에 담는 방법이다.

 

model.compile(loss= ~, optimizer= ~, metrics=['accuracy'])
result = model.fit(X, y, ~~~, validation_split=0.3, validation_data=(testX, testY), shuffle=True)

print(result.history['acc']) # 0.9987

 

참고

result.history = {
   'acc' : [0.9987],
   'loss': [0.0478],
   'val_acc': [0.9543],
   'val_loss': [0.0498],

   ...
}

[Jupyter] ModuleNotFoundError: No module named ‘tensorflow’

ModuleNotFoundError Traceback (most recent call last)
<ipython-input-3-c546be358acf> in <module>() ----> 
    1 import tensorflow as tf
    2 import numpy as np
    3 import matplotlib.pyplot as plt
    4 from tensorflow.examples.tutorials.mnist import input_data
    5 import os

ModuleNotFoundError: No module named 'tensorflow'

 

 

conda로 설치한 경우만

conda install jupyter notebook
jupyter notebook

 

그래도 못찾으면

source activate tensorflow
jupyter notebook