class_docstr: Create atomic convolution neural network potential for binding energy.
  
  Example:
  
  >>> B = 10 # batch_size
  >>> N_1 = 6 # frag1_n_atoms
  >>> N_2 = 6 # frag2_n_atoms
  >>> N = 12 # complex_n_atoms
  >>> M = 6 # n_neighbors
  >>> n_tasks = 1
  >>> C_1 = np.zeros((N_1, 3))
  >>> C_2 = np.zeros((N_2, 3))
  >>> C = np.zeros((N, 3))
  >>> NL_1 = {}
  >>> for i in range(n_atoms): NL_1[i] = [0 for m in range(M)]
  >>> NL_2 = {}
  >>> for i in range(n_atoms): NL_2[i] = [0 for m in range(M)]
  >>> NL = {}
  >>> for i in range(n_atoms): NL[i] = [0 for m in range(M)]
  >>> Z_1 = np.zeros((N))
  >>> Z_2 = np.zeros((N))
  >>> Z = np.zeros((N))
  >>> X = [(C_1, NL_1, Z_1, C_2, NL_2, Z_2, C, NL, Z) for i in range(B)]
  >>> y = np.zeros(B, n_tasks)
  >>> w = np.zeros(B, n_tasks)
  >>> ids = np.zeros(B,)
  >>> dataset = dc.data.NumpyDataset(X, y, w, ids)
  >>> rp = [[12.0, 0.0, 0.04]]
  >>> at = None
  >>> model = TensorflowFragmentRegressor(n_tasks, rp, at, N_1, N_2, N, M)
  >>> model.fit(dataset)
