コード例 #1
0
plot_confusion_matrix(conf, 1, "Closed form")

acc1 = np.ones(EPOCHS_NO) * acc

print("-------------------")

# ------------------------------------------------------------------------------
# ------ Gradient optimization of linear model

grad_model = LinearClassifier()

acc2 = np.zeros(EPOCHS_NO)

ep = 1
while ep <= EPOCHS_NO:
    grad_model.update_params(X_train, T_train, LEARNING_RATE)
    acc, conf = evaluate(grad_model, X_test, L_test)

    acc2[ep - 1] = acc

    if ep % REPORT_EVERY == 0:
        print("[Linear-grad] Epoch %4d; Accuracy on test set: %f" % (ep, acc))

    ep = ep + 1

print(conf)
plot_confusion_matrix(conf, 2, "Linear model - gradient")

print("-------------------")

# ------------------------------------------------------------------------------