Model

This module is designed to include machine-learning models for interpolating energies and forces from either an atom-centered or image-centered fingerprint description.

Model

class amp.model.LossFunction(energy_coefficient=1.0, force_coefficient=0.04, charge_coefficient=10.0, convergence=None, parallel=None, overfit=0.0, raise_ConvergenceOccurred=True, log_losses=True, d=None, weight_duplicates=False, maxiter=100000, nft_ids=None)[source]

Bases: object

Basic loss function, which can be used by the model.get_loss method which is required in standard model classes.

If parallel is None, it will pull it from the model itself. Only use this keyword to override the model’s specification.

Also has parallelization methods built in.

See self.default_parameters for the default values of parameters specified as None.

Parameters:
  • energy_coefficient (float) – Coefficient of the energy contribution in the loss function.

  • charge_coefficient (float) – Coefficient of the charge contribution in the loss function.

  • force_coefficient (float) – Coefficient of the force contribution in the loss function. Can set to None as shortcut to turn off force training.

  • convergence (dict) – Dictionary of keys and values defining convergence. Keys are ‘energy_rmse’, ‘energy_maxresid’, ‘force_rmse’, ‘force_maxresid’, ‘charge_rmse’, and ‘charge_maxresid’. If ‘force_rmse’ and ‘force_maxresid’ are both set to None, force training is turned off and force_coefficient is set to None.

  • parallel (dict) – Parallel configuration dictionary. Will pull from model itself if not specified.

  • overfit (float) – Multiplier of atomic neural network weights norm penalty term in the loss function.

  • raise_ConvergenceOccurred (bool) – If True will raise convergence notice.

  • log_losses (bool) – If True will log the loss function value in the log file else will not.

  • d (None or float) – If d is None, both loss function and its gradient are calculated analytically. If d is a float, then gradient of the loss function is calculated by perturbing each parameter plus/minus d.

  • weight_duplicates (bool) – If multiple identical images are present in the training set, whether to weight them as such in the loss function. E.g., if False, any duplicate images will only count as a single image, if True, then a triplicate image will weight the same as having that image three times. Default is False.

  • maxiter (int) – Terminate loss function optimization at a give step/epoch.

  • nft_ids (list of length-2 tuples) – If nft_ids is not None, it should have the form of [(hash_id_0, index_of_atom_0), (hash_id_1, index_of_atom_1), …]. Only force_loss on the atom of given index is included in the image with the corresponding hash id.

attach_model(model, images=None, fingerprints=None, fingerprintprimes=None, charge_fp_appends=None, charge_fpprime_appends=None, log=None)[source]

Attach the model to be used to the loss function. hashed images, fingerprints, fingerprintprimes, and charge training purposed fingerpint sets can optionally be specified; this is typically for use in parallelization.

Parameters:
  • model (object) – Class representing the regression model.

  • images (dict) – Dictionary of hashed images to train on.

  • fingerprints (dict) – Fingerprints of images to train on.

  • fingerprintprimes (dict) – Fingerprint derivatives of images to train on.

  • charge_fp_appends (dict) – charge fingerprints of images to train on.

  • charge_fpprime_appends (dict) – charge fingerprint derivatives of images to train on.

calculate_loss(parametervector, lossprime)[source]

Method that calculates the loss, derivative of the loss with respect to parameters (if requested), and max_residual.

This is the reference (pure-python) version and should not be called in typical runs; the fortran version should be much faster.

Parameters:
  • parametervector (list) – Parameters of the regression model in the form of a list.

  • lossprime (bool) – If True, will calculate and return dloss_dparameters, else will only return zero for dloss_dparameters.

check_convergence(loss, energy_loss, force_loss, charge_loss, energy_maxresid, force_maxresid, charge_maxresid)[source]

Check convergence

Checks to see whether convergence is met; if it is, raises ConvergenceException to stop the optimizer.