class_docstr_tok: ["Create","atomic","convolution","neural","network","potential","for","binding","energy",".","Example",":",">",">",">","B","=","10","#","batch_size",">",">",">","N_1","=","6","#","frag1_n_atoms",">",">",">","N_2","=","6","#","frag2_n_atoms",">",">",">","N","=","12","#","complex_n_atoms",">",">",">","M","=","6","#","n_neighbors",">",">",">","n_tasks","=","1",">",">",">","C_1","=","np.zeros","(","(","N_1",",","3",")",")",">",">",">","C_2","=","np.zeros","(","(","N_2",",","3",")",")",">",">",">","C","=","np.zeros","(","(","N",",","3",")",")",">",">",">","NL_1","=","{","}",">",">",">","for","i","in","range","(","n_atoms",")",":","NL_1","[","i","]","=","[","0","for","m","in","range","(","M",")","]",">",">",">","NL_2","=","{","}",">",">",">","for","i","in","range","(","n_atoms",")",":","NL_2","[","i","]","=","[","0","for","m","in","range","(","M",")","]",">",">",">","NL","=","{","}",">",">",">","for","i","in","range","(","n_atoms",")",":","NL","[","i","]","=","[","0","for","m","in","range","(","M",")","]",">",">",">","Z_1","=","np.zeros","(","(","N",")",")",">",">",">","Z_2","=","np.zeros","(","(","N",")",")",">",">",">","Z","=","np.zeros","(","(","N",")",")",">",">",">","X","=","[","(","C_1",",","NL_1",",","Z_1",",","C_2",",","NL_2",",","Z_2",",","C",",","NL",",","Z",")","for","i","in","range","(","B",")","]",">",">",">","y","=","np.zeros","(","B",",","n_tasks",")",">",">",">","w","=","np.zeros","(","B",",","n_tasks",")",">",">",">","ids","=","np.zeros","(","B",",",")",">",">",">","dataset","=","dc.data.NumpyDataset","(","X",",","y",",","w",",","ids",")",">",">",">","rp","=","[","[","12.0",",","0.0",",","0.04","]","]",">",">",">","at","=","None",">",">",">","model","=","TensorflowFragmentRegressor","(","n_tasks",",","rp",",","at",",","N_1",",","N_2",",","N",",","M",")",">",">",">","model.fit","(","dataset",")"]
code: def build(self, graph, name_scopes, training):
      N = self.complex_num_atoms
      N_1 = self.frag1_num_atoms
      N_2 = self.frag2_num_atoms
      M = self.max_num_neighbors
      B = self.batch_size
      placeholder_scope = TensorflowGraph.get_placeholder_scope(
          graph, name_scopes
      )
      with graph.as_default():
          with placeholder_scope:
              self.frag1_X_placeholder = tf.placeholder(
                  tf.float32,
                  shape=[B, N_1, 3],
                  name="frag1_X_placeholder",
              )
              self.frag1_Z_placeholder = tf.placeholder(
                  tf.float32, shape=[B, N_1], name="frag1_Z_placeholder"
              )
              self.frag1_Nbrs_placeholder = tf.placeholder(
                  tf.int32,
                  shape=[B, N_1, M],
                  name="frag1_Nbrs_placeholder",
              )
              self.frag1_Nbrs_Z_placeholder = tf.placeholder(
                  tf.float32,
                  shape=[B, N_1, M],
                  name="frag1_Nbrs_Z_placeholder",
              )
              self.frag2_X_placeholder = tf.placeholder(
                  tf.float32,
                  shape=[B, N_2, 3],
                  name="frag2_X_placeholder",
              )
              self.frag2_Z_placeholder = tf.placeholder(
                  tf.float32, shape=[B, N_2], name="frag2_Z_placeholder"
              )
              self.frag2_Nbrs_placeholder = tf.placeholder(
                  tf.int32,
                  shape=[B, N_2, M],
                  name="frag2_Nbrs_placeholder",
              )
              self.frag2_Nbrs_Z_placeholder = tf.placeholder(
                  tf.float32,
                  shape=[B, N_2, M],
                  name="frag2_Nbrs_Z_placeholder",
              )
              self.complex_X_placeholder = tf.placeholder(
                  tf.float32,
                  shape=[B, N, 3],
                  name="complex_X_placeholder",
              )
              self.complex_Z_placeholder = tf.placeholder(
                  tf.float32, shape=[B, N], name="complex_Z_placeholder"
              )
              self.complex_Nbrs_placeholder = tf.placeholder(
                  tf.int32,
                  shape=[B, N, M],
                  name="complex_Nbrs_placeholder",
              )
              self.complex_Nbrs_Z_placeholder = tf.placeholder(
                  tf.float32,
                  shape=[B, N, M],
                  name="complex_Nbrs_Z_placeholder",
              )
  
          layer_sizes = self.layer_sizes
          weight_init_stddevs = self.weight_init_stddevs
          bias_init_consts = self.bias_init_consts
          dropouts = self.dropouts
          boxsize = self.boxsize
          conv_layers = self.conv_layers
          lengths_set = {
              len(layer_sizes),
              len(weight_init_stddevs),
              len(bias_init_consts),
              len(dropouts),
          }
          assert (
              len(lengths_set) == 1
          ), "All layer params must have same length."
          num_layers = lengths_set.pop()
          assert num_layers > 0, "Must have some layers defined."
          radial_params = self.radial_params
          atom_types = self.atom_types
  
          frag1_layer = atomicnet_ops.AtomicConvolutionLayer(
              self.frag1_X_placeholder,
              self.frag1_Nbrs_placeholder,
              self.frag1_Nbrs_Z_placeholder,
              atom_types,
              radial_params,
              boxsize,
              B,
              N_1,
              M,
              3,
          )
          for x in range(conv_layers - 1):
              l = int(frag1_layer.get_shape()[-1])
              frag1_layer = atomicnet_ops.AtomicConvolutionLayer(
                  frag1_layer,
                  self.frag1_Nbrs_placeholder,
                  self.frag1_Nbrs_Z_placeholder,
                  atom_types,
                  radial_params,
                  boxsize,
                  B,
                  N_1,
                  M,
                  l,
              )
  
          frag2_layer = atomicnet_ops.AtomicConvolutionLayer(
              self.frag2_X_placeholder,
              self.frag2_Nbrs_placeholder,
              self.frag2_Nbrs_Z_placeholder,
              atom_types,
              radial_params,
              boxsize,
              B,
              N_2,
              M,
              3,
          )
          for x in range(conv_layers - 1):
              l = int(frag2_layer.get_shape()[-1])
              frag2_layer = atomicnet_ops.AtomicConvolutionLayer(
                  frag2_layer,
                  self.frag2_Nbrs_placeholder,
                  self.frag2_Nbrs_Z_placeholder,
                  atom_types,
                  radial_params,
                  boxsize,
                  B,
                  N_2,
                  M,
                  l,
              )
  
          complex_layer = atomicnet_ops.AtomicConvolutionLayer(
              self.complex_X_placeholder,
              self.complex_Nbrs_placeholder,
              self.complex_Nbrs_Z_placeholder,
              atom_types,
              radial_params,
              boxsize,
              B,
              N,
              M,
              3,
          )
          for x in range(conv_layers - 1):
              l = int(complex_layer.get_shape()[-1])
              complex_layer = atomicnet_ops.AtomicConvolutionLayer(
                  complex_layer,
                  self.complex_Nbrs_placeholder,
                  self.complex_Nbrs_Z_placeholder,
                  atom_types,
                  radial_params,
                  boxsize,
                  B,
                  N,
                  M,
                  l,
              )
  
          weights = []
          biases = []
          output_weights = []
          output_biases = []
          output = []
  
          n_features = int(frag1_layer.get_shape()[-1])
  
          for ind, atomtype in enumerate(atom_types):
              prev_layer_size = n_features
              weights.append([])
              biases.append([])
              output_weights.append([])
              output_biases.append([])
              for i in range(num_layers):
                  weight, bias = atomicnet_ops.InitializeWeightsBiases(
                      prev_layer_size=prev_layer_size,
                      size=layer_sizes[i],
                      weights=tf.truncated_normal(
                          shape=[prev_layer_size, layer_sizes[i]],
                          stddev=weight_init_stddevs[i],
                      ),
                      biases=tf.constant(
                          value=bias_init_consts[i],
                          shape=[layer_sizes[i]],
                      ),
                  )
                  weights[ind].append(weight)
                  biases[ind].append(bias)
                  prev_layer_size = layer_sizes[i]
              weight, bias = atomicnet_ops.InitializeWeightsBiases(
                  prev_layer_size, 1
              )
              output_weights[ind].append(weight)
              output_biases[ind].append(bias)
  
          def atomnet(current_input, atomtype):
              prev_layer = current_input
  
              for i in range(num_layers):
                  layer = atomicnet_ops.AtomicNNLayer(
                      tensor=prev_layer,
                      size=layer_sizes[i],
                      weights=weights[atomtype][i],
                      biases=biases[atomtype][i],
                  )
                  layer = tf.nn.relu(layer)
                  layer = model_ops.dropout(
                      layer, dropouts[i], training
                  )
                  prev_layer = layer
                  prev_layer_size = layer_sizes[i]
  
              output_layer = tf.squeeze(
                  atomicnet_ops.AtomicNNLayer(
                      tensor=prev_layer,
                      size=prev_layer_size,
                      weights=output_weights[atomtype][0],
                      biases=output_biases[atomtype][0],
                  )
              )
  
              return output_layer
  
          frag1_zeros = tf.zeros((B, N_1))
          frag2_zeros = tf.zeros((B, N_2))
          complex_zeros = tf.zeros((B, N))
  
          frag1_atomtype_energy = []
          frag2_atomtype_energy = []
          complex_atomtype_energy = []
  
          for ind, atomtype in enumerate(atom_types):
              frag1_outputs = tf.map_fn(
                  lambda x: atomnet(x, ind), frag1_layer
              )
              frag2_outputs = tf.map_fn(
                  lambda x: atomnet(x, ind), frag2_layer
              )
              complex_outputs = tf.map_fn(
                  lambda x: atomnet(x, ind), complex_layer
              )
  
              cond = tf.equal(self.frag1_Z_placeholder, atomtype)
              frag1_atomtype_energy.append(
                  tf.where(cond, frag1_outputs, frag1_zeros)
              )
              cond = tf.equal(self.frag2_Z_placeholder, atomtype)
              frag2_atomtype_energy.append(
                  tf.where(cond, frag2_outputs, frag2_zeros)
              )
              cond = tf.equal(self.complex_Z_placeholder, atomtype)
              complex_atomtype_energy.append(
                  tf.where(cond, complex_outputs, complex_zeros)
              )
  
          frag1_outputs = tf.add_n(frag1_atomtype_energy)
          frag2_outputs = tf.add_n(frag2_atomtype_energy)
          complex_outputs = tf.add_n(complex_atomtype_energy)
  
          frag1_energy = tf.reduce_sum(frag1_outputs, 1)
          frag2_energy = tf.reduce_sum(frag2_outputs, 1)
          complex_energy = tf.reduce_sum(complex_outputs, 1)
          binding_energy = complex_energy - (
              frag1_energy + frag2_energy
          )
          output.append(binding_energy)
  
      return output
  
file_path: deepchem/contrib/atomicconv/models/atomicnet.py
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import unicode_literals
  import os
  import time
  import numpy
  import tensorflow
  from deepchem.data import DiskDataset
  from deepchem.nn import model_ops
  from legacy import TensorflowGraph, TensorflowGraphModel, TensorflowMultiTaskRegressor
  from deepchem.utils.save import log
  import atomicnet_ops
label_desc: Use image node_id 3 for calling the TensorflowFragmentRegressor obj's underlying member method code with example usage: obj.build(graph, name_scopes, training) and returns: output, output_layer