Flexible neural representation for physics prediction