Training and testing caption generation