morphogen.learning.run

Learning from a configuration (morphogen learn): the data of a behaviour at a material point or of a microstructure along random paths, the training of a model, its errors on the validation paths and on named paths that the learned law runs at a material point against the reference, the files of the model and of the data.

A configuration (a mapping, or its learning mapping):

material: {young: 200000, poisson: 0.3, plasticity: {yield: 200, hardening: 10000}}
# or a microstructure: sample: image.npy, materials: {0: ..., 1: ...}, bc: periodic
kinematics: small
data: {paths: 128, segments: 4, increments: 8, amplitude: 0.01, volumetric: 0.2,
       kind: walk, components: null, free: false, rate: null, seed: 0,
       validation: 0.25}
model: {kind: recurrent, hidden: 32, rate: false, seed: 0}  # or kind: standard, internal: 8
# (and strain: logarithmic or green-lagrange, the strain a model sees in finite strains)
training: {epochs: 300, batch: 16, learning_rate: 0.01, final: 0.1, patience: null,
           clip: 1.0, rotate: false, seed: 0}
paths: {cycle: "t=0,1,3 n=8,16 E11=0,0.01,-0.01"}
output: model.npz
save_data: data.npz

data are the options of random_paths() and the fraction of validation paths, model those of make_model() (hidden by default 32, or two layers of 32; internal, the internal variables of a standard model, by default 8; strain, the strain that a model of any kind sees in finite strains: logarithmic, the default, 1/2 ln C and its conjugate stress, or green-lagrange, E and S), training those of train() (rotate: true for isotropic behaviours, cubic for a cubic crystal in its axes). The learned law of a crystal runs in the axes of its material, turned by the orientation of each grain (learned: {model: ..., oriented: true}, the default); the elastic constants and the thermal expansion of a reference material go to its learned material.

morphogen.learning.run.KEYS = ('material', 'sample', 'materials', 'bc', 'kinematics', 'data', 'model', 'training', 'paths', 'output', 'save_data')

The keys of a configuration, and the defaults of its sections

morphogen.learning.run.source_of(cfg: dict, base=None, kinematics: str = 'small') → Callable[source]

The response to a path of the material (a material point) or of the sample (a voxel image, relative to base) of materials (the FFT solver of the paths, under the boundary condition bc) of a configuration.

morphogen.learning.run.reference_elasticity(source) → dict[source]

The elastic constants of a reference material (young, poisson), for the linear problems and the reference media of its learned law, and its thermal expansion; none of a microstructure, nor the constants of a crystal (the learned law then takes those of its initial tangent).

morphogen.learning.run.compare_path(material, respond, path, kinematics: str = 'small', orientation=None) → tuple[source]

The response of the reference respond along path (a LoadingPath), that of the learned material at a material point (turned by orientation, Bunge angles; None where it fails) and their gaps, a row of path_errors().

morphogen.learning.run.path_errors(model, source, paths, kinematics: str = 'small', orientation=None) → dict[source]

The gaps of the learned law of model at a material point to the responses of source (responder()) along named paths (name -> path, its specification or its text): the root mean square of the gaps of the stresses (of the strains) relative to that of the stresses (of the strains) of the reference at the planned steps, and the final stresses of both; infinite gaps and the message where the learned law fails (no solution for the stresses prescribed, after four divisions of a step). The learned material takes the elastic constants of a reference material (else those of its initial tangent); orientation (Bunge angles) turns both, a crystal and its law learned in its axes.

morphogen.learning.run.learn(config: dict, base=None, *, callback=None, model: Model | None = None) → tuple[Model, dict][source]

Learn the behaviour of a configuration (see the module): the trained model (or model, trained further) and the summary of the data, of the training, of its errors and of the files written (relative to base). callback: that of train().