Parameters:
  • loss (float) – Value of the loss function.

  • energy_loss (float) – Value of the energy contribution of the loss function.

  • force_loss (float) – Value of the force contribution of the loss function.

  • charge_loss (float) – Value of the charge contribution of the loss function.

  • energy_maxresid (float) – Maximum energy residual.

  • force_maxresid (float) – Maximum force residual.

  • charge_maxresid (float) – Maximum charge residual.

default_parameters = {'convergence': {'charge_maxresid': None, 'charge_rmse': 0.0005, 'energy_maxresid': None, 'energy_rmse': 0.001, 'force_maxresid': None, 'force_rmse': None}}
get_loss(parametervector, lossprime)[source]

Returns the current value of the loss function for a given set of parameters, or, if the energy is less than the energy_tol raises a ConvergenceException.

Parameters:
  • parametervector (list) – Parameters of the regression model in the form of a list.

  • lossprime (bool) – If True, will calculate and return dloss_dparameters, else will only return zero for dloss_dparameters.

process_parallels(vector, server, n_pids)[source]
Parameters:
  • vector (list) – Parameters of the regression model in the form of a list.

  • server (object) – Master session of parallel processing.

  • processes (list of objects) – Worker sessions for parallel processing.

reset()[source]

Reset the step counter for a fresh training attempt. Parallel workers do not need to restart; they receive fresh parameter vectors each step.

class amp.model.Model[source]

Bases: object

Class that includes common methods between different models.

calculate_dEnergy_dParameters(fingerprints)[source]

Calculates a list of floats corresponding to the derivative of model-predicted energy of an image with respect to model parameters.

Parameters:

fingerprints (list) – List of fingerprints of an image, one per atom.

calculate_dForces_dParameters(fingerprints, fingerprintprimes)[source]

Calculates an array of floats corresponding to the derivative of model-predicted atomic forces of an image with respect to model parameters.

Parameters:
  • fingerprints (list) – List of fingerprints of an image, one per atom.

  • fingerprintprimes (dict) – Dictionary of fingerprint derivatives, where the key is a tuple with (index, symbol, neighbor_index, neighbor_symbol, direction).

calculate_dgcEnergy_dParameters(fingerprints, wf, qfp_append)[source]

Calculates a list of floats corresponding to the derivative of model-predicted energy of an image in charge learning scheme with respect to model parameters.

Parameters:
  • fingerprints (list) – List of fingerprints of an image, one per atom.

  • wf (float) – Workfunction of an image.

  • qfp_append (list) – List of charge fingerprint of an image, one per atom.

calculate_dgcForces_dParameters(fingerprints, fingerprintprimes, wf, qfp_append, qfpprime_append)[source]

Calculates an array of floats corresponding to the derivative of model-predicted atomic forces of an image in charge learning scheme with respect to model parameters.

Parameters:
  • fingerprints (list) – List of fingerprints of an image, one per atom.

  • fingerprintprimes (dict) – Dictionary of fingerprint derivatives, where the key is a tuple with (index, symbol, neighbor_index, neighbor_symbol, direction).

  • wf (float) – Workfunction of an image.

  • qfp_append (list) – List of charge fingerprint of an image, one per atom.

  • qfpprime_append (list) – List of charge fingerprint derivatives, one per atom.

calculate_energy(fingerprints)[source]

Calculates the model-predicted energy for an image, based on its fingerprint.

Parameters:

fingerprints (list) – List of fingerprints of an image, one per atom.

calculate_forces(fingerprints, fingerprintprimes)[source]

Calculates the model-predicted forces for an image, based on derivatives of fingerprints.

Parameters:
  • fingerprints (list) – List of fingerprints of an image, one per atom.

  • fingerprintprimes (dict) – Dictionary of fingerprint derivatives, where the key is a tuple with (index, symbol, neighbor_index, neighbor_symbol, direction).

calculate_gc_energy(fingerprints, wf, qfp_append)[source]

Calculates the model-predicted energy for an image, based on its fingerprint and the charge-learning scheme.

Parameters:
  • fingerprints (list) – List of fingerprints of an image, one per atom.

  • wf (float) – Workfunction of an image.

  • qfp_append (list) – List of charge fingerprint of an image, one per atom.

