PIXELBANKv9.1.0
Menu

Implement a gradient descent update step for camera parameters in the context of Bundle Adjustment, a crucial process in Image Alignment and Stitching. You are given the current camera parameters and their gradient, and need to perform one update step to minimize a cost function.

The goal of gradient descent is to iteratively update parameters to minimize the cost function, which measures the difference between observed and predicted values. The learning rate controls the step size of each update. The gradient of the cost function points in the direction of the steepest ascent, so subtracting it from the current parameters moves them downhill toward the minimum.

Here are the steps to update the parameters:

  1. Compute the gradient of the cost function with respect to the current parameters.
  2. Multiply the gradient by the learning rate.
  3. Subtract the result from the current parameters to obtain the updated parameters.
θnew=θold−η⋅∇C\theta_{new} = \theta_{old} - \eta \cdot \nabla C

This technique is widely used in computer vision applications, such as image stitching and 3D reconstruction.

Example:

Input:
translation = [1, 1, 1]
gradient = [0.1, 0.2, 0.3]
learning_rate = 0.1
Output:
[0.99, 0.98, 0.97]
Reasoning:

Applying gradient descent update:

θ_new = θ_old - η × gradient

For each component:

  • tx_new = 1 - 0.1 × 0.1 = 1 - 0.01 = 0.99
  • ty_new = 1 - 0.1 × 0.2 = 1 - 0.02 = 0.98
  • tz_new = 1 - 0.1 × 0.3 = 1 - 0.03 = 0.97

Result: [0.99, 0.98, 0.97]

The translation moves in the opposite direction of the gradient.

Constraints:

  • translation: current [tx, ty, tz]
  • gradient: cost gradient [∂C/∂tx, ∂C/∂ty, ∂C/∂tz]
  • learning_rate: step size η
  • Return updated translation
  • Round to 4 decimal places
🔒

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test Results

0/0
Run code to see test results.
Gradient Descent Update - Medium | PixelBank