return W1, b1, W2, b2


def calc_class(X):
    y = fcann2_classify(X, W1, b1, W2, b2)
    return np.argmax(y, axis=1) * np.max(y, axis=1)


if __name__ == "__main__":
    np.random.seed(100)
    # get the training dataset
    X, Y_ = data.sample_gmm_2d(6, 2, 10)

    # train the model
    W1, b1, W2, b2 = fcann2_train(X, data.class_to_onehot(Y_), 6)
    # evaluate the model on the training dataset
    probs = fcann2_classify(X, W1, b1, W2, b2)
    Y = np.argmax(probs, axis=1)

    # report performance
    accuracy, recall, precision = data.eval_perf_multi(Y, Y_)
    AP = data.eval_AP(Y_)
    print(accuracy, recall, precision, AP)

    # graph the decision surface
    rect = (np.min(X, axis=0), np.max(X, axis=0))
    data.graph_surface(calc_class, rect, offset=0.5)

    # graph the data points
    data.graph_data(X, Y_, Y, special=[])
        return self.session.run(self.probs, feed_dict={self.X: X})


def calc_class(X):
    y = tflr.eval(X)
    return np.argmax(y, axis=1) * np.max(y, axis=1)


if __name__ == "__main__":
    # inicijaliziraj generatore slučajnih brojeva
    np.random.seed(100)
    tf.set_random_seed(100)

    # instanciraj podatke X i labele Yoh_
    X, Y_ = data.sample_gmm_2d(6, 2, 10)
    Yoh_ = data.class_to_onehot(Y_)

    # izgradi graf:
    tflr = TFLogreg(X.shape[1], Yoh_.shape[1], 0.06, 1)

    # nauči parametre:
    tflr.train(X, Yoh_, 1000)

    # dohvati vjerojatnosti na skupu za učenje
    probs = tflr.eval(X)
    Y = np.argmax(probs, axis=1)

    # ispiši performansu (preciznost i odziv po razredima)
    accuracy, recall, precision = data.eval_perf_multi(Y, Y_)
    AP = data.eval_AP(Y_)
    print(accuracy, recall, precision, AP)
                                      (2 * np.linalg.norm(w))) * 2 * w  # D x 1
        grad_b = (1 / N) * np.sum(dL_dscores)  # 1 x 1

        # poboljšani parametri
        w += -param_delta * grad_w
        b += -param_delta * grad_b

    return w, b


if __name__ == "__main__":
    np.random.seed(100)
    # get the training dataset
    X, Y_ = data.sample_gauss(2, 100)
    # train the model
    w, b = binlogreg_train(X, data.class_to_onehot(Y_))
    # evaluate the model on the training dataset
    probs = binlogreg_classify(X, w, b)
    Y = probs > 0.5

    # report performance
    accuracy, recall, precision = data.eval_perf_binary(Y[:, -1], Y_)
    AP = data.eval_AP(Y_)
    print(accuracy, recall, precision, AP)

    # graph the decision surface
    rect = (np.min(X, axis=0), np.max(X, axis=0))
    data.graph_surface(lambda x: binlogreg_classify(x, w, b), rect, offset=0.5)

    # graph the data points
    data.graph_data(X, Y_, Y[:, -1], special=[])