Assuming the codes are correct in train and evaluate I cannot see any obvious error.
Could you try to post an executable code snippet (using maybe random inputs), which could reproduce this issue, please?