Deep learning has been successfully applied to a variety of tasks. However, a lot of unnecessary information for the task is included in the training data and it is difficult to automatically remove such unnecessary information in the trained model. For example, it is necessary to ignore the variations of the patients in the measured data for medical diagnosis. To address this problem, we propose a method that applies a module called Gradient Reversal Layer to train the model by removing unnecessary information and extracting only the relevant information for the target task. In this study, we conducted three experiments to demonstrate the effectiveness of the proposed method. The first one is to classify clothing images with unnecessary shift information and the second one is to identify the person from the face images with unnecessary facial expressions. Finally, the third one is to estimate the presence of diseases in medical data with unnecessary variations due to the differences of the patients. In all experiments, we obtained results where the unwanted information in the features was reduced, thereby improving the desired classification performance.