calculate_gc_forces(fingerprints, fingerprintprimes, wf, qfp_append, qfpprime_append)[source]

Calculates the model-predicted forces for an image, based on derivatives of fingerprints and the charge learning scheme.

Parameters:
  • fingerprints (list) – List of fingerprints of an image, one per atom.

  • fingerprintprimes (dict) – Dictionary of fingerprint derivatives, where the key is a tuple with (index, symbol, neighbor_index, neighbor_symbol, direction).

  • wf (float) – Workfunction of an image.

  • qfp_append (list) – List of charge fingerprint of an image, one per atom.

  • qfpprime_append (list) – List of charge fingerprint derivatives, one per atom.

calculate_numerical_dEnergy_dParameters(fingerprints, d=1e-05)[source]
Evaluates dEnergy_dParameters using finite

difference in charge learning scheme.

This will trigger two calls to calculate_gc_energy(), with each parameter perturbed plus/minus d.

Parameters:
  • fingerprints (list) – List of fingerprints of an image, one per atom.

  • d (float) – The amount of perturbation in each parameter.

calculate_numerical_dForces_dParameters(fingerprints, fingerprintprimes, d=1e-05)[source]

Evaluates dForces_dParameters using finite difference. This will trigger two calls to calculate_forces(), with each parameter perturbed plus/minus d.

Parameters:
  • fingerprints (list) – List of fingerprints of an image, one per atom.

  • fingerprintprimes (dict) – Dictionary of fingerprint derivatives, where the key is a tuple with (index, symbol, neighbor_index, neighbor_symbol, direction).

  • d (float) – The amount of perturbation in each parameter.

calculate_numerical_dgcEnergy_dParameters(fingerprints, wf, qfp_append, d=1e-05)[source]

Evaluates dEnergy_dParameters using finite difference.

This will trigger two calls to calculate_energy(), with each parameter perturbed plus/minus d.

Parameters:
  • fingerprints (list) – List of fingerprints of an image, one per atom.

  • wf (float) – Workfunction of an image.

  • qfp_append (list) – List of charge fingerprint of an image, one per atom.

  • d (float) – The amount of perturbation in each parameter.

calculate_numerical_dgcForces_dParameters(fingerprints, fingerprintprimes, wf, qfp_append, qfpprime_append, d=1e-05)[source]

Evaluates dForces_dParameters using finite difference in charge learning scheme. This will trigger two calls to calculate_gc_forces(), with each parameter perturbed plus/minus d.

Parameters:
  • fingerprints (list) – List of fingerprints of an image, one per atom.

  • fingerprintprimes (dict) – Dictionary of fingerprint derivatives, where the key is a tuple with (index, symbol, neighbor_index, neighbor_symbol, direction).

  • wf (float) – Workfunction of an image.

  • qfp_append (list) – List of charge fingerprint of an image, one per atom.

  • qfpprime_append (list) – List of charge fingerprint derivatives, one per atom.

  • d (float) – The amount of perturbation in each parameter.

property log

Method to set or get a logger. Should be an instance of amp.utilities.Logger.

Parameters:

log (Logger object) – Write function at which to log data. Note this must be a callable function.

tostring()[source]

Returns an evaluatable representation of the calculator that can be used to re-establish the calculator.

amp.model.calculate_charge_fingerprints_range(fp, images, qfp_append)[source]

Calculates the range for the fingerprints corresponding to images, stored in fp and charge fingerprints stored in qfp_append. The fp is a fingerprints object with the fingerprints data stored in a dictionary-like object at fp.fingerprints. (Typically this is a .utilties.Data structure.) images is a hashed dictionary of atoms for which to consider the range. The qfp_append is a dictionary whose keys are the hashed ids of images.

In image-centered mode, returns an array of (min, max) values for each fingerprint. In atom-centered mode, returns a dictionary of such arrays, one per element.

amp.model.calculate_charge_fp(z_position, image_eta, interface, image_potential)[source]
amp.model.calculate_charge_fpprime(z_position, image_eta, interface, image_potential)[source]
amp.model.calculate_fingerprints_range(fp, images)[source]

