Esempio n. 1
0
(x_train, t_train), (x_test, t_test) = load_mnist(normalize=True,
                                                  one_hot_label=True)

# settings of the neuralnet
form = [784, 50, 10]
activ_func = ['relu', 'softmax']
loss_func = 'cross_entropy'

# settings of the batch prediction
test_size = x_test.shape[0]

net = NeuralNet(form, activ_func, loss_func)

# settings of the weights parameter
f = open('weights.pkl', 'rb')
net.W = pickle.load(f)
f.close()


def check_prediction():
    i = np.random.randint(0, len(x_test))
    img = x_test[i]
    label = np.argmax(t_test[i])
    z = np.argmax(net.forprop(img))
    img_show(img.reshape(28, 28) * 255)
    print('label : {}'.format(label))
    print('prediction : {}'.format(z))


def prediction_accuracy(it_num=100, batch_size=100):
    acc = 0