tfcompute

Overview

Details

class tensorflowcompute.tfcompute(tf_model_directory, log_filename='tf_manager.log', device=None, bootstrap=None, bootstrap_map=None, _debug_mode=False, _mock_mode=False, write_tensorboard=False, use_xla=False)

TensorFlow Computations for HTF.

Parameters:
  • tf_model_directory – Directory in which to save the TensorFlow model files.
  • log_filename – Name to use for the TensorFlow log file.
  • device – Device (GPU) on which to execute, if a specific one is desired.
  • bootstrap – If set to a directory, will search for and load a previously-saved model file
  • bootstrap_map – A dictionary to be used when bootstrapping, pairing old models’ tensor variable names with new ones. Key is new name, value is older model’s.
  • _deubug_mode – Set this to True to see more debug messages.
  • _mock_mode – Set this to True to run a “fake” calculation of forces that would be passed to the HOOMD simulation without applying them.
  • write_tensorboard – If True, a tensorboard file will be written in the tf_model_directory.
  • use_xla – If True, enables the accelerated linear algebra library in TensorFlow, which can be useful for large and complicated tensor operations.
attach(nlist=None, r_cut=0, save_period=1000, period=1, feed_dict=None, mol_indices=None, batch_size=None)

Attaches the TensorFlow instance to HOOMD. The main method of this class, this method sets up TensorFlow and gets HOOMD ready to interact with it.

Parameters:
  • nlist – The HOOMD neighbor list that will be used as the TensorFlow input.
  • r_cut – Cutoff radius for neighbor listing.
  • save_period – How often to save the TensorFlow data. Period here is measured by how many times the TensorFLow model is updated. See period.
  • period – How many HOOMD steps should pass before updating the TensorFlow model. In combination with save_period, determines how many timesteps pass before TensorFlow saves its data (slow). For example, with a save_period of 200, a period of 4, TensorFlow will write to the tf_model_directory every 800 simulation steps.
  • feed_dict – The dictionary keyed by tensor names and filled with corresponding values. See feed_dict in __init__.
  • mol_indices – Molecule indices for each atom, identifying which molecule each atom belongs to.
  • batch_size – The size of batches if we are using batching. Cannot be used if molecule-wise batching is active.
finish_update(batch_index, batch_frac)

Allow TF to read output and we wait for it to finish.

Parameters:
  • batch_index – index of batch to be processed
  • batch_frac – fractional batch index, i.e. batch_frac = batch_index / len(input)
get_forces_array()

Retrieve forces array as numpy array

get_nlist_array()

Retrieve neighbor list array as numpy array

get_positions_array()

Retrieve positions array as numpy array

get_virial_array()

Retrieve virial array as numpy array

rcut()

Define the cutoff radius used in the neighbor list. Adapted from hoomd/md/pair.py

scalar4_vec_to_np(array)

Convert from scalar4 dtype to numpy array :param array: the scalar4 array to be processed

set_reference_forces(*forces)

Sets the HOOMD reference forces to be used by TensorFlow. See C++ comments in TensorFlowCompute.h

shutdown_tf()

Shut down the TensorFlow instance.