 
   /// 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.
   ///

      measurement.patchWithJacobian(at: region)
    assert(generatedAppearance_H_latent.shape == generatedAppearance.shape + [LatentCode.dimension])
    return LinearizedAppearanceTrackingFactor<LatentCode>(
      error: Patch(actualAppearance - generatedAppearance),
      errorVector_H_pose: -actualAppearance_H_pose,
      errorVector_H_latent: generatedAppearance_H_latent,
      edges: Variables.linearized(edges))
  }
}

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

  @derivative(of: errorVector)
