     let (appearance, _) = appearanceModel(latent.flatTensor)
     let region = OrientedBoundingBox(
       center: pose, rows: appearance.shape[0], cols: appearance.shape[1])
-    return Patch(appearance - measurement.patch(at: region))
+    return Patch(weight * (appearance - measurement.patch(at: region)))
   }
 
   @derivative(of: errorVector)

    _ poseId: TypedID<Pose2>,
    _ latentId: TypedID<LatentCode>,
    measurement: Tensor<Double>,
    appearanceModel: @escaping GenerativeModel
  ) {
    self.edges = Tuple2(poseId, latentId)
    self.measurement = measurement
    self.appearanceModel = appearanceModel
  }

  /// Returns the difference between the PPCA generated `Patch` and the `Patch` cropped from


  /// The image containing the target.
  public let measurement: Tensor<Double>

  /// Weighting of the error
  public var weight: Double

  /// A generative model that produces an appearance from a latent code.
  ///
