In test_model() method, you use below dictionary to feed model:
feed_dict={self.input_R: self.test_R, self.input_mask_R: self.test_mask_R}
so you feed model with test_R to predict test ratings! Isn't it wrong?I believe the feed_dict must be as below:
feed_dict={self.input_R: self.train_R, self.input_mask_R: self.test_mask_R}
so the model won't see test_R before predicting it.