def test_bayesian_binary_mnist(self): # Create a astroNN neural network instance and set the basic parameter net = MNIST_BCNN() net.task = 'binary_classification' net.callbacks = ErrorOnNaN() net.max_epochs = 1 net.train(x_train, y_train) pred, pred_err = net.test(x_test) test_num = y_test.shape[0] net.save('mnist_binary_bcnn_test') net_reloaded = load_folder("mnist_binary_bcnn_test") net_reloaded.mc_num = 3 prediction_loaded, prediction_loaded_err = net_reloaded.test(x_test)
def test_bayesian_binary_mnist(self): # Create a astroNN neural network instance and set the basic parameter net = MNIST_BCNN() net.task = 'binary_classification' net.callbacks = ErrorOnNaN() net.max_epochs = 1 # Just use 1 epochs for quick result # Train the neural network net.train(self.x_train[:200], self.y_train[:200]) net.save('mnist_binary_bcnn_test') net_reloaded = load_folder("mnist_binary_bcnn_test") net_reloaded.mc_num = 3 # prevent memory issue on Tavis CI prediction_loaded = net_reloaded.test(self.x_test[:200])
def test_bayesian_binary_mnist(self): (x_train, y_train), (x_test, y_test) = mnist.load_data() y_train = utils.to_categorical(y_train, 10) y_train = y_train.astype(np.float32) x_train = x_train.astype(np.float32) x_test = x_test.astype(np.float32) # Create a astroNN neural network instance and set the basic parameter net = MNIST_BCNN() net.task = 'binary_classification' net.callbacks = ErrorOnNaN() net.max_epochs = 1 # Just use 5 epochs for quick result # Trian the nerual network net.train(x_train[:200], y_train[:200]) net.save('mnist_binary_bcnn_test') net_reloaded = load_folder("mnist_binary_bcnn_test") net_reloaded.mc_num = 3 # prevent memory issue on Tavis CI prediction_loaded = net_reloaded.test(x_test[:200])
def test_bayesian_mnist(self): from astroNN.models import MNIST_BCNN import pylab as plt (x_train, y_train), (x_test, y_test) = mnist.load_data() y_train = utils.to_categorical(y_train, 10) # To convert to desirable type y_train = y_train.astype(np.float32) x_train = x_train.astype(np.float32) x_test = x_test.astype(np.float32) # Create a astroNN neural network instance and set the basic parameter net = MNIST_BCNN() net.task = 'classification' net.callbacks = ErrorOnNaN() net.max_epochs = 1 # Just use 5 epochs for quick result # Trian the nerual network net.train(x_train[:200], y_train[:200]) plt.close() # Travis-CI memory error?? # net.plot_model() # disable due to memory issue on Travis CI net.save('mnist_bcnn_test') net.plot_dense_stats() net.evaluate(x_train[:10], y_train[:10]) net_reloaded = load_folder("mnist_bcnn_test") net_reloaded.mc_num = 3 # prevent memory issue on Tavis CI prediction_loaded = net_reloaded.test(x_test[:200]) net_reloaded.folder_name = None # set to None so it can be saved net_reloaded.save() load_folder( net_reloaded.folder_name) # ignore pycharm warning, its not None
def test_bayesian_mnist(self): import pylab as plt # Create a astroNN neural network instance and set the basic parameter net = MNIST_BCNN() net.task = 'classification' net.callbacks = ErrorOnNaN() net.max_epochs = 1 # Train the neural network net.train(x_train, y_train) net.save('mnist_bcnn_test') net.plot_dense_stats() plt.close() # Travis-CI memory error?? net.evaluate(x_test, utils.to_categorical(y_test, 10)) pred, pred_err = net.test(x_test) test_num = y_test.shape[0] assert (np.sum(pred == y_test)) / test_num > 0.9 # assert accuracy net_reloaded = load_folder("mnist_bcnn_test") net_reloaded.mc_num = 3 # prevent memory issue on Tavis CI prediction_loaded = net_reloaded.test(x_test[:200]) net_reloaded.folder_name = None # set to None so it can be saved net_reloaded.save() load_folder(net_reloaded.folder_name) # ignore pycharm warning, its not None