Learning to reason over visual objects