Calculates the range for the fingerprints corresponding to images, stored in fp. fp is a fingerprints object with the fingerprints data stored in a dictionary-like object at fp.fingerprints. (Typically this is a .utilties.Data structure.) images is a hashed dictionary of atoms for which to consider the range.

In image-centered mode, returns an array of (min, max) values for each fingerprint. In atom-centered mode, returns a dictionary of such arrays, one per element.

amp.model.ravel_data(train_forces, train_charges, mode, images, fingerprints, fingerprintprimes, qfp_append, qfpprime_append, weight_duplicates)[source]

Reshapes data of images into lists.

Parameters:
  • train_forces (bool) – Determining whether forces are also trained or not.

  • train_charges (bool) – Determining whether to use charge learning scheme.

  • mode (str) – Can be either ‘atom-centered’ or ‘image-centered’.

  • images (dict) – Dictionary of hashed images, from amp.utilities.hash_images.

  • fingerprints (dict) – Dictionary with images hashs as keys and the corresponding fingerprints as values.

  • fingerprintprimes (dict) – Dictionary with images hashs as keys and the corresponding fingerprint derivatives as values.

  • qfp_append (dict) – Dictionary with images hashs as keys and the corresponding charge fingerprints as values.

  • qfpprime_append (dict) – Dictionary with images hashs as keys and the corresponding charge fingerprint derivatives as values.

  • weight_duplicates (bool) – If multiple identical images are present in the training set, whether to weight them as such in the loss function. E.g., if False, any duplicate images will only count as a single image, if True, then a triplicate image will weight the same as having that image three times. Default is False.

amp.model.send_data_to_fortran(_fmodules, energy_coefficient, force_coefficient, charge_coefficient, overfit, train_forces, train_charges, num_atoms, num_images, actual_energies, actual_forces, actual_charges, image_wfs, atomic_positions, num_images_atoms, atomic_numbers, raveled_fingerprints, raveled_charge_fingerprints, num_neighbors, raveled_neighborlists, raveled_fingerprintprimes, raveled_charge_fingerprintprimes, model, d, image_weights, is_nft, nft_indices)[source]

Function that sends images data to fortran code. Is used just once on each core.

Neural Network

class amp.model.neuralnetwork.NeuralNetwork(hiddenlayers=(5, 5), activation='tanh', weights=None, scalings=None, fprange=None, mode=None, version=None, regressor=None, lossfunction=None, fortran=True, checkpoints=100, randomseed=None, prescale=False)[source]

Bases: Model

Class that implements a basic feed-forward neural network.

