for num in range(Epoch):
        batch_xs = rbm1.passThrough(MA_data)
        new_w, new_hb, new_vb, ReconErr = rbm2.train(batch_xs)
        print("Epoch: {}, Reconstruction Error: {}".format(num, ReconErr))

    for num in range(Epoch):
        batch_xs = rbm1.passThrough(MA_data)
        batch_xs1 = rbm2.passThrough(batch_xs)
        new_w, new_hb, new_vb, ReconErr = rbm3.train(batch_xs1)
        print("Epoch: {}, Reconstruction Error: {}".format(num, ReconErr))

    temp1 = rbm1.passThrough(MA_data)
    temp2 = rbm2.passThrough(temp1)
    temp3 = rbm3.inference(temp2)
    temp4 = rbm2.passBack(temp3)
    REC = rbm1.passBack(temp4)

    print(np.shape(REC))
    RMSE = np.sqrt(
        np.mean(np.square(MA_data - REC), axis=0) /
        float(np.shape(MA_data)[0]))
    print("Shape of RMSE: {}, RMSE {}".format(np.shape(RMSE), RMSE))
    ReconRank = rankdata(RMSE)

    with open('FeatureRank.csv', 'wb') as csvfile:
        spamwriter = csv.writer(csvfile,
                                delimiter=',',
                                quotechar='|',
                                quoting=csv.QUOTE_MINIMAL)
        spamwriter.writerow(["Feature Number", "ReconRank", "RMSE"])