Example-26: Module
[1]:
# Given an objective function or a model, it can be wrapped with torch.nn.Module
# This allows to use different optimization methods (torch.optim, pytorch-optimizer, ...)
# In this example chromaticity is optimized by
# 1) wrapping objective funtion (R^n x R^m x ... -> R) with a torch module (no data is passed to forward call)
# 2) wrapping chromaticity function with a torch module (plane index is passed as feature to forward call)
# In the first case, regular optimization is performed using all avaliable data
# For the second case, mini-batched optimization can be performed
# Planes (horozontal or vertical) are used as features
# Alternatively, location indices along the ring can be used as features (values of twiss parameters at location)
# Or location pairs (phase advance)
[2]:
# Import
import torch
from torch.utils.data import TensorDataset
from torch.utils.data import DataLoader
torch.set_printoptions(linewidth=128)
import matplotlib
from matplotlib import pyplot as plt
matplotlib.rcParams['text.usetex'] = True
from twiss import twiss
from ndmap.signature import chop
from ndmap.evaluate import evaluate
from ndmap.pfp import parametric_fixed_point
from model.library.drift import Drift
from model.library.quadrupole import Quadrupole
from model.library.sextupole import Sextupole
from model.library.dipole import Dipole
from model.library.line import Line
from model.command.wrapper import group
from model.command.wrapper import Wrapper
[3]:
# Define simple FODO based lattice using nested lines
DR = Drift('DR', 0.25)
BM = Dipole('BM', 3.50, torch.pi/4.0)
QF_A = Quadrupole('QF_A', 0.5, +0.20)
QD_A = Quadrupole('QD_A', 0.5, -0.19)
QF_B = Quadrupole('QF_B', 0.5, +0.20)
QD_B = Quadrupole('QD_B', 0.5, -0.19)
QF_C = Quadrupole('QF_C', 0.5, +0.20)
QD_C = Quadrupole('QD_C', 0.5, -0.19)
QF_D = Quadrupole('QF_D', 0.5, +0.20)
QD_D = Quadrupole('QD_D', 0.5, -0.19)
SF_A = Sextupole('SF_A', 0.25, 0.00)
SD_A = Sextupole('SD_A', 0.25, 0.00)
SF_B = Sextupole('SF_B', 0.25, 0.00)
SD_B = Sextupole('SD_B', 0.25, 0.00)
SF_C = Sextupole('SF_C', 0.25, 0.00)
SD_C = Sextupole('SD_C', 0.25, 0.00)
SF_D = Sextupole('SF_D', 0.25, 0.00)
SD_D = Sextupole('SD_D', 0.25, 0.00)
FODO_A = Line('FODO_A', [QF_A, DR, SF_A, DR, BM, DR, SD_A, DR, QD_A, QD_A, DR, SD_A, DR, BM, DR, SF_A, DR, QF_A], propagate=True, dp=0.0, exact=False, output=False, matrix=False)
FODO_B = Line('FODO_B', [QF_B, DR, SF_B, DR, BM, DR, SD_B, DR, QD_B, QD_B, DR, SD_B, DR, BM, DR, SF_B, DR, QF_B], propagate=True, dp=0.0, exact=False, output=False, matrix=False)
FODO_C = Line('FODO_C', [QF_C, DR, SF_C, DR, BM, DR, SD_C, DR, QD_C, QD_C, DR, SD_C, DR, BM, DR, SF_C, DR, QF_C], propagate=True, dp=0.0, exact=False, output=False, matrix=False)
FODO_D = Line('FODO_D', [QF_D, DR, SF_D, DR, BM, DR, SD_D, DR, QD_D, QD_D, DR, SD_D, DR, BM, DR, SF_D, DR, QF_D], propagate=True, dp=0.0, exact=False, output=False, matrix=False)
RING = Line('RING', [FODO_A, FODO_B, FODO_C, FODO_D], propagate=True, dp=0.0, exact=False, output=False, matrix=False)
[4]:
# Set parametric mapping
ring, *_ = group(RING, 'FODO_A', 'FODO_D', ('ms', ['Sextupole'], None, None), ('dp', None, None, None), root=True)
# Set deviation parameters
fp = torch.tensor(4*[0.0], dtype=torch.float64)
ms = torch.tensor(8*[0.0], dtype=torch.float64)
dp = torch.tensor([0.0], dtype=torch.float64)
[5]:
# Define parametric chomaticity function
# Compute parametric fixed point (first order dispersion)
pfp, *_ = parametric_fixed_point((0, 1), fp, [ms, dp], ring)
chop(pfp)
# Define ring around parametric fixed point
def mapping(state, ms, dp):
return ring(state + evaluate(pfp, [ms, dp]), ms, dp) - evaluate(pfp, [ms, dp])
# Define tunes
def tune(ms, dp):
matrix = torch.func.jacrev(mapping)(fp, ms, dp)
tunes, *_ = twiss(matrix)
return tunes
# Define chromaticity
def chromaticity(ms):
return torch.func.jacrev(tune, 1)(ms, dp).squeeze()
# Compute natural chromaticity
print(chromaticity(ms))
tensor([-2.0649, -0.8260], dtype=torch.float64)
[6]:
# Chromaticity can be corrected in a single step
# Compute starting values
psix, psiy = chromaticity(ms)
# Set target values
psix_target = torch.tensor(5.0, dtype=torch.float64)
psiy_target = torch.tensor(5.0, dtype=torch.float64)
# Perform correction
dpsix = psix - psix_target
dpsiy = psiy - psiy_target
solution = - torch.linalg.pinv((torch.func.jacrev(chromaticity)(ms)).squeeze()) @ torch.stack([dpsix, dpsiy])
print(solution)
# Test solution
print(chromaticity(solution))
tensor([ 0.7439, -1.2084, 0.7439, -1.2084, 0.7439, -1.2084, 0.7439, -1.2084], dtype=torch.float64)
tensor([5.0000, 5.0000], dtype=torch.float64)
[7]:
# Optimization (wrapping objective funtion)
# Set model parameters
# Parameters are not cloned inside the module on initialization, values will change during optimization!
ms = torch.tensor(8*[0.0], dtype=torch.float64)
# Define scalar objective function
def objective(ms):
psix, psiy = chromaticity(ms)
return ((psix - psix_target)**2 + (psiy - psiy_target)**2).sqrt()
# Set model (forward returns evaluated objective)
model = Wrapper(objective, ms)
# Set optimizer
optimizer = torch.optim.Adam(model.parameters(), lr=1.0E-2)
# Perfom optimization
epochs = 256
for epoch in range(epochs):
# Evaluate model
error = model()
# Compute derivatives
error.backward()
# Perform optimization step
optimizer.step()
# Set gradient to zero
optimizer.zero_grad()
# Verbose
knobs, *_ = [*model.parameters()]
print(error.detach(), (knobs.detach() - solution).norm())
tensor(9.1573, dtype=torch.float64) tensor(2.8105, dtype=torch.float64)
tensor(9.0611, dtype=torch.float64) tensor(2.7830, dtype=torch.float64)
tensor(8.9651, dtype=torch.float64) tensor(2.7555, dtype=torch.float64)
tensor(8.8693, dtype=torch.float64) tensor(2.7280, dtype=torch.float64)
tensor(8.7737, dtype=torch.float64) tensor(2.7006, dtype=torch.float64)
tensor(8.6784, dtype=torch.float64) tensor(2.6732, dtype=torch.float64)
tensor(8.5833, dtype=torch.float64) tensor(2.6458, dtype=torch.float64)
tensor(8.4884, dtype=torch.float64) tensor(2.6184, dtype=torch.float64)
tensor(8.3938, dtype=torch.float64) tensor(2.5910, dtype=torch.float64)
tensor(8.2995, dtype=torch.float64) tensor(2.5636, dtype=torch.float64)
tensor(8.2054, dtype=torch.float64) tensor(2.5363, dtype=torch.float64)
tensor(8.1116, dtype=torch.float64) tensor(2.5090, dtype=torch.float64)
tensor(8.0181, dtype=torch.float64) tensor(2.4817, dtype=torch.float64)
tensor(7.9249, dtype=torch.float64) tensor(2.4544, dtype=torch.float64)
tensor(7.8320, dtype=torch.float64) tensor(2.4271, dtype=torch.float64)
tensor(7.7394, dtype=torch.float64) tensor(2.3999, dtype=torch.float64)
tensor(7.6471, dtype=torch.float64) tensor(2.3727, dtype=torch.float64)
tensor(7.5552, dtype=torch.float64) tensor(2.3455, dtype=torch.float64)
tensor(7.4636, dtype=torch.float64) tensor(2.3183, dtype=torch.float64)
tensor(7.3724, dtype=torch.float64) tensor(2.2912, dtype=torch.float64)
tensor(7.2815, dtype=torch.float64) tensor(2.2641, dtype=torch.float64)
tensor(7.1910, dtype=torch.float64) tensor(2.2370, dtype=torch.float64)
tensor(7.1008, dtype=torch.float64) tensor(2.2099, dtype=torch.float64)
tensor(7.0110, dtype=torch.float64) tensor(2.1829, dtype=torch.float64)
tensor(6.9216, dtype=torch.float64) tensor(2.1560, dtype=torch.float64)
tensor(6.8326, dtype=torch.float64) tensor(2.1290, dtype=torch.float64)
tensor(6.7440, dtype=torch.float64) tensor(2.1021, dtype=torch.float64)
tensor(6.6557, dtype=torch.float64) tensor(2.0752, dtype=torch.float64)
tensor(6.5679, dtype=torch.float64) tensor(2.0484, dtype=torch.float64)
tensor(6.4804, dtype=torch.float64) tensor(2.0216, dtype=torch.float64)
tensor(6.3933, dtype=torch.float64) tensor(1.9948, dtype=torch.float64)
tensor(6.3066, dtype=torch.float64) tensor(1.9681, dtype=torch.float64)
tensor(6.2204, dtype=torch.float64) tensor(1.9415, dtype=torch.float64)
tensor(6.1345, dtype=torch.float64) tensor(1.9148, dtype=torch.float64)
tensor(6.0489, dtype=torch.float64) tensor(1.8883, dtype=torch.float64)
tensor(5.9638, dtype=torch.float64) tensor(1.8617, dtype=torch.float64)
tensor(5.8791, dtype=torch.float64) tensor(1.8353, dtype=torch.float64)
tensor(5.7947, dtype=torch.float64) tensor(1.8089, dtype=torch.float64)
tensor(5.7107, dtype=torch.float64) tensor(1.7825, dtype=torch.float64)
tensor(5.6271, dtype=torch.float64) tensor(1.7562, dtype=torch.float64)
tensor(5.5438, dtype=torch.float64) tensor(1.7299, dtype=torch.float64)
tensor(5.4609, dtype=torch.float64) tensor(1.7037, dtype=torch.float64)
tensor(5.3783, dtype=torch.float64) tensor(1.6776, dtype=torch.float64)
tensor(5.2961, dtype=torch.float64) tensor(1.6515, dtype=torch.float64)
tensor(5.2142, dtype=torch.float64) tensor(1.6255, dtype=torch.float64)
tensor(5.1326, dtype=torch.float64) tensor(1.5996, dtype=torch.float64)
tensor(5.0513, dtype=torch.float64) tensor(1.5737, dtype=torch.float64)
tensor(4.9702, dtype=torch.float64) tensor(1.5479, dtype=torch.float64)
tensor(4.8895, dtype=torch.float64) tensor(1.5221, dtype=torch.float64)
tensor(4.8091, dtype=torch.float64) tensor(1.4964, dtype=torch.float64)
tensor(4.7289, dtype=torch.float64) tensor(1.4708, dtype=torch.float64)
tensor(4.6489, dtype=torch.float64) tensor(1.4453, dtype=torch.float64)
tensor(4.5692, dtype=torch.float64) tensor(1.4198, dtype=torch.float64)
tensor(4.4897, dtype=torch.float64) tensor(1.3944, dtype=torch.float64)
tensor(4.4105, dtype=torch.float64) tensor(1.3690, dtype=torch.float64)
tensor(4.3314, dtype=torch.float64) tensor(1.3438, dtype=torch.float64)
tensor(4.2525, dtype=torch.float64) tensor(1.3186, dtype=torch.float64)
tensor(4.1738, dtype=torch.float64) tensor(1.2934, dtype=torch.float64)
tensor(4.0953, dtype=torch.float64) tensor(1.2683, dtype=torch.float64)
tensor(4.0169, dtype=torch.float64) tensor(1.2433, dtype=torch.float64)
tensor(3.9387, dtype=torch.float64) tensor(1.2184, dtype=torch.float64)
tensor(3.8606, dtype=torch.float64) tensor(1.1935, dtype=torch.float64)
tensor(3.7827, dtype=torch.float64) tensor(1.1687, dtype=torch.float64)
tensor(3.7049, dtype=torch.float64) tensor(1.1440, dtype=torch.float64)
tensor(3.6272, dtype=torch.float64) tensor(1.1193, dtype=torch.float64)
tensor(3.5496, dtype=torch.float64) tensor(1.0947, dtype=torch.float64)
tensor(3.4722, dtype=torch.float64) tensor(1.0702, dtype=torch.float64)
tensor(3.3948, dtype=torch.float64) tensor(1.0457, dtype=torch.float64)
tensor(3.3176, dtype=torch.float64) tensor(1.0212, dtype=torch.float64)
tensor(3.2404, dtype=torch.float64) tensor(0.9968, dtype=torch.float64)
tensor(3.1634, dtype=torch.float64) tensor(0.9725, dtype=torch.float64)
tensor(3.0864, dtype=torch.float64) tensor(0.9482, dtype=torch.float64)
tensor(3.0096, dtype=torch.float64) tensor(0.9240, dtype=torch.float64)
tensor(2.9328, dtype=torch.float64) tensor(0.8998, dtype=torch.float64)
tensor(2.8561, dtype=torch.float64) tensor(0.8757, dtype=torch.float64)
tensor(2.7796, dtype=torch.float64) tensor(0.8516, dtype=torch.float64)
tensor(2.7031, dtype=torch.float64) tensor(0.8276, dtype=torch.float64)
tensor(2.6267, dtype=torch.float64) tensor(0.8035, dtype=torch.float64)
tensor(2.5504, dtype=torch.float64) tensor(0.7796, dtype=torch.float64)
tensor(2.4742, dtype=torch.float64) tensor(0.7556, dtype=torch.float64)
tensor(2.3980, dtype=torch.float64) tensor(0.7317, dtype=torch.float64)
tensor(2.3220, dtype=torch.float64) tensor(0.7078, dtype=torch.float64)
tensor(2.2460, dtype=torch.float64) tensor(0.6839, dtype=torch.float64)
tensor(2.1702, dtype=torch.float64) tensor(0.6601, dtype=torch.float64)
tensor(2.0944, dtype=torch.float64) tensor(0.6363, dtype=torch.float64)
tensor(2.0186, dtype=torch.float64) tensor(0.6125, dtype=torch.float64)
tensor(1.9430, dtype=torch.float64) tensor(0.5887, dtype=torch.float64)
tensor(1.8674, dtype=torch.float64) tensor(0.5649, dtype=torch.float64)
tensor(1.7919, dtype=torch.float64) tensor(0.5412, dtype=torch.float64)
tensor(1.7165, dtype=torch.float64) tensor(0.5174, dtype=torch.float64)
tensor(1.6411, dtype=torch.float64) tensor(0.4937, dtype=torch.float64)
tensor(1.5658, dtype=torch.float64) tensor(0.4699, dtype=torch.float64)
tensor(1.4906, dtype=torch.float64) tensor(0.4462, dtype=torch.float64)
tensor(1.4154, dtype=torch.float64) tensor(0.4225, dtype=torch.float64)
tensor(1.3402, dtype=torch.float64) tensor(0.3988, dtype=torch.float64)
tensor(1.2652, dtype=torch.float64) tensor(0.3751, dtype=torch.float64)
tensor(1.1901, dtype=torch.float64) tensor(0.3514, dtype=torch.float64)
tensor(1.1152, dtype=torch.float64) tensor(0.3278, dtype=torch.float64)
tensor(1.0402, dtype=torch.float64) tensor(0.3041, dtype=torch.float64)
tensor(0.9654, dtype=torch.float64) tensor(0.2805, dtype=torch.float64)
tensor(0.8906, dtype=torch.float64) tensor(0.2569, dtype=torch.float64)
tensor(0.8158, dtype=torch.float64) tensor(0.2333, dtype=torch.float64)
tensor(0.7412, dtype=torch.float64) tensor(0.2098, dtype=torch.float64)
tensor(0.6665, dtype=torch.float64) tensor(0.1862, dtype=torch.float64)
tensor(0.5920, dtype=torch.float64) tensor(0.1627, dtype=torch.float64)
tensor(0.5174, dtype=torch.float64) tensor(0.1393, dtype=torch.float64)
tensor(0.4430, dtype=torch.float64) tensor(0.1159, dtype=torch.float64)
tensor(0.3685, dtype=torch.float64) tensor(0.0925, dtype=torch.float64)
tensor(0.2941, dtype=torch.float64) tensor(0.0691, dtype=torch.float64)
tensor(0.2198, dtype=torch.float64) tensor(0.0458, dtype=torch.float64)
tensor(0.1455, dtype=torch.float64) tensor(0.0225, dtype=torch.float64)
tensor(0.0713, dtype=torch.float64) tensor(0.0009, dtype=torch.float64)
tensor(0.0034, dtype=torch.float64) tensor(0.0210, dtype=torch.float64)
tensor(0.0681, dtype=torch.float64) tensor(0.0360, dtype=torch.float64)
tensor(0.1144, dtype=torch.float64) tensor(0.0467, dtype=torch.float64)
tensor(0.1474, dtype=torch.float64) tensor(0.0539, dtype=torch.float64)
tensor(0.1708, dtype=torch.float64) tensor(0.0581, dtype=torch.float64)
tensor(0.1860, dtype=torch.float64) tensor(0.0598, dtype=torch.float64)
tensor(0.1928, dtype=torch.float64) tensor(0.0591, dtype=torch.float64)
tensor(0.1912, dtype=torch.float64) tensor(0.0563, dtype=torch.float64)
tensor(0.1816, dtype=torch.float64) tensor(0.0516, dtype=torch.float64)
tensor(0.1652, dtype=torch.float64) tensor(0.0453, dtype=torch.float64)
tensor(0.1436, dtype=torch.float64) tensor(0.0373, dtype=torch.float64)
tensor(0.1178, dtype=torch.float64) tensor(0.0277, dtype=torch.float64)
tensor(0.0874, dtype=torch.float64) tensor(0.0163, dtype=torch.float64)
tensor(0.0514, dtype=torch.float64) tensor(0.0036, dtype=torch.float64)
tensor(0.0133, dtype=torch.float64) tensor(0.0093, dtype=torch.float64)
tensor(0.0305, dtype=torch.float64) tensor(0.0187, dtype=torch.float64)
tensor(0.0602, dtype=torch.float64) tensor(0.0250, dtype=torch.float64)
tensor(0.0796, dtype=torch.float64) tensor(0.0285, dtype=torch.float64)
tensor(0.0901, dtype=torch.float64) tensor(0.0292, dtype=torch.float64)
tensor(0.0923, dtype=torch.float64) tensor(0.0274, dtype=torch.float64)
tensor(0.0868, dtype=torch.float64) tensor(0.0234, dtype=torch.float64)
tensor(0.0744, dtype=torch.float64) tensor(0.0175, dtype=torch.float64)
tensor(0.0563, dtype=torch.float64) tensor(0.0101, dtype=torch.float64)
tensor(0.0326, dtype=torch.float64) tensor(0.0014, dtype=torch.float64)
tensor(0.0048, dtype=torch.float64) tensor(0.0101, dtype=torch.float64)
tensor(0.0362, dtype=torch.float64) tensor(0.0164, dtype=torch.float64)
tensor(0.0519, dtype=torch.float64) tensor(0.0199, dtype=torch.float64)
tensor(0.0647, dtype=torch.float64) tensor(0.0213, dtype=torch.float64)
tensor(0.0721, dtype=torch.float64) tensor(0.0205, dtype=torch.float64)
tensor(0.0681, dtype=torch.float64) tensor(0.0179, dtype=torch.float64)
tensor(0.0566, dtype=torch.float64) tensor(0.0135, dtype=torch.float64)
tensor(0.0438, dtype=torch.float64) tensor(0.0067, dtype=torch.float64)
tensor(0.0224, dtype=torch.float64) tensor(0.0036, dtype=torch.float64)
tensor(0.0187, dtype=torch.float64) tensor(0.0082, dtype=torch.float64)
tensor(0.0269, dtype=torch.float64) tensor(0.0118, dtype=torch.float64)
tensor(0.0412, dtype=torch.float64) tensor(0.0129, dtype=torch.float64)
tensor(0.0420, dtype=torch.float64) tensor(0.0122, dtype=torch.float64)
tensor(0.0388, dtype=torch.float64) tensor(0.0090, dtype=torch.float64)
tensor(0.0296, dtype=torch.float64) tensor(0.0034, dtype=torch.float64)
tensor(0.0122, dtype=torch.float64) tensor(0.0032, dtype=torch.float64)
tensor(0.0101, dtype=torch.float64) tensor(0.0068, dtype=torch.float64)
tensor(0.0220, dtype=torch.float64) tensor(0.0079, dtype=torch.float64)
tensor(0.0250, dtype=torch.float64) tensor(0.0066, dtype=torch.float64)
tensor(0.0208, dtype=torch.float64) tensor(0.0030, dtype=torch.float64)
tensor(0.0100, dtype=torch.float64) tensor(0.0023, dtype=torch.float64)
tensor(0.0092, dtype=torch.float64) tensor(0.0063, dtype=torch.float64)
tensor(0.0233, dtype=torch.float64) tensor(0.0064, dtype=torch.float64)
tensor(0.0202, dtype=torch.float64) tensor(0.0052, dtype=torch.float64)
tensor(0.0222, dtype=torch.float64) tensor(0.0022, dtype=torch.float64)
tensor(0.0071, dtype=torch.float64) tensor(0.0026, dtype=torch.float64)
tensor(0.0109, dtype=torch.float64) tensor(0.0063, dtype=torch.float64)
tensor(0.0244, dtype=torch.float64) tensor(0.0062, dtype=torch.float64)
tensor(0.0201, dtype=torch.float64) tensor(0.0050, dtype=torch.float64)
tensor(0.0235, dtype=torch.float64) tensor(0.0020, dtype=torch.float64)
tensor(0.0084, dtype=torch.float64) tensor(0.0058, dtype=torch.float64)
tensor(0.0370, dtype=torch.float64) tensor(0.0067, dtype=torch.float64)
tensor(0.0358, dtype=torch.float64) tensor(0.0074, dtype=torch.float64)
tensor(0.0242, dtype=torch.float64) tensor(0.0087, dtype=torch.float64)
tensor(0.0366, dtype=torch.float64) tensor(0.0057, dtype=torch.float64)
tensor(0.0215, dtype=torch.float64) tensor(0.0043, dtype=torch.float64)
tensor(0.0269, dtype=torch.float64) tensor(0.0042, dtype=torch.float64)
tensor(0.0241, dtype=torch.float64) tensor(0.0046, dtype=torch.float64)
tensor(0.0212, dtype=torch.float64) tensor(0.0058, dtype=torch.float64)
tensor(0.0275, dtype=torch.float64) tensor(0.0046, dtype=torch.float64)
tensor(0.0146, dtype=torch.float64) tensor(0.0036, dtype=torch.float64)
tensor(0.0189, dtype=torch.float64) tensor(0.0014, dtype=torch.float64)
tensor(0.0056, dtype=torch.float64) tensor(0.0025, dtype=torch.float64)
tensor(0.0087, dtype=torch.float64) tensor(0.0019, dtype=torch.float64)
tensor(0.0073, dtype=torch.float64) tensor(0.0022, dtype=torch.float64)
tensor(0.0128, dtype=torch.float64) tensor(0.0025, dtype=torch.float64)
tensor(0.0102, dtype=torch.float64) tensor(0.0023, dtype=torch.float64)
tensor(0.0072, dtype=torch.float64) tensor(0.0012, dtype=torch.float64)
tensor(0.0076, dtype=torch.float64) tensor(0.0040, dtype=torch.float64)
tensor(0.0213, dtype=torch.float64) tensor(0.0039, dtype=torch.float64)
tensor(0.0158, dtype=torch.float64) tensor(0.0042, dtype=torch.float64)
tensor(0.0231, dtype=torch.float64) tensor(0.0033, dtype=torch.float64)
tensor(0.0202, dtype=torch.float64) tensor(0.0023, dtype=torch.float64)
tensor(0.0146, dtype=torch.float64) tensor(0.0023, dtype=torch.float64)
tensor(0.0128, dtype=torch.float64) tensor(0.0039, dtype=torch.float64)
tensor(0.0218, dtype=torch.float64) tensor(0.0035, dtype=torch.float64)
tensor(0.0197, dtype=torch.float64) tensor(0.0023, dtype=torch.float64)
tensor(0.0139, dtype=torch.float64) tensor(0.0018, dtype=torch.float64)
tensor(0.0115, dtype=torch.float64) tensor(0.0036, dtype=torch.float64)
tensor(0.0222, dtype=torch.float64) tensor(0.0036, dtype=torch.float64)
tensor(0.0215, dtype=torch.float64) tensor(0.0022, dtype=torch.float64)
tensor(0.0111, dtype=torch.float64) tensor(0.0016, dtype=torch.float64)
tensor(0.0100, dtype=torch.float64) tensor(0.0033, dtype=torch.float64)
tensor(0.0204, dtype=torch.float64) tensor(0.0032, dtype=torch.float64)
tensor(0.0180, dtype=torch.float64) tensor(0.0028, dtype=torch.float64)
tensor(0.0152, dtype=torch.float64) tensor(0.0025, dtype=torch.float64)
tensor(0.0149, dtype=torch.float64) tensor(0.0021, dtype=torch.float64)
tensor(0.0137, dtype=torch.float64) tensor(0.0019, dtype=torch.float64)
tensor(0.0103, dtype=torch.float64) tensor(0.0036, dtype=torch.float64)
tensor(0.0216, dtype=torch.float64) tensor(0.0034, dtype=torch.float64)
tensor(0.0209, dtype=torch.float64) tensor(0.0014, dtype=torch.float64)
tensor(0.0084, dtype=torch.float64) tensor(0.0010, dtype=torch.float64)
tensor(0.0063, dtype=torch.float64) tensor(0.0038, dtype=torch.float64)
tensor(0.0236, dtype=torch.float64) tensor(0.0036, dtype=torch.float64)
tensor(0.0222, dtype=torch.float64) tensor(0.0013, dtype=torch.float64)
tensor(0.0074, dtype=torch.float64) tensor(0.0010, dtype=torch.float64)
tensor(0.0065, dtype=torch.float64) tensor(0.0034, dtype=torch.float64)
tensor(0.0216, dtype=torch.float64) tensor(0.0032, dtype=torch.float64)
tensor(0.0196, dtype=torch.float64) tensor(0.0018, dtype=torch.float64)
tensor(0.0101, dtype=torch.float64) tensor(0.0015, dtype=torch.float64)
tensor(0.0097, dtype=torch.float64) tensor(0.0028, dtype=torch.float64)
tensor(0.0174, dtype=torch.float64) tensor(0.0026, dtype=torch.float64)
tensor(0.0151, dtype=torch.float64) tensor(0.0024, dtype=torch.float64)
tensor(0.0141, dtype=torch.float64) tensor(0.0021, dtype=torch.float64)
tensor(0.0134, dtype=torch.float64) tensor(0.0021, dtype=torch.float64)
tensor(0.0134, dtype=torch.float64) tensor(0.0019, dtype=torch.float64)
tensor(0.0112, dtype=torch.float64) tensor(0.0028, dtype=torch.float64)
tensor(0.0171, dtype=torch.float64) tensor(0.0026, dtype=torch.float64)
tensor(0.0161, dtype=torch.float64) tensor(0.0017, dtype=torch.float64)
tensor(0.0108, dtype=torch.float64) tensor(0.0015, dtype=torch.float64)
tensor(0.0089, dtype=torch.float64) tensor(0.0029, dtype=torch.float64)
tensor(0.0186, dtype=torch.float64) tensor(0.0027, dtype=torch.float64)
tensor(0.0174, dtype=torch.float64) tensor(0.0015, dtype=torch.float64)
tensor(0.0093, dtype=torch.float64) tensor(0.0012, dtype=torch.float64)
tensor(0.0076, dtype=torch.float64) tensor(0.0030, dtype=torch.float64)
tensor(0.0192, dtype=torch.float64) tensor(0.0029, dtype=torch.float64)
tensor(0.0180, dtype=torch.float64) tensor(0.0013, dtype=torch.float64)
tensor(0.0084, dtype=torch.float64) tensor(0.0011, dtype=torch.float64)
tensor(0.0069, dtype=torch.float64) tensor(0.0031, dtype=torch.float64)
tensor(0.0195, dtype=torch.float64) tensor(0.0028, dtype=torch.float64)
tensor(0.0182, dtype=torch.float64) tensor(0.0013, dtype=torch.float64)
tensor(0.0079, dtype=torch.float64) tensor(0.0010, dtype=torch.float64)
tensor(0.0065, dtype=torch.float64) tensor(0.0031, dtype=torch.float64)
tensor(0.0193, dtype=torch.float64) tensor(0.0029, dtype=torch.float64)
tensor(0.0180, dtype=torch.float64) tensor(0.0013, dtype=torch.float64)
tensor(0.0079, dtype=torch.float64) tensor(0.0011, dtype=torch.float64)
tensor(0.0068, dtype=torch.float64) tensor(0.0029, dtype=torch.float64)
tensor(0.0186, dtype=torch.float64) tensor(0.0027, dtype=torch.float64)
tensor(0.0171, dtype=torch.float64) tensor(0.0015, dtype=torch.float64)
tensor(0.0087, dtype=torch.float64) tensor(0.0012, dtype=torch.float64)
tensor(0.0077, dtype=torch.float64) tensor(0.0027, dtype=torch.float64)
tensor(0.0172, dtype=torch.float64) tensor(0.0026, dtype=torch.float64)
tensor(0.0156, dtype=torch.float64) tensor(0.0016, dtype=torch.float64)
tensor(0.0101, dtype=torch.float64) tensor(0.0014, dtype=torch.float64)
tensor(0.0092, dtype=torch.float64) tensor(0.0024, dtype=torch.float64)
tensor(0.0153, dtype=torch.float64) tensor(0.0022, dtype=torch.float64)
tensor(0.0137, dtype=torch.float64) tensor(0.0020, dtype=torch.float64)
tensor(0.0117, dtype=torch.float64) tensor(0.0017, dtype=torch.float64)
tensor(0.0108, dtype=torch.float64) tensor(0.0022, dtype=torch.float64)
tensor(0.0136, dtype=torch.float64) tensor(0.0020, dtype=torch.float64)
[8]:
# Optimization (wrapping chromaticity function)
# Set model parameters
# Parameters are not cloned inside the module on initialization, values will change during optimization!
ms = torch.tensor(8*[0.0], dtype=torch.float64)
# Set features and labels
# X selects the plane (horizontal or vertical chomaticity)
# y is corresponding target chromaticity value for selected plane
X = torch.tensor([[0], [1]])
y = torch.stack([psix_target, psiy_target])
# Set dataset
# Note, batch size is one, technicaly this is not a mini-batch optimization
batch_size = 1
dataset = TensorDataset(X.clone(), y.clone())
# Set data loader
dataloader = DataLoader(dataset, batch_size=batch_size, shuffle=True)
# Set objective (return horizontal or vertical chomaticity)
def objective(x, ms):
return chromaticity(ms)[x].squeeze()
# Set model (forward returns evaluated objective)
model = Wrapper(objective, ms)
# Set optimizer
optimizer = torch.optim.Adam(model.parameters(), lr=1.0E-2)
# Set loss funtion
lf = torch.nn.MSELoss()
# Perfom optimization
epochs = 256
for epoch in range(epochs):
# Loop over batches of data
for batch, (X, y) in enumerate(dataloader):
# Evaluate model
y_hat = model(X)
# Evaluate loss function
error = lf(y_hat, y.squeeze())
# Compute derivatives
error.backward()
# Perform optimization step
optimizer.step()
# Set gradient to zero
optimizer.zero_grad()
# Verbose
knobs, *_ = [*model.parameters()]
print(error.detach(), (knobs.detach() - solution).norm())
tensor(35.4295, dtype=torch.float64) tensor(2.8297, dtype=torch.float64)
tensor(47.7980, dtype=torch.float64) tensor(2.8006, dtype=torch.float64)
tensor(33.9269, dtype=torch.float64) tensor(2.7718, dtype=torch.float64)
tensor(45.6336, dtype=torch.float64) tensor(2.7423, dtype=torch.float64)
tensor(32.6024, dtype=torch.float64) tensor(2.7134, dtype=torch.float64)
tensor(43.5373, dtype=torch.float64) tensor(2.6840, dtype=torch.float64)
tensor(42.6609, dtype=torch.float64) tensor(2.6547, dtype=torch.float64)
tensor(41.7582, dtype=torch.float64) tensor(2.6255, dtype=torch.float64)
tensor(29.9431, dtype=torch.float64) tensor(2.5970, dtype=torch.float64)
tensor(29.4738, dtype=torch.float64) tensor(2.5684, dtype=torch.float64)
tensor(28.9800, dtype=torch.float64) tensor(2.5399, dtype=torch.float64)
tensor(37.5585, dtype=torch.float64) tensor(2.5109, dtype=torch.float64)
tensor(36.7554, dtype=torch.float64) tensor(2.4820, dtype=torch.float64)
tensor(27.1260, dtype=torch.float64) tensor(2.4540, dtype=torch.float64)
tensor(26.6535, dtype=torch.float64) tensor(2.4259, dtype=torch.float64)
tensor(26.1669, dtype=torch.float64) tensor(2.3979, dtype=torch.float64)
tensor(33.0411, dtype=torch.float64) tensor(2.3695, dtype=torch.float64)
tensor(32.3221, dtype=torch.float64) tensor(2.3413, dtype=torch.float64)
tensor(31.5935, dtype=torch.float64) tensor(2.3133, dtype=torch.float64)
tensor(30.8600, dtype=torch.float64) tensor(2.2855, dtype=torch.float64)
tensor(23.2333, dtype=torch.float64) tensor(2.2585, dtype=torch.float64)
tensor(22.8195, dtype=torch.float64) tensor(2.2316, dtype=torch.float64)
tensor(22.3918, dtype=torch.float64) tensor(2.2048, dtype=torch.float64)
tensor(27.5644, dtype=torch.float64) tensor(2.1774, dtype=torch.float64)
tensor(21.3774, dtype=torch.float64) tensor(2.1510, dtype=torch.float64)
tensor(20.9557, dtype=torch.float64) tensor(2.1246, dtype=torch.float64)
tensor(25.3956, dtype=torch.float64) tensor(2.0977, dtype=torch.float64)
tensor(24.8144, dtype=torch.float64) tensor(2.0711, dtype=torch.float64)
tensor(24.2275, dtype=torch.float64) tensor(2.0447, dtype=torch.float64)
tensor(18.9254, dtype=torch.float64) tensor(2.0192, dtype=torch.float64)
tensor(22.9146, dtype=torch.float64) tensor(1.9932, dtype=torch.float64)
tensor(18.0572, dtype=torch.float64) tensor(1.9680, dtype=torch.float64)
tensor(17.6949, dtype=torch.float64) tensor(1.9429, dtype=torch.float64)
tensor(21.0109, dtype=torch.float64) tensor(1.9173, dtype=torch.float64)
tensor(20.5056, dtype=torch.float64) tensor(1.8920, dtype=torch.float64)
tensor(16.3728, dtype=torch.float64) tensor(1.8675, dtype=torch.float64)
tensor(16.0336, dtype=torch.float64) tensor(1.8432, dtype=torch.float64)
tensor(18.7730, dtype=torch.float64) tensor(1.8183, dtype=torch.float64)
tensor(15.2336, dtype=torch.float64) tensor(1.7943, dtype=torch.float64)
tensor(14.9012, dtype=torch.float64) tensor(1.7705, dtype=torch.float64)
tensor(14.5642, dtype=torch.float64) tensor(1.7468, dtype=torch.float64)
tensor(14.2246, dtype=torch.float64) tensor(1.7232, dtype=torch.float64)
tensor(13.8840, dtype=torch.float64) tensor(1.6997, dtype=torch.float64)
tensor(15.6818, dtype=torch.float64) tensor(1.6758, dtype=torch.float64)
tensor(13.1131, dtype=torch.float64) tensor(1.6528, dtype=torch.float64)
tensor(14.8403, dtype=torch.float64) tensor(1.6294, dtype=torch.float64)
tensor(14.4807, dtype=torch.float64) tensor(1.6062, dtype=torch.float64)
tensor(12.0058, dtype=torch.float64) tensor(1.5839, dtype=torch.float64)
tensor(11.7240, dtype=torch.float64) tensor(1.5617, dtype=torch.float64)
tensor(13.2212, dtype=torch.float64) tensor(1.5391, dtype=torch.float64)
tensor(12.8885, dtype=torch.float64) tensor(1.5167, dtype=torch.float64)
tensor(12.5528, dtype=torch.float64) tensor(1.4946, dtype=torch.float64)
tensor(12.2161, dtype=torch.float64) tensor(1.4727, dtype=torch.float64)
tensor(10.0792, dtype=torch.float64) tensor(1.4517, dtype=torch.float64)
tensor(9.8487, dtype=torch.float64) tensor(1.4307, dtype=torch.float64)
tensor(9.6134, dtype=torch.float64) tensor(1.4099, dtype=torch.float64)
tensor(10.7013, dtype=torch.float64) tensor(1.3887, dtype=torch.float64)
tensor(9.0662, dtype=torch.float64) tensor(1.3683, dtype=torch.float64)
tensor(8.8395, dtype=torch.float64) tensor(1.3480, dtype=torch.float64)
tensor(9.7233, dtype=torch.float64) tensor(1.3273, dtype=torch.float64)
tensor(9.4668, dtype=torch.float64) tensor(1.3069, dtype=torch.float64)
tensor(8.0403, dtype=torch.float64) tensor(1.2873, dtype=torch.float64)
tensor(8.8849, dtype=torch.float64) tensor(1.2672, dtype=torch.float64)
tensor(7.5717, dtype=torch.float64) tensor(1.2480, dtype=torch.float64)
tensor(7.3774, dtype=torch.float64) tensor(1.2289, dtype=torch.float64)
tensor(7.1814, dtype=torch.float64) tensor(1.2099, dtype=torch.float64)
tensor(7.7638, dtype=torch.float64) tensor(1.1906, dtype=torch.float64)
tensor(7.5544, dtype=torch.float64) tensor(1.1715, dtype=torch.float64)
tensor(6.4981, dtype=torch.float64) tensor(1.1532, dtype=torch.float64)
tensor(6.3243, dtype=torch.float64) tensor(1.1350, dtype=torch.float64)
tensor(6.8253, dtype=torch.float64) tensor(1.1165, dtype=torch.float64)
tensor(5.9263, dtype=torch.float64) tensor(1.0987, dtype=torch.float64)
tensor(5.7620, dtype=torch.float64) tensor(1.0811, dtype=torch.float64)
tensor(5.5974, dtype=torch.float64) tensor(1.0636, dtype=torch.float64)
tensor(5.9471, dtype=torch.float64) tensor(1.0458, dtype=torch.float64)
tensor(5.2268, dtype=torch.float64) tensor(1.0288, dtype=torch.float64)
tensor(5.0744, dtype=torch.float64) tensor(1.0119, dtype=torch.float64)
tensor(5.3731, dtype=torch.float64) tensor(0.9946, dtype=torch.float64)
tensor(4.7320, dtype=torch.float64) tensor(0.9782, dtype=torch.float64)
tensor(4.5913, dtype=torch.float64) tensor(0.9618, dtype=torch.float64)
tensor(4.8476, dtype=torch.float64) tensor(0.9452, dtype=torch.float64)
tensor(4.2758, dtype=torch.float64) tensor(0.9292, dtype=torch.float64)
tensor(4.5347, dtype=torch.float64) tensor(0.9130, dtype=torch.float64)
tensor(3.9830, dtype=torch.float64) tensor(0.8975, dtype=torch.float64)
tensor(4.2354, dtype=torch.float64) tensor(0.8816, dtype=torch.float64)
tensor(4.1097, dtype=torch.float64) tensor(0.8661, dtype=torch.float64)
tensor(3.9835, dtype=torch.float64) tensor(0.8507, dtype=torch.float64)
tensor(3.4304, dtype=torch.float64) tensor(0.8360, dtype=torch.float64)
tensor(3.3309, dtype=torch.float64) tensor(0.8215, dtype=torch.float64)
tensor(3.5530, dtype=torch.float64) tensor(0.8066, dtype=torch.float64)
tensor(3.4421, dtype=torch.float64) tensor(0.7920, dtype=torch.float64)
tensor(3.3313, dtype=torch.float64) tensor(0.7777, dtype=torch.float64)
tensor(3.2212, dtype=torch.float64) tensor(0.7635, dtype=torch.float64)
tensor(2.7570, dtype=torch.float64) tensor(0.7499, dtype=torch.float64)
tensor(2.9791, dtype=torch.float64) tensor(0.7361, dtype=torch.float64)
tensor(2.8788, dtype=torch.float64) tensor(0.7225, dtype=torch.float64)
tensor(2.4735, dtype=torch.float64) tensor(0.7095, dtype=torch.float64)
tensor(2.4011, dtype=torch.float64) tensor(0.6966, dtype=torch.float64)
tensor(2.3278, dtype=torch.float64) tensor(0.6838, dtype=torch.float64)
tensor(2.2539, dtype=torch.float64) tensor(0.6711, dtype=torch.float64)
tensor(2.3372, dtype=torch.float64) tensor(0.6583, dtype=torch.float64)
tensor(2.0867, dtype=torch.float64) tensor(0.6460, dtype=torch.float64)
tensor(2.1669, dtype=torch.float64) tensor(0.6335, dtype=torch.float64)
tensor(2.0960, dtype=torch.float64) tensor(0.6212, dtype=torch.float64)
tensor(1.8491, dtype=torch.float64) tensor(0.6095, dtype=torch.float64)
tensor(1.9372, dtype=torch.float64) tensor(0.5975, dtype=torch.float64)
tensor(1.7122, dtype=torch.float64) tensor(0.5861, dtype=torch.float64)
tensor(1.7894, dtype=torch.float64) tensor(0.5745, dtype=torch.float64)
tensor(1.5839, dtype=torch.float64) tensor(0.5634, dtype=torch.float64)
tensor(1.5311, dtype=torch.float64) tensor(0.5525, dtype=torch.float64)
tensor(1.5798, dtype=torch.float64) tensor(0.5413, dtype=torch.float64)
tensor(1.4119, dtype=torch.float64) tensor(0.5307, dtype=torch.float64)
tensor(1.3630, dtype=torch.float64) tensor(0.5202, dtype=torch.float64)
tensor(1.3145, dtype=torch.float64) tensor(0.5099, dtype=torch.float64)
tensor(1.2665, dtype=torch.float64) tensor(0.4997, dtype=torch.float64)
tensor(1.2191, dtype=torch.float64) tensor(0.4896, dtype=torch.float64)
tensor(1.1727, dtype=torch.float64) tensor(0.4797, dtype=torch.float64)
tensor(1.1272, dtype=torch.float64) tensor(0.4699, dtype=torch.float64)
tensor(1.0828, dtype=torch.float64) tensor(0.4602, dtype=torch.float64)
tensor(1.0396, dtype=torch.float64) tensor(0.4507, dtype=torch.float64)
tensor(1.0320, dtype=torch.float64) tensor(0.4411, dtype=torch.float64)
tensor(0.9468, dtype=torch.float64) tensor(0.4319, dtype=torch.float64)
tensor(0.9092, dtype=torch.float64) tensor(0.4229, dtype=torch.float64)
tensor(0.9150, dtype=torch.float64) tensor(0.4137, dtype=torch.float64)
tensor(0.8847, dtype=torch.float64) tensor(0.4048, dtype=torch.float64)
tensor(0.8541, dtype=torch.float64) tensor(0.3960, dtype=torch.float64)
tensor(0.7488, dtype=torch.float64) tensor(0.3876, dtype=torch.float64)
tensor(0.7846, dtype=torch.float64) tensor(0.3792, dtype=torch.float64)
tensor(0.7557, dtype=torch.float64) tensor(0.3709, dtype=torch.float64)
tensor(0.6528, dtype=torch.float64) tensor(0.3629, dtype=torch.float64)
tensor(0.6288, dtype=torch.float64) tensor(0.3552, dtype=torch.float64)
tensor(0.6581, dtype=torch.float64) tensor(0.3473, dtype=torch.float64)
tensor(0.6333, dtype=torch.float64) tensor(0.3395, dtype=torch.float64)
tensor(0.6086, dtype=torch.float64) tensor(0.3319, dtype=torch.float64)
tensor(0.5213, dtype=torch.float64) tensor(0.3247, dtype=torch.float64)
tensor(0.5545, dtype=torch.float64) tensor(0.3174, dtype=torch.float64)
tensor(0.5322, dtype=torch.float64) tensor(0.3102, dtype=torch.float64)
tensor(0.4551, dtype=torch.float64) tensor(0.3034, dtype=torch.float64)
tensor(0.4386, dtype=torch.float64) tensor(0.2967, dtype=torch.float64)
tensor(0.4220, dtype=torch.float64) tensor(0.2900, dtype=torch.float64)
tensor(0.4055, dtype=torch.float64) tensor(0.2835, dtype=torch.float64)
tensor(0.4140, dtype=torch.float64) tensor(0.2769, dtype=torch.float64)
tensor(0.3690, dtype=torch.float64) tensor(0.2706, dtype=torch.float64)
tensor(0.3541, dtype=torch.float64) tensor(0.2645, dtype=torch.float64)
tensor(0.3395, dtype=torch.float64) tensor(0.2584, dtype=torch.float64)
tensor(0.3251, dtype=torch.float64) tensor(0.2524, dtype=torch.float64)
tensor(0.3246, dtype=torch.float64) tensor(0.2464, dtype=torch.float64)
tensor(0.3123, dtype=torch.float64) tensor(0.2405, dtype=torch.float64)
tensor(0.2781, dtype=torch.float64) tensor(0.2349, dtype=torch.float64)
tensor(0.2846, dtype=torch.float64) tensor(0.2292, dtype=torch.float64)
tensor(0.2732, dtype=torch.float64) tensor(0.2237, dtype=torch.float64)
tensor(0.2619, dtype=torch.float64) tensor(0.2183, dtype=torch.float64)
tensor(0.2507, dtype=torch.float64) tensor(0.2130, dtype=torch.float64)
tensor(0.2145, dtype=torch.float64) tensor(0.2079, dtype=torch.float64)
tensor(0.2265, dtype=torch.float64) tensor(0.2028, dtype=torch.float64)
tensor(0.2166, dtype=torch.float64) tensor(0.1979, dtype=torch.float64)
tensor(0.1852, dtype=torch.float64) tensor(0.1931, dtype=torch.float64)
tensor(0.1779, dtype=torch.float64) tensor(0.1885, dtype=torch.float64)
tensor(0.1706, dtype=torch.float64) tensor(0.1839, dtype=torch.float64)
tensor(0.1743, dtype=torch.float64) tensor(0.1793, dtype=torch.float64)
tensor(0.1669, dtype=torch.float64) tensor(0.1748, dtype=torch.float64)
tensor(0.1460, dtype=torch.float64) tensor(0.1705, dtype=torch.float64)
tensor(0.1399, dtype=torch.float64) tensor(0.1663, dtype=torch.float64)
tensor(0.1422, dtype=torch.float64) tensor(0.1621, dtype=torch.float64)
tensor(0.1263, dtype=torch.float64) tensor(0.1581, dtype=torch.float64)
tensor(0.1284, dtype=torch.float64) tensor(0.1540, dtype=torch.float64)
tensor(0.1139, dtype=torch.float64) tensor(0.1501, dtype=torch.float64)
tensor(0.1089, dtype=torch.float64) tensor(0.1464, dtype=torch.float64)
tensor(0.1040, dtype=torch.float64) tensor(0.1427, dtype=torch.float64)
tensor(0.1035, dtype=torch.float64) tensor(0.1389, dtype=torch.float64)
tensor(0.0933, dtype=torch.float64) tensor(0.1354, dtype=torch.float64)
tensor(0.0935, dtype=torch.float64) tensor(0.1318, dtype=torch.float64)
tensor(0.0837, dtype=torch.float64) tensor(0.1284, dtype=torch.float64)
tensor(0.0844, dtype=torch.float64) tensor(0.1250, dtype=torch.float64)
tensor(0.0751, dtype=torch.float64) tensor(0.1218, dtype=torch.float64)
tensor(0.0761, dtype=torch.float64) tensor(0.1185, dtype=torch.float64)
tensor(0.0674, dtype=torch.float64) tensor(0.1154, dtype=torch.float64)
tensor(0.0642, dtype=torch.float64) tensor(0.1124, dtype=torch.float64)
tensor(0.0612, dtype=torch.float64) tensor(0.1094, dtype=torch.float64)
tensor(0.0609, dtype=torch.float64) tensor(0.1064, dtype=torch.float64)
tensor(0.0546, dtype=torch.float64) tensor(0.1036, dtype=torch.float64)
tensor(0.0520, dtype=torch.float64) tensor(0.1008, dtype=torch.float64)
tensor(0.0518, dtype=torch.float64) tensor(0.0980, dtype=torch.float64)
tensor(0.0463, dtype=torch.float64) tensor(0.0954, dtype=torch.float64)
tensor(0.0466, dtype=torch.float64) tensor(0.0928, dtype=torch.float64)
tensor(0.0445, dtype=torch.float64) tensor(0.0902, dtype=torch.float64)
tensor(0.0387, dtype=torch.float64) tensor(0.0877, dtype=torch.float64)
tensor(0.0399, dtype=torch.float64) tensor(0.0853, dtype=torch.float64)
tensor(0.0380, dtype=torch.float64) tensor(0.0829, dtype=torch.float64)
tensor(0.0361, dtype=torch.float64) tensor(0.0806, dtype=torch.float64)
tensor(0.0306, dtype=torch.float64) tensor(0.0784, dtype=torch.float64)
tensor(0.0291, dtype=torch.float64) tensor(0.0762, dtype=torch.float64)
tensor(0.0278, dtype=torch.float64) tensor(0.0741, dtype=torch.float64)
tensor(0.0264, dtype=torch.float64) tensor(0.0720, dtype=torch.float64)
tensor(0.0265, dtype=torch.float64) tensor(0.0700, dtype=torch.float64)
tensor(0.0253, dtype=torch.float64) tensor(0.0680, dtype=torch.float64)
tensor(0.0240, dtype=torch.float64) tensor(0.0660, dtype=torch.float64)
tensor(0.0206, dtype=torch.float64) tensor(0.0641, dtype=torch.float64)
tensor(0.0196, dtype=torch.float64) tensor(0.0623, dtype=torch.float64)
tensor(0.0200, dtype=torch.float64) tensor(0.0605, dtype=torch.float64)
tensor(0.0175, dtype=torch.float64) tensor(0.0588, dtype=torch.float64)
tensor(0.0166, dtype=torch.float64) tensor(0.0571, dtype=torch.float64)
tensor(0.0158, dtype=torch.float64) tensor(0.0555, dtype=torch.float64)
tensor(0.0149, dtype=torch.float64) tensor(0.0539, dtype=torch.float64)
tensor(0.0141, dtype=torch.float64) tensor(0.0523, dtype=torch.float64)
tensor(0.0134, dtype=torch.float64) tensor(0.0508, dtype=torch.float64)
tensor(0.0126, dtype=torch.float64) tensor(0.0493, dtype=torch.float64)
tensor(0.0119, dtype=torch.float64) tensor(0.0478, dtype=torch.float64)
tensor(0.0114, dtype=torch.float64) tensor(0.0464, dtype=torch.float64)
tensor(0.0104, dtype=torch.float64) tensor(0.0450, dtype=torch.float64)
tensor(0.0102, dtype=torch.float64) tensor(0.0436, dtype=torch.float64)
tensor(0.0098, dtype=torch.float64) tensor(0.0423, dtype=torch.float64)
tensor(0.0093, dtype=torch.float64) tensor(0.0410, dtype=torch.float64)
tensor(0.0088, dtype=torch.float64) tensor(0.0397, dtype=torch.float64)
tensor(0.0074, dtype=torch.float64) tensor(0.0385, dtype=torch.float64)
tensor(0.0078, dtype=torch.float64) tensor(0.0373, dtype=torch.float64)
tensor(0.0074, dtype=torch.float64) tensor(0.0362, dtype=torch.float64)
tensor(0.0070, dtype=torch.float64) tensor(0.0351, dtype=torch.float64)
tensor(0.0066, dtype=torch.float64) tensor(0.0340, dtype=torch.float64)
tensor(0.0054, dtype=torch.float64) tensor(0.0330, dtype=torch.float64)
tensor(0.0051, dtype=torch.float64) tensor(0.0320, dtype=torch.float64)
tensor(0.0048, dtype=torch.float64) tensor(0.0310, dtype=torch.float64)
tensor(0.0046, dtype=torch.float64) tensor(0.0300, dtype=torch.float64)
tensor(0.0046, dtype=torch.float64) tensor(0.0291, dtype=torch.float64)
tensor(0.0040, dtype=torch.float64) tensor(0.0282, dtype=torch.float64)
tensor(0.0041, dtype=torch.float64) tensor(0.0273, dtype=torch.float64)
tensor(0.0036, dtype=torch.float64) tensor(0.0264, dtype=torch.float64)
tensor(0.0034, dtype=torch.float64) tensor(0.0256, dtype=torch.float64)
tensor(0.0032, dtype=torch.float64) tensor(0.0248, dtype=torch.float64)
tensor(0.0031, dtype=torch.float64) tensor(0.0240, dtype=torch.float64)
tensor(0.0029, dtype=torch.float64) tensor(0.0232, dtype=torch.float64)
tensor(0.0028, dtype=torch.float64) tensor(0.0225, dtype=torch.float64)
tensor(0.0024, dtype=torch.float64) tensor(0.0218, dtype=torch.float64)
tensor(0.0023, dtype=torch.float64) tensor(0.0211, dtype=torch.float64)
tensor(0.0023, dtype=torch.float64) tensor(0.0204, dtype=torch.float64)
tensor(0.0021, dtype=torch.float64) tensor(0.0197, dtype=torch.float64)
tensor(0.0018, dtype=torch.float64) tensor(0.0191, dtype=torch.float64)
tensor(0.0019, dtype=torch.float64) tensor(0.0184, dtype=torch.float64)
tensor(0.0018, dtype=torch.float64) tensor(0.0178, dtype=torch.float64)
tensor(0.0017, dtype=torch.float64) tensor(0.0172, dtype=torch.float64)
tensor(0.0014, dtype=torch.float64) tensor(0.0167, dtype=torch.float64)
tensor(0.0014, dtype=torch.float64) tensor(0.0161, dtype=torch.float64)
tensor(0.0014, dtype=torch.float64) tensor(0.0156, dtype=torch.float64)
tensor(0.0011, dtype=torch.float64) tensor(0.0151, dtype=torch.float64)
tensor(0.0012, dtype=torch.float64) tensor(0.0146, dtype=torch.float64)
tensor(0.0010, dtype=torch.float64) tensor(0.0141, dtype=torch.float64)
tensor(0.0010, dtype=torch.float64) tensor(0.0136, dtype=torch.float64)
tensor(0.0009, dtype=torch.float64) tensor(0.0132, dtype=torch.float64)
tensor(0.0008, dtype=torch.float64) tensor(0.0127, dtype=torch.float64)
tensor(0.0008, dtype=torch.float64) tensor(0.0123, dtype=torch.float64)
tensor(0.0008, dtype=torch.float64) tensor(0.0119, dtype=torch.float64)
tensor(0.0007, dtype=torch.float64) tensor(0.0114, dtype=torch.float64)
tensor(0.0007, dtype=torch.float64) tensor(0.0110, dtype=torch.float64)
tensor(0.0006, dtype=torch.float64) tensor(0.0107, dtype=torch.float64)
tensor(0.0006, dtype=torch.float64) tensor(0.0103, dtype=torch.float64)
tensor(0.0006, dtype=torch.float64) tensor(0.0099, dtype=torch.float64)