Parameters:
  • hiddenlayers (dict) –

    Dictionary of chemical element symbols and architectures of their corresponding hidden layers of the conventional neural network. Number of nodes of last layer is always one corresponding to energy. However, number of nodes of first layer is equal to three times number of atoms in the system in the case of no descriptor, and is equal to length of symmetry functions of the descriptor. Can be fed using tuples as:

    >>> hiddenlayers = (3, 2,)
    

    for example, in which a neural network with two hidden layers, the first one having three nodes and the second one having two nodes is assigned (to the whole atomic system in the no descriptor case, and to each chemical element in the atom-centered mode). When setting only one hidden layer, the dictionary can be fed as:

    >>> hiddenlayers = (3,)
    

    In the atom-centered mode, neural network for each species can be assigned seperately, as:

    >>> hiddenlayers = {"O":(3,5), "Au":(5,6)}
    

    for example.

  • activation (str) – Assigns the type of activation funtion. “linear” refers to linear function, “tanh” refers to tanh function, and “sigmoid” refers to sigmoid function.

  • weights (dict) – In the atom-centered mode, keys correspond to chemical elements and values are dictionaries with layer keys and network weight two dimensional arrays as values. Arrays are set up to connect node i in the previous layer with node j in the current layer with indices w[i,j]. The last value for index i corresponds to bias. In the case of no descriptor, keys correspond to layers and values are two dimensional arrays of network weight. If weights is not given, arrays will be randomly generated.

  • scalings (dict) – In the case of no descriptor, keys are “intercept” and “slope” and values are real numbers. In the fingerprinting scheme, keys correspond to chemical elements and values are dictionaries with “intercept” and “slope” keys and real number values. If scalings is None, it will be guessed based on the input range of energies.

  • fprange (dict) –

    Range of fingerprints of each chemical species. Should be fed as a dictionary of chemical species and a list of minimum and maximun, e.g.:

    >>> fprange={"Pd": [0.31, 0.59], "O":[0.56, 0.72]}
    

  • mode (str) – Can be either ‘atom-centered’ or ‘image-centered’.

  • version (object) – Version of this class.

  • regressor (object) – Regressor object for finding best fit model parameters, e.g. by loss function optimization via amp.regression.Regressor.

  • lossfunction (object) – Loss function object.

  • prescale (bool) – If True, will start with a simple single-parameter (per element) regression to find the best-fit values for the scaling parameters. This portion of the code is not parallelized, but can greatly improve the likelihood of and path to convergence, as this is the most sensitive parameter. Ignored if scalings are explicitly supplied.

  • fortran (bool) – Can optionally shut off fortran, primarily for debugging.

  • checkpoints (int) – Frequency with which to save parameter checkpoints upon training. E.g., 100 saves a checkpoint on each 100th training step. By default only the last checkpoint is retained; to keep all checkpoints make the frequency negative instead of positive. Specify None for no checkpoints. Note that checkpoints can be used to resume a training run simply by resubmitting the same script; if a checkpoint file is found it will be used.

  • randomseed (None or int) – Seed to use in random number generator for making initial guess of training parameters. You should only set this if you want a script to always generate the same “random” initial parameters. This primarily useful for unit tests or benchmarking.

  • note: (..) – Dimensions of weight two dimensional arrays should be consistent: with hiddenlayers.

Raises:

RuntimeError, NotImplementedError

calculate_atomic_energy(afp, index, symbol)[source]

Given input to the neural network, output (which corresponds to energy) is calculated about the specified atom. The sum of these for all atoms is the total energy (in atom-centered mode).

Parameters:
  • afp (list) – Atomic fingerprints in the form of a list to be used as input to the neural network.

  • index (int) – Index of the atom for which atomic energy is calculated (only used in the atom-centered mode).

  • symbol (str) – Symbol of the atom for which atomic energy is calculated (only used in the atom-centered mode).

Returns:

Energy.

Return type:

float

calculate_dAtomicEnergy_dParameters(afp, index=None, symbol=None)[source]

Returns the derivative of energy square error with respect to variables.

Parameters:
  • afp (list) – Atomic fingerprints in the form of a list to be used as input to the neural network.

  • index (int) – Index of the atom for which atomic energy is calculated (only used in the atom-centered mode)

  • symbol (str) – Symbol of the atom for which atomic energy is calculated (only used in the atom-centered mode)

Returns:

The value of the derivative of energy square error with respect to variables.

Return type:

list of float

calculate_dForce_dParameters(afp, derafp, direction, nindex=None, nsymbol=None)[source]

Returns the derivative of force square error with respect to variables.

Parameters:
  • afp (list) – Atomic fingerprints in the form of a list to be used as input to the neural network.

  • derafp (list) – Derivatives of atomic fingerprints in the form of a list to be used as input to the neural network.

  • direction (int) – Direction of force.

  • nindex (int) – Index of the atom at which force is acting. (only used in the atom-centered mode)

  • nsymbol (str) – Symbol of the atom at which force is acting. (only used in the atom-centered mode)

Returns:

The value of the derivative of force square error with respect to variables.

Return type:

list of float

calculate_force(afp, derafp, direction, nindex=None, nsymbol=None)[source]

Given derivative of input to the neural network, derivative of output (which corresponds to forces) is calculated.

