qmctorch.utils package
Submodules
- qmctorch.utils.algebra_utils module
- qmctorch.utils.hdf5_utils module
print_insert_error()
print_insert_type_error()
print_load_error()
load_from_hdf5()
load_object()
load_group()
load_data()
cast_loaded_data()
bytes2str()
lookup_cast()
isgroup()
dump_to_hdf5()
insert_object()
insert_group()
insert_data()
insert_type()
insert_default()
insert_list()
insert_tuple()
insert_numpy()
insert_torch_tensor()
insert_torch_parameter()
insert_none()
haschildren()
children()
get_children_names()
get_child_object()
add_group_attr()
register_extra_attributes()
- qmctorch.utils.interpolate module
- qmctorch.utils.plot_data module
- qmctorch.utils.stat_utils module
- qmctorch.utils.torch_utils module
Module contents
Utils module API.
- qmctorch.utils.plot_energy(local_energy, e0=None, show_variance=False)[source]
Plot the evolution of the energy
- qmctorch.utils.plot_data(observable, obsname)[source]
Plot the evolution a given data
- Parameters:
obs_dict (SimpleNamespace) – namespace of observable
obsname (str) – name (key) of the desired observable
- qmctorch.utils.plot_block(eloc)[source]
Plot the blocking thingy
- Parameters:
eloc (np.array) – values of the local energy
- qmctorch.utils.plot_walkers_traj(eloc, walkers='mean')[source]
Plot the trajectory of all the individual walkers
- qmctorch.utils.plot_correlation_time(eloc)[source]
Plot the blocking thingy
- Parameters:
eloc (np.array) – values of the local energy
- qmctorch.utils.set_torch_double_precision()[source]
Set the default precision to double for all torch tensors.
- qmctorch.utils.set_torch_single_precision()[source]
Set the default precision to single for all torch tensors.
- class qmctorch.utils.DataSet(*args: Any, **kwargs: Any)[source]
Bases:
Dataset
Creates a torch data set
- Parameters:
data (data {torch.tensor} --) –
- class qmctorch.utils.Loss(*args: Any, **kwargs: Any)[source]
Bases:
Module
Defines the loss to use during the optimization
- Parameters:
used (wf {WaveFunction} -- wave function object) –
- Keyword Arguments:
(default (method {str} -- method to use) – {‘energy’}) (energy, variance, weighted-energy, weighted-variance)
from (clip {bool} -- clip the values that are +/- % sigma away) – the mean (default: {False})
- forward(pos, no_grad=False, deactivate_weight=False)[source]
Computes the loss
- Parameters:
batch (pos {torch.tensor} -- positions of the walkers in that) –
- Keyword Arguments:
loss (no_grad {bool} -- computes the gradient of the) – (default: {False})
- Returns:
torch.tensor, torch.tensor – value of the loss, local energies
- static get_grad_mode(no_grad)[source]
Returns enable_grad or no_grad
- Parameters:
[description] (no_grad {bool} --) –
- class qmctorch.utils.OrthoReg(*args: Any, **kwargs: Any)[source]
Bases:
Module
Add a penalty loss to keep the MO orthogonalized
- Keyword Arguments:
(default (alpha {float} -- strength of the penaly) – {0.1})
- forward(W)[source]
Return the loss : |W x W^T - I|.
- qmctorch.utils.dump_to_hdf5(obj, fname, root_name=None)[source]
Dump the content of an object in a hdf5 file.
- Parameters:
dump (obj {object} -- object to) –
hdf5 (fname {str} -- name of the) –
- Keyword Arguments:
(default (root_name {str} -- root group in the hdf5 file) – {None})
- qmctorch.utils.load_from_hdf5(obj, fname, obj_name)[source]
Load the content of an hdf5 file in an object.
- Parameters:
data (obj {object} -- object where to load the) –
file (fname {str} -- name pf the hdf5) –
hdf5 (obj_name {str} -- name of the root group in the) –
- qmctorch.utils.register_extra_attributes(obj, attr_names)[source]
Register extra attribute to be able to dump them
- Parameters:
attr (obj {object} -- the object where we want to add) –
names (attr_names {list} -- a list of attr) –
- qmctorch.utils.fast_power(x, k, mask0=None, mask2=None)[source]
Computes x**k when k have elements 0, 1, 2
- Parameters:
x (torch.tensor) – input
k (torch.tensor) – exponents
mask0 (torch.tensor) – precomputed mask of the elements of that are 0 (Defaults to None and computed here)
mask2 (torch.tensor) – precomputed mask of the elements of that are 2 (Defaults to None and computed here)
- Returns:
values of x**k
- Return type:
torch.tensor
- class qmctorch.utils.InterpolateMolecularOrbitals(wf)[source]
Bases:
object
Interpolation of the AO using a log grid centered on each atom.
- get_mo_max_index(orb)[source]
Get the index of the highest MO to inlcude in the interpoaltion
- Parameters:
orb (str) – occupied or all
- Raises:
ValueError – if orb not valid
- class qmctorch.utils.InterpolateAtomicOrbitals(wf)[source]
Bases:
object
Interpolation of the AO using a log grid centered on each atom.
- qmctorch.utils.btrace(M)[source]
Computes the trace of batched matrices
- Parameters:
M (torch.tensor) – matrices of size (Na, Nb, … Nx, N, N)
- Returns:
trace of matrices (Na, Nb, … Nx)
- Return type:
torch.tensor
Example
>>> m = torch.rand(100,5,5) >>> tr = btrace(m)
- qmctorch.utils.bdet2(M)[source]
Computes the determinant of batched 2x2 matrices
- Parameters:
M (torch.tensor) – input matrices
- Returns:
determinants of the matrices
- Return type:
torch.tensor
- qmctorch.utils.bproj(M, P)[source]
Project batched marices using P^T M P
- Parameters:
M (torch.tensor) – batched matrices size (…, N, M)
P (torch.tensor) – Porjectors size (…, N, M)
- Returns:
Projected matrices
- Return type:
torch.tensor