qadence 1.7.7__tar.gz → 1.7.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {qadence-1.7.7 → qadence-1.7.8}/PKG-INFO +3 -3
- {qadence-1.7.7 → qadence-1.7.8}/pyproject.toml +3 -3
- {qadence-1.7.7 → qadence-1.7.8}/qadence/ml_tools/config.py +14 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/ml_tools/constructors.py +7 -2
- {qadence-1.7.7 → qadence-1.7.8}/qadence/ml_tools/train_grad.py +39 -7
- {qadence-1.7.7 → qadence-1.7.8}/.coveragerc +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/.github/ISSUE_TEMPLATE/bug-report.yml +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/.github/ISSUE_TEMPLATE/config.yml +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/.github/ISSUE_TEMPLATE/new-feature.yml +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/.github/workflows/build_docs.yml +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/.github/workflows/lint.yml +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/.github/workflows/test_all.yml +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/.github/workflows/test_examples.yml +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/.github/workflows/test_fast.yml +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/.gitignore +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/.pre-commit-config.yaml +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/LICENSE +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/MANIFEST.in +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/README.md +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/mkdocs.yml +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/__init__.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/analog/__init__.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/analog/addressing.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/analog/constants.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/analog/device.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/analog/hamiltonian_terms.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/analog/parse_analog.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/backend.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/backends/__init__.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/backends/api.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/backends/braket/__init__.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/backends/braket/backend.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/backends/braket/config.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/backends/braket/convert_ops.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/backends/gpsr.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/backends/horqrux/__init__.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/backends/horqrux/backend.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/backends/horqrux/config.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/backends/horqrux/convert_ops.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/backends/jax_utils.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/backends/pulser/__init__.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/backends/pulser/backend.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/backends/pulser/channels.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/backends/pulser/cloud.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/backends/pulser/config.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/backends/pulser/convert_ops.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/backends/pulser/devices.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/backends/pulser/pulses.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/backends/pulser/waveforms.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/backends/pyqtorch/__init__.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/backends/pyqtorch/backend.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/backends/pyqtorch/config.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/backends/pyqtorch/convert_ops.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/backends/utils.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/blocks/__init__.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/blocks/abstract.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/blocks/analog.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/blocks/block_to_tensor.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/blocks/composite.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/blocks/embedding.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/blocks/manipulate.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/blocks/matrix.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/blocks/primitive.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/blocks/utils.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/circuit.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/constructors/__init__.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/constructors/ansatze.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/constructors/daqc/__init__.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/constructors/daqc/daqc.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/constructors/daqc/gen_parser.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/constructors/daqc/utils.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/constructors/feature_maps.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/constructors/hamiltonians.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/constructors/iia.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/constructors/qft.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/constructors/rydberg_feature_maps.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/constructors/rydberg_hea.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/constructors/utils.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/decompose.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/divergences.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/draw/__init__.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/draw/assets/dark/measurement.png +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/draw/assets/dark/measurement.svg +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/draw/assets/light/measurement.png +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/draw/assets/light/measurement.svg +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/draw/themes.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/draw/utils.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/draw/vizbackend.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/engines/__init__.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/engines/differentiable_backend.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/engines/jax/__init__.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/engines/jax/differentiable_backend.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/engines/jax/differentiable_expectation.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/engines/torch/__init__.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/engines/torch/differentiable_backend.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/engines/torch/differentiable_expectation.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/exceptions/__init__.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/exceptions/exceptions.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/execution.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/extensions.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/libs.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/log_config.yaml +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/logger.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/measurements/__init__.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/measurements/protocols.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/measurements/samples.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/measurements/shadow.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/measurements/tomography.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/measurements/utils.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/mitigations/__init__.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/mitigations/analog_zne.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/mitigations/protocols.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/mitigations/readout.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/ml_tools/__init__.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/ml_tools/data.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/ml_tools/models.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/ml_tools/optimize_step.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/ml_tools/parameters.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/ml_tools/printing.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/ml_tools/saveload.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/ml_tools/tensors.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/ml_tools/train_no_grad.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/ml_tools/utils.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/model.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/noise/__init__.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/noise/protocols.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/noise/readout.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/operations/__init__.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/operations/analog.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/operations/control_ops.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/operations/ham_evo.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/operations/parametric.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/operations/primitive.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/overlap.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/parameters.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/protocols.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/py.typed +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/qubit_support.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/register.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/serial_expr_grammar.peg +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/serialization.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/states.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/transpile/__init__.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/transpile/apply_fn.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/transpile/block.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/transpile/circuit.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/transpile/digitalize.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/transpile/flatten.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/transpile/invert.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/transpile/transpile.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/types.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/qadence/utils.py +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/renovate.json +0 -0
- {qadence-1.7.7 → qadence-1.7.8}/setup.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: qadence
|
3
|
-
Version: 1.7.
|
3
|
+
Version: 1.7.8
|
4
4
|
Summary: Pasqal interface for circuit-based quantum computing SDKs
|
5
5
|
Author-email: Aleksander Wennersteen <aleksander.wennersteen@pasqal.com>, Gert-Jan Both <gert-jan.both@pasqal.com>, Niklas Heim <niklas.heim@pasqal.com>, Mario Dagrada <mario.dagrada@pasqal.com>, Vincent Elfving <vincent.elfving@pasqal.com>, Dominik Seitz <dominik.seitz@pasqal.com>, Roland Guichard <roland.guichard@pasqal.com>, "Joao P. Moutinho" <joao.moutinho@pasqal.com>, Vytautas Abramavicius <vytautas.abramavicius@pasqal.com>, Gergana Velikova <gergana.velikova@pasqal.com>, Eduardo Maschio <eduardo.maschio@pasqal.com>, Smit Chaudhary <smit.chaudhary@pasqal.com>, Ignacio Fernández Graña <ignacio.fernandez-grana@pasqal.com>, Charles Moussa <charles.moussa@pasqal.com>, Giorgio Tosti Balducci <giorgio.tosti-balducci@pasqal.com>, Daniele Cucurachi <daniele.cucurachi@pasqal.com>
|
6
6
|
License: Apache 2.0
|
@@ -22,7 +22,7 @@ Requires-Dist: matplotlib
|
|
22
22
|
Requires-Dist: nevergrad
|
23
23
|
Requires-Dist: numpy
|
24
24
|
Requires-Dist: openfermion
|
25
|
-
Requires-Dist: pyqtorch==1.4.
|
25
|
+
Requires-Dist: pyqtorch==1.4.9
|
26
26
|
Requires-Dist: pyyaml
|
27
27
|
Requires-Dist: rich
|
28
28
|
Requires-Dist: scipy
|
@@ -57,7 +57,7 @@ Requires-Dist: mlflow; extra == 'mlflow'
|
|
57
57
|
Provides-Extra: protocols
|
58
58
|
Requires-Dist: qadence-protocols; extra == 'protocols'
|
59
59
|
Provides-Extra: pulser
|
60
|
-
Requires-Dist: pasqal-cloud==0.
|
60
|
+
Requires-Dist: pasqal-cloud==0.12.2; extra == 'pulser'
|
61
61
|
Requires-Dist: pulser-core==0.19.0; extra == 'pulser'
|
62
62
|
Requires-Dist: pulser-simulation==0.19.0; extra == 'pulser'
|
63
63
|
Provides-Extra: visualization
|
@@ -26,7 +26,7 @@ authors = [
|
|
26
26
|
]
|
27
27
|
requires-python = ">=3.9"
|
28
28
|
license = { text = "Apache 2.0" }
|
29
|
-
version = "1.7.
|
29
|
+
version = "1.7.8"
|
30
30
|
classifiers = [
|
31
31
|
"License :: OSI Approved :: Apache Software License",
|
32
32
|
"Programming Language :: Python",
|
@@ -50,7 +50,7 @@ dependencies = [
|
|
50
50
|
"jsonschema",
|
51
51
|
"nevergrad",
|
52
52
|
"scipy",
|
53
|
-
"pyqtorch==1.4.
|
53
|
+
"pyqtorch==1.4.9",
|
54
54
|
"pyyaml",
|
55
55
|
"matplotlib",
|
56
56
|
"Arpeggio==2.0.2",
|
@@ -64,7 +64,7 @@ allow-ambiguous-features = true
|
|
64
64
|
pulser = [
|
65
65
|
"pulser-core==0.19.0",
|
66
66
|
"pulser-simulation==0.19.0",
|
67
|
-
"pasqal-cloud==0.
|
67
|
+
"pasqal-cloud==0.12.2",
|
68
68
|
]
|
69
69
|
braket = ["amazon-braket-sdk<1.71.2"]
|
70
70
|
visualization = [
|
@@ -447,6 +447,13 @@ class FeatureMapConfig:
|
|
447
447
|
assign `t, x = xs[:,0], xs[:,1]`.
|
448
448
|
"""
|
449
449
|
|
450
|
+
tag: str | None = None
|
451
|
+
"""
|
452
|
+
String to indicate the name tag of the feature map.
|
453
|
+
|
454
|
+
Defaults to None, in which case no tag will be applied.
|
455
|
+
"""
|
456
|
+
|
450
457
|
def __post_init__(self) -> None:
|
451
458
|
if self.multivariate_strategy == MultivariateStrategy.PARALLEL and self.num_features > 1:
|
452
459
|
assert (
|
@@ -606,6 +613,13 @@ class AnsatzConfig:
|
|
606
613
|
param_prefix: str = "theta"
|
607
614
|
"""The base bame of the variational parameter."""
|
608
615
|
|
616
|
+
tag: str | None = None
|
617
|
+
"""
|
618
|
+
String to indicate the name tag of the ansatz.
|
619
|
+
|
620
|
+
Defaults to None, in which case no tag will be applied.
|
621
|
+
"""
|
622
|
+
|
609
623
|
def __post_init__(self) -> None:
|
610
624
|
if self.ansatz_type == AnsatzType.IIA:
|
611
625
|
assert (
|
@@ -7,7 +7,7 @@ from qadence.backend import BackendConfiguration
|
|
7
7
|
from qadence.blocks import chain, kron
|
8
8
|
from qadence.blocks.abstract import AbstractBlock
|
9
9
|
from qadence.blocks.composite import ChainBlock, KronBlock
|
10
|
-
from qadence.blocks.utils import add
|
10
|
+
from qadence.blocks.utils import add, tag
|
11
11
|
from qadence.circuit import QuantumCircuit
|
12
12
|
from qadence.constructors import (
|
13
13
|
analog_feature_map,
|
@@ -774,10 +774,15 @@ def build_qnn_from_configs(
|
|
774
774
|
fm_blocks=fm_blocks,
|
775
775
|
ansatz_config=ansatz_config,
|
776
776
|
)
|
777
|
+
if isinstance(fm_config.tag, str):
|
778
|
+
tag(full_fm, fm_config.tag)
|
777
779
|
inputs = fm_config.inputs
|
778
780
|
blocks.append(full_fm)
|
779
781
|
|
780
|
-
|
782
|
+
ansatz = create_ansatz(register=register, config=ansatz_config)
|
783
|
+
if isinstance(ansatz_config.tag, str):
|
784
|
+
tag(ansatz, ansatz_config.tag)
|
785
|
+
blocks.append(ansatz)
|
781
786
|
|
782
787
|
circ = QuantumCircuit(register, *blocks)
|
783
788
|
|
@@ -213,21 +213,48 @@ def train(
|
|
213
213
|
]
|
214
214
|
|
215
215
|
# writing metrics
|
216
|
+
# we specify two writers,
|
217
|
+
# to write at evaluation time and before evaluation
|
216
218
|
callbacks += [
|
217
219
|
Callback(
|
218
220
|
lambda opt_res: write_tracker(
|
219
221
|
writer,
|
220
222
|
opt_res.loss,
|
221
223
|
opt_res.metrics,
|
222
|
-
opt_res.iteration,
|
224
|
+
opt_res.iteration - 1, # loss returned be optimized_step is at -1
|
225
|
+
tracking_tool=config.tracking_tool,
|
226
|
+
),
|
227
|
+
called_every=config.write_every,
|
228
|
+
call_end_epoch=True,
|
229
|
+
),
|
230
|
+
Callback(
|
231
|
+
lambda opt_res: write_tracker(
|
232
|
+
writer,
|
233
|
+
opt_res.loss,
|
234
|
+
opt_res.metrics,
|
235
|
+
opt_res.iteration, # after_opt we match the right loss function
|
223
236
|
tracking_tool=config.tracking_tool,
|
224
237
|
),
|
225
238
|
called_every=config.write_every,
|
226
|
-
|
239
|
+
call_end_epoch=False,
|
227
240
|
call_after_opt=True,
|
228
|
-
|
229
|
-
)
|
241
|
+
),
|
230
242
|
]
|
243
|
+
if perform_val:
|
244
|
+
callbacks += [
|
245
|
+
Callback(
|
246
|
+
lambda opt_res: write_tracker(
|
247
|
+
writer,
|
248
|
+
None,
|
249
|
+
opt_res.metrics,
|
250
|
+
opt_res.iteration,
|
251
|
+
tracking_tool=config.tracking_tool,
|
252
|
+
),
|
253
|
+
called_every=config.write_every,
|
254
|
+
call_before_opt=True,
|
255
|
+
call_during_eval=True,
|
256
|
+
)
|
257
|
+
]
|
231
258
|
|
232
259
|
# checkpointing
|
233
260
|
if config.folder and config.checkpoint_every > 0 and not config.checkpoint_best_only:
|
@@ -332,17 +359,22 @@ def train(
|
|
332
359
|
logger.info("Terminating training gracefully after the current iteration.")
|
333
360
|
break
|
334
361
|
|
335
|
-
#
|
362
|
+
# For handling printing/writing the last training loss
|
336
363
|
# as optimize_step does not give the loss value at the last iteration
|
337
364
|
try:
|
338
365
|
loss, metrics, *_ = next_loss_iter(dl_iter)
|
339
|
-
if
|
340
|
-
|
366
|
+
if isinstance(loss, Tensor):
|
367
|
+
loss = loss.item()
|
368
|
+
if perform_val:
|
369
|
+
# reputting val_loss as already evaluated before
|
370
|
+
metrics["val_loss"] = val_loss
|
371
|
+
print_metrics(loss, metrics, iteration)
|
341
372
|
|
342
373
|
except KeyboardInterrupt:
|
343
374
|
logger.info("Terminating training gracefully after the current iteration.")
|
344
375
|
|
345
376
|
# Final callbacks, by default checkpointing and writing
|
377
|
+
opt_result = OptimizeResult(iteration, model, optimizer, loss, metrics)
|
346
378
|
callbacks_after_opt = [callback for callback in callbacks if callback.call_after_opt]
|
347
379
|
run_callbacks(callbacks_after_opt, opt_result, is_last_iteration=True)
|
348
380
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|