Your model is most likely overfitting 1. That is, it is essentially memorizing the input-output relations in the training data, rather than learning the “shape” of the training data. So it does very well on the training data, but does badly on the test data in comparison.
You could try various regularization 1 methods to try to get around overfitting. Some common regularization methods are adding Dropout layers to your model, or adding a weight decay parameter to y our optimizer.