Solved by anup1912 in post #2 
              
              
                I found out the problem. This error was caused because the my weights had a different length than the number of samples in the dataset. So only 1/3rd of them were actually fetched.