Show HN: Torch Lens Maker – Differentiable Geometric Optics in PyTorch
Published on: 2025-06-05 09:29:11
Torch Lens Maker
Welcome to Torch Lens Maker, an open-source Python library for differentiable geometric optics based on PyTorch. Currently a very experimental project, the goal is to be able to design complex real-world optical systems (lenses, mirrors, etc.) using modern computer code and state-of-the art numerical optimization.
python import torchlensmaker as tlm optics = tlm.Sequential( tlm.ObjectAtInfinity( beam_diameter = 10 , angular_size = 20 ), tlm.Gap( 15 ), tlm.RefractiveSurface(tlm.Sphere( diameter = 25 , R =- 45.0 ), material = "BK7-nd" ), tlm.Gap( 3 ), tlm.RefractiveSurface(tlm.Sphere( diameter = 25 , R = tlm.parameter( - 20 )), material = "air" ), tlm.Gap( 100 ), tlm.ImagePlane( 50 ), ) tlm.optimize(optics, tlm.optim.Adam(optics.parameters(), lr = 5e-4 ), { "base" : 10 , "object" : 5 }, 100 ) tlm.show2d(optics, title = "Landscape Lens" )
The core of the project is differentiable geometric optics: 3D collision detection and the laws of optics implemented in PyTorch. Py
... Read full article.