Skip to content

class QOConstants(pydantic.BaseModel)#

Parent classes#

class pydantic.BaseModel

Introduction#

class QOConstants contains physical constants used in loss function during neural network learning process. It inherits from the pydantic's BaseModel class to guarantee field type compatibility and their correct filling without manual implementation of all checks.

Example construction with manual values set
from tensorflow import keras

from nneve.quantum_oscillator import QOConstants, QOTracker

constants = QOConstants(
    optimizer=keras.optimizers.Adam(),
    tracker=QOTracker(),
    k=4.0,
    mass=1.0,
    x_left=-6.0,
    x_right=6.0,
    fb=1.0,
    sample_size=500,
    v_f=1.0,
    v_lambda=1.0,
    v_drive=1.0,
)

Instance attributes#

Note

  • Attributes are mutable
  • Arbitrary types are allowed to be used as attribute values

optimizer: keras.optimizers.Optimizer#

1
2
3
4
5
6
7
Field(
        default=keras.optimizers.Adam(
            learning_rate=DEFAULT_LEARNING_RATE,
            beta_1=DEFAULT_BETA_1,
            beta_2=DEFAULT_BETA_2,
        )
    )

Argument required for compiling a Keras model.

tracker: QOTracker#

Field(default_factory=QOTracker)

QOTracker class, responsible for collecting metrics during neural network learning process.

k: float#

Field(default=4.0)

Oscillator force constant.

mass: float#

Field(default=1.0)

Oscillator mass used in \([\frac{\hbar^2}{2m}\frac{\partial^2}{\partial x^2} + V(x)]\psi(x) = E\psi(x)\)

x_left: float#

Field(default=-6.0)

Left boundary condition of our quantum harmonic oscillator model.

x_right: float#

Field(default=6.0)

Right boundary condition of our quantum harmonic oscillator model.

fb: float#

Field(default=0.0)

Constant boundary value for boundary conditions.

sample_size: int#

Field(default=1000)

Size of our current learning sample (number of points on the linear space).

v_f: int#

Field(default=1.0)

Multiplier of regularization function which prevents our network from learning trivial eigenfunctions.

v_lambda: int#

Field(default=1.0)

Multiplier of regularization function which prevents our network from learning trivial eigenvalues.

v_drive: int#

Field(default=1.0)

Multiplier of regularization function which motivates our network to scan for higher values of eigenvalues.

Instance methods#

def sample(self) -> tf.Tensor#

Generates tensor of sample_size float32 values in range from x_left to x_right for network learning process.

Returns#

type description
tf.Tensor float32 tensor in shape (sample_size, 1)