train_sz = X.shape[0]
train_batch_sz = X.shape[0]
train_batch_n = train_sz / train_batch_sz

train_cost = np.zeros((2000,))
train_err  = np.zeros((2000,))
test_cost  = np.zeros((2000,))
test_err   = np.zeros((2000,))

for epoch in range(2000):


    for batch_idx in range(train_batch_n):

        batch_X, batch_H, batch_C, batch_m, batch_y = prepare_batch(X=X, H=H, C=C, m=M, y=y, batch_idx=batch_idx, batch_sz=train_batch_sz)

        #v1 = f_watch(batch_X, batch_H, batch_C, batch_m, batch_y)

        #cost = f_grad_shared(batch_X, batch_H, batch_C, batch_m, batch_y)
        f_update()


    train_cost[epoch] = f_grad_shared(X, H, C, M, y)
    train_err[epoch] = f_pred_err(X, H, C, M, y)
    test_cost[epoch] = f_grad_shared(X1, H1, C1, M1, y1)
    test_err[epoch] = f_pred_err(X1, H1, C1, M1, y1)

    output_pred = f_pred_gross(X1, H1, C1, M1)
    output_pred[M1==0] = -1
train_batch_sz = 37
train_batch_n = train_sz / train_batch_sz

train_cost = np.zeros((2000, ))
train_err = np.zeros((2000, ))
test_cost = np.zeros((2000, ))
test_err = np.zeros((2000, ))

for epoch in range(2000):

    for batch_idx in range(train_batch_n):

        batch_X, batch_H, batch_C, batch_m, batch_y = prepare_batch(
            X=X,
            H=H,
            C=C,
            m=M,
            y=y,
            batch_idx=batch_idx,
            batch_sz=train_batch_sz)

        #v1 = f_watch(batch_X, batch_H, batch_C, batch_m, batch_y)

        cost = f_grad_shared(batch_X, batch_H, batch_C, batch_m, batch_y)
        f_update()

    train_cost[epoch] = f_grad_shared(X, H, C, M, y)
    train_err[epoch] = f_pred_err(X, H, C, M, y)
    test_cost[epoch] = f_grad_shared(X1, H1, C1, M1, y1)
    test_err[epoch] = f_pred_err(X1, H1, C1, M1, y1)

    output_pred = f_pred_gross(X1, H1, C1, M1)