Parameters:
  • afp (list) – Atomic fingerprints in the form of a list to be used as input to the neural network.

  • derafp (list) – Derivatives of atomic fingerprints in the form of a list to be used as input to the neural network.

  • direction (int) – Direction of force.

  • nindex (int) – Index of the atom at which force is acting. (only used in the atom-centered mode)

  • nsymbol (str) – Symbol of the atom at which force is acting. (only used in the atom-centered mode)

Returns:

Force.

Return type:

float

fit(trainingimages, descriptor, log, parallel, only_setup=False)[source]

Fit the model parameters such that the fingerprints can be used to describe the energies in trainingimages. log is the logging object. descriptor is a descriptor object, as would be in calc.descriptor.

Parameters:
  • trainingimages (dict) – Hashed dictionary of training images.

  • descriptor (object) – Class representing local atomic environment.

  • log (Logger object) – Write function at which to log data. Note this must be a callable function.

  • parallel (dict) – Parallel configuration dictionary. Takes the same form as in amp.Amp.

  • only_setup (bool) – only_setup is primarily for debugging. It initializes all variables but skips the last line of starting the regressor.

property forcetraining

Returns true if forcetraining is turned on (as determined by examining the convergence criteria in the loss function), else returns False.

get_loss(vector, lossprime)[source]

Method to be called by the regression master.

Takes one and only one input, a vector of parameters. Returns one output, the value of the loss (cost) function.

Parameters:

vector (list) – Parameters of the regression model in the form of a list.

property lossfunction

Allows the user to set a custom loss function.

For example, >>> from amp.model import LossFunction >>> lossfxn = LossFunction(energy_tol=0.0001) >>> calc.model.lossfunction = lossfxn

Parameters:

lossfunction (object) – Loss function object, if at all desired by the user.

prescale_intercepts(trainingimages)[source]

Calculates a reasonable guess for the per-atom energy, by regressing a one-parameter-per-element model (per-atom energies), and uses this as the scaling energy. This is a reasonably inefficient residual-minimization technique, but doesn’t typically bottleneck the code. The slopes are not explicitly calculated, and take as w

randomize(trainingimages=None, weights=True, scalings=True, seed=None)[source]

Randomizes the model parameters (i.e., re-initializes them); this is typically used just before training.

Parameters:
  • trainingimages (list) – List of ASE atoms objects that are being trained. This is only needed if scalings is True.

  • weights (bool) – If False, do not randomize weights.

  • scalings (bool) – If False, do not randomize scalings.

  • seed (None or int) – Seed to use in random number generator for making initial guess of training parameters. You should only set this if you want a script to always generate the same “random” initial parameters. This primarily useful for unit tests or benchmarking.

property vector

Access to get or set the model parameters (weights, scaling for each network) as a single vector, useful in particular for regression.

Parameters:

vector (list) – Parameters of the regression model in the form of a list.

class amp.model.neuralnetwork.NodePlot(calc)[source]

Bases: object

Creates plots to visualize the output of the nodes in the neural networks.

initialize with a calculator that has parameters; e.g. a trained calculator or else one in which fit has been called with the setup_only flag turned on.

Call with the ‘plot’ method, which takes as argment a list of images

plot(images, filename='nodeplot.pdf')[source]

Creates a plot of the output of each node, as a violin plot.

class amp.model.neuralnetwork.OffsetCalculator(scalings)[source]

Bases: object

A calculator in which energy is only a sum of one-body atomic terms, with an energy per element type. This is used to calculate the scaling parameters.

get_potential_energy(atoms)[source]

Calculate a crude potential energy.

class amp.model.neuralnetwork.Raveler(weights, scalings)[source]

Bases: object

Class to ravel and unravel variable values into a single vector.

This is used for feeding into the optimizer. Feed in a list of dictionaries to initialize the shape of the transformation. Note no data is saved in the class; each time it is used it is passed either the dictionaries or vector. The dictionaries for initialization should be two levels deep.

weights, scalings are the variables to ravel and unravel

to_dicts(vector)[source]

Puts the vector back into weights and scalings dictionaries of the form initialized. vector must have same length as the output of unravel.

to_vector(weights, scalings)[source]

Puts the weights and scalings embedded dictionaries into a single vector and returns it. The dictionaries need to have the identical structure to those it was initialized with.

amp.model.neuralnetwork.calculate_dOutputs_dInputs(parameters, derafp, outputs, nsymbol)[source]

Calculates the derivative of the neural network nodes with respect to the inputs.

Parameters:
  • parameters (dict) – ASE dictionary object.

  • derafp (list) – Derivatives of atomic fingerprints in the form of a list to be used as input to the neural network.

  • outputs (dict) – Outputs of neural network nodes.

  • nsymbol (str) – Symbol of the atom for which atomic energy is calculated (only used in the atom-centered mode)

Returns:

Derivatives of outputs of neural network nodes w.r.t. inputs.

Return type:

dict

amp.model.neuralnetwork.calculate_nodal_outputs(parameters, afp, symbol)[source]

Given input to the neural network, output (which corresponds to energy) is calculated about the specified atom. The sum of these for all atoms is the total energy (in atom-centered mode).

Parameters:
  • parameters (dict) – ASE dictionary object.

  • afp (list) – Atomic fingerprints in the form of a list to be used as input to the neural network.

  • symbol (str) – Symbol of the atom for which atomic energy is calculated (only used in the atom-centered mode)

Returns:

Outputs of neural network nodes

Return type:

dict

amp.model.neuralnetwork.calculate_ohat_D_delta(parameters, outputs, W)[source]

Calculates extra matrices ohat, D, delta needed in mathematical manipulations.

Notations are consistent with those of ‘Rojas, R. Neural Networks - A Systematic Introduction. Springer-Verlag, Berlin, first edition 1996’

Parameters:
  • parameters (dict) – ASE dictionary object.

  • outputs (dict) – Outputs of neural network nodes.

  • W (dict) – The same as weight dictionary, but the last rows associated with biases are deleted in W.

amp.model.neuralnetwork.get_initial_scalings(images, activation, elements=None, seed=None)[source]

Generates initial scaling matrices, such that the range of activation is scaled to the range of actual energies.

imagesdict

ASE atoms objects (the training set).

activation: str

Assigns the type of activation funtion. “linear” refers to linear function, “tanh” refers to tanh function, and “sigmoid” refers to sigmoid function.

elements: list of str

List of atom symbols; used in the atom-centered mode only.

Returns:

scalings

Return type:

float

amp.model.neuralnetwork.get_random_weights(hiddenlayers, activation, len_of_fps=None, no_of_atoms=None, seed=None)[source]

Generates random weight arrays from variables.

hiddenlayers: dict

Dictionary of chemical element symbols and architectures of their corresponding hidden layers of the conventional neural network. Number of nodes of last layer is always one corresponding to energy. However, number of nodes of first layer is equal to three times number of atoms in the system in the case of no descriptor, and is equal to length of symmetry functions in the atom-centered mode. Can be fed as:

>>> hiddenlayers = (3, 2,)

for example, in which a neural network with two hidden layers, the first one having three nodes and the second one having two nodes is assigned (to the whole atomic system in the case of no descriptor, and to each chemical element in the atom-centered mode). In the atom-centered mode, neural network for each species can be assigned seperately, as:

>>> hiddenlayers = {"O":(3,5), "Au":(5,6)}

for example.

activationstr

Assigns the type of activation funtion. “linear” refers to linear function, “tanh” refers to tanh function, and “sigmoid” refers to sigmoid function.

len_of_fpsdict

Length of fingerprints of each element, e.g:

>>> len_of_fps={"O": 20, "Pd":20}
no_of_atomsint

Number of atoms in atomic systems; used only in the case of no descriptor.

seedNone or int

Seed to use in random number generator for making initial guess of training parameters. You should only set this if you want a script to always generate the same “random” initial parameters. This primarily useful for unit tests or benchmarking.

Returns:

weights

Return type:

float

Tensorflow Neural Network

A work in progress, this module amp.model.tflow uses Google’s TensorFlow package to implement a neural network, which may provide GPU acceleration and other advantages.