Beispiel #1
0
 def __init__(self, n_hidden=100, init='glorot_uniform'):
   self.n_hidden = n_hidden
   self.init = initializations.get(init)
   Wz = self.init([n_hidden, n_hidden])
   Wr = self.init([n_hidden, n_hidden])
   Wh = self.init([n_hidden, n_hidden])
   Uz = self.init([n_hidden, n_hidden])
   Ur = self.init([n_hidden, n_hidden])
   Uh = self.init([n_hidden, n_hidden])
   bz = model_ops.zeros(shape=(n_hidden,))
   br = model_ops.zeros(shape=(n_hidden,))
   bh = model_ops.zeros(shape=(n_hidden,))
   self.trainable_weights = [Wz, Wr, Wh, Uz, Ur, Uh, bz, br, bh]
Beispiel #2
0
 def __init__(self, n_hidden=100, init='glorot_uniform'):
   self.n_hidden = n_hidden
   self.init = initializations.get(init)
   Wz = self.init([n_hidden, n_hidden])
   Wr = self.init([n_hidden, n_hidden])
   Wh = self.init([n_hidden, n_hidden])
   Uz = self.init([n_hidden, n_hidden])
   Ur = self.init([n_hidden, n_hidden])
   Uh = self.init([n_hidden, n_hidden])
   bz = model_ops.zeros(shape=(n_hidden,))
   br = model_ops.zeros(shape=(n_hidden,))
   bh = model_ops.zeros(shape=(n_hidden,))
   self.trainable_weights = [Wz, Wr, Wh, Uz, Ur, Uh, bz, br, bh]
Beispiel #3
0
  def build(self):
    self.W_cf = self.init([self.n_embedding, self.n_hidden])
    self.W_df = self.init([self.n_distance, self.n_hidden])
    self.W_fc = self.init([self.n_hidden, self.n_embedding])
    self.b_cf = model_ops.zeros(shape=[
        self.n_hidden,
    ])
    self.b_df = model_ops.zeros(shape=[
        self.n_hidden,
    ])

    self.trainable_weights = [
        self.W_cf, self.W_df, self.W_fc, self.b_cf, self.b_df
    ]
Beispiel #4
0
  def build(self):
    self.W_cf = self.init([self.n_embedding, self.n_hidden])
    self.W_df = self.init([self.n_distance, self.n_hidden])
    self.W_fc = self.init([self.n_hidden, self.n_embedding])
    self.b_cf = model_ops.zeros(shape=[
        self.n_hidden,
    ])
    self.b_df = model_ops.zeros(shape=[
        self.n_hidden,
    ])

    self.trainable_weights = [
        self.W_cf, self.W_df, self.W_fc, self.b_cf, self.b_df
    ]
Beispiel #5
0
  def _build(self):
    self.W = self.init(shape=(self.num_nodes, self.num_nodes))
    self.b = model_ops.zeros(shape=[
        self.num_nodes,
    ])

    self.trainable_weights = [self.W, self.b]
Beispiel #6
0
    def _build(self):
        self.W = self.init(shape=(self.num_nodes, self.num_nodes))
        self.b = model_ops.zeros(shape=[
            self.num_nodes,
        ])

        self.trainable_weights = [self.W, self.b]
Beispiel #7
0
  def build(self):
    self.W_list = []
    self.b_list = []
    prev_layer_size = self.n_embedding
    for i, layer_size in enumerate(self.layer_sizes):
      self.W_list.append(self.init([prev_layer_size, layer_size]))
      self.b_list.append(model_ops.zeros(shape=[
          layer_size,
      ]))
      prev_layer_size = layer_size
    self.W_list.append(self.init([prev_layer_size, self.n_outputs]))
    self.b_list.append(model_ops.zeros(shape=[
        self.n_outputs,
    ]))
    prev_layer_size = self.n_outputs

    self.trainable_weights = self.W_list + self.b_list
Beispiel #8
0
  def build(self):
    self.W_list = []
    self.b_list = []
    prev_layer_size = self.n_embedding
    for i, layer_size in enumerate(self.layer_sizes):
      self.W_list.append(self.init([prev_layer_size, layer_size]))
      self.b_list.append(model_ops.zeros(shape=[
          layer_size,
      ]))
      prev_layer_size = layer_size
    self.W_list.append(self.init([prev_layer_size, self.n_outputs]))
    self.b_list.append(model_ops.zeros(shape=[
        self.n_outputs,
    ]))
    prev_layer_size = self.n_outputs

    self.trainable_weights = self.W_list + self.b_list
Beispiel #9
0
 def build(self):
   if self.gaussian_expand:
     self.W = self.init([self.n_input * 11, self.n_input])
     self.b = model_ops.zeros(shape=[
         self.n_input,
     ])
     self.trainable_weights = self.W + self.b
   else:
     self.trainable_weights = None
Beispiel #10
0
 def build(self):
   if self.gaussian_expand:
     self.W = self.init([self.n_input * 11, self.n_input])
     self.b = model_ops.zeros(shape=[
         self.n_input,
     ])
     self.trainable_weights = self.W + self.b
   else:
     self.trainable_weights = None
Beispiel #11
0
  def build(self):
    """"Construct internal trainable weights.
        """

    self.W_list = []
    self.b_list = []
    prev_layer_size = self.n_graph_feat
    for layer_size in self.layer_sizes:
      self.W_list.append(self.init([prev_layer_size, layer_size]))
      self.b_list.append(model_ops.zeros(shape=[
          layer_size,
      ]))
      prev_layer_size = layer_size
    self.W_list.append(self.init([prev_layer_size, self.n_outputs]))
    self.b_list.append(model_ops.zeros(shape=[
        self.n_outputs,
    ]))

    self.trainable_weights = self.W_list + self.b_list
Beispiel #12
0
  def build(self):
    """"Construct internal trainable weights.
        """

    self.W_list = []
    self.b_list = []
    prev_layer_size = self.n_graph_feat
    for layer_size in self.layer_sizes:
      self.W_list.append(self.init([prev_layer_size, layer_size]))
      self.b_list.append(model_ops.zeros(shape=[
          layer_size,
      ]))
      prev_layer_size = layer_size
    self.W_list.append(self.init([prev_layer_size, self.n_outputs]))
    self.b_list.append(model_ops.zeros(shape=[
        self.n_outputs,
    ]))

    self.trainable_weights = self.W_list + self.b_list
Beispiel #13
0
 def __init__(self,
              pair_features,
              n_pair_features=8,
              n_hidden=100,
              init='glorot_uniform'):
   self.n_pair_features = n_pair_features
   self.n_hidden = n_hidden
   self.init = initializations.get(init)
   W = self.init([n_pair_features, n_hidden * n_hidden])
   b = model_ops.zeros(shape=(n_hidden * n_hidden,))
   self.A = tf.nn.xw_plus_b(pair_features, W, b)
   self.A = tf.reshape(self.A, (-1, n_hidden, n_hidden))
   self.trainable_weights = [W, b]
Beispiel #14
0
 def __init__(self,
              pair_features,
              n_pair_features=8,
              n_hidden=100,
              init='glorot_uniform'):
   self.n_pair_features = n_pair_features
   self.n_hidden = n_hidden
   self.init = initializations.get(init)
   W = self.init([n_pair_features, n_hidden * n_hidden])
   b = model_ops.zeros(shape=(n_hidden * n_hidden,))
   self.A = tf.nn.xw_plus_b(pair_features, W, b)
   self.A = tf.reshape(self.A, (-1, n_hidden, n_hidden))
   self.trainable_weights = [W, b]
Beispiel #15
0
    def create_tensor(self, in_layers=None, set_tensors=True, **kwargs):
        """ Generate Radial Symmetry Function """
        init_fn = initializations.get(self.init)  # Set weight initialization
        if self.activation == 'ani':
            activation_fn = self.ani_activate
        else:
            activation_fn = activations.get(self.activation)
        if in_layers is None:
            in_layers = self.in_layers
        in_layers = convert_to_layers(in_layers)

        inputs = in_layers[0].out_tensor
        atom_numbers = in_layers[1].out_tensor
        in_channels = inputs.get_shape().as_list()[-1]
        self.W = init_fn(
            [len(self.atom_number_cases), in_channels, self.out_channels])

        self.b = model_ops.zeros(
            (len(self.atom_number_cases), self.out_channels))
        outputs = []
        for i, atom_case in enumerate(self.atom_number_cases):
            # optimization to allow for tensorcontraction/broadcasted mmul
            # using a reshape trick. Note that the np and tf matmul behavior
            # differs when dealing with broadcasts

            a = inputs  # (i,j,k)
            b = self.W[i, :, :]  # (k, l)

            ai = tf.shape(a)[0]
            aj = tf.shape(a)[1]
            ak = tf.shape(a)[2]
            bl = tf.shape(b)[1]

            output = activation_fn(
                tf.reshape(tf.matmul(tf.reshape(a, [ai * aj, ak]), b),
                           [ai, aj, bl]) + self.b[i, :])

            mask = 1 - tf.cast(tf.cast(atom_numbers - atom_case, tf.bool),
                               tf.float32)
            output = tf.reshape(output * tf.expand_dims(mask, 2),
                                (-1, self.max_atoms, self.out_channels))
            outputs.append(output)
        out_tensor = tf.add_n(outputs)

        if set_tensors:
            self.out_tensor = out_tensor

        return out_tensor
  def create_tensor(self, in_layers=None, set_tensors=True, **kwargs):
    """ Generate Radial Symmetry Function """
    init_fn = initializations.get(self.init)  # Set weight initialization
    if self.activation == 'ani':
      activation_fn = self.ani_activate
    else:
      activation_fn = activations.get(self.activation)
    if in_layers is None:
      in_layers = self.in_layers
    in_layers = convert_to_layers(in_layers)

    inputs = in_layers[0].out_tensor
    atom_numbers = in_layers[1].out_tensor
    in_channels = inputs.get_shape().as_list()[-1]
    self.W = init_fn(
        [len(self.atom_number_cases), in_channels, self.out_channels])

    self.b = model_ops.zeros((len(self.atom_number_cases), self.out_channels))
    outputs = []
    for i, atom_case in enumerate(self.atom_number_cases):
      # optimization to allow for tensorcontraction/broadcasted mmul
      # using a reshape trick. Note that the np and tf matmul behavior
      # differs when dealing with broadcasts

      a = inputs  # (i,j,k)
      b = self.W[i, :, :]  # (k, l)

      ai = tf.shape(a)[0]
      aj = tf.shape(a)[1]
      ak = tf.shape(a)[2]
      bl = tf.shape(b)[1]

      output = activation_fn(
          tf.reshape(tf.matmul(tf.reshape(a, [ai * aj, ak]), b), [ai, aj, bl]) +
          self.b[i, :])

      mask = 1 - tf.cast(tf.cast(atom_numbers - atom_case, tf.bool), tf.float32)
      output = tf.reshape(output * tf.expand_dims(mask, 2),
                          (-1, self.max_atoms, self.out_channels))
      outputs.append(output)
    out_tensor = tf.add_n(outputs)

    if set_tensors:
      self.out_tensor = out_tensor

    return out_tensor
Beispiel #17
0
    def build(self):
        """ Construct internal trainable weights.

        TODO(rbharath): Need to make this not set instance variables to
        follow style in other layers.
        """
        init = initializations.get(self.init)  # Set weight initialization

        self.W_AA = init([self.n_atom_input_feat, self.n_hidden_AA])
        self.b_AA = model_ops.zeros(shape=[
            self.n_hidden_AA,
        ])

        self.W_PA = init([self.n_pair_input_feat, self.n_hidden_PA])
        self.b_PA = model_ops.zeros(shape=[
            self.n_hidden_PA,
        ])

        self.W_A = init([self.n_hidden_A, self.n_atom_output_feat])
        self.b_A = model_ops.zeros(shape=[
            self.n_atom_output_feat,
        ])

        self.trainable_weights = [
            self.W_AA, self.b_AA, self.W_PA, self.b_PA, self.W_A, self.b_A
        ]
        if self.update_pair:
            self.W_AP = init([self.n_atom_input_feat * 2, self.n_hidden_AP])
            self.b_AP = model_ops.zeros(shape=[
                self.n_hidden_AP,
            ])

            self.W_PP = init([self.n_pair_input_feat, self.n_hidden_PP])
            self.b_PP = model_ops.zeros(shape=[
                self.n_hidden_PP,
            ])

            self.W_P = init([self.n_hidden_P, self.n_pair_output_feat])
            self.b_P = model_ops.zeros(shape=[
                self.n_pair_output_feat,
            ])

            self.trainable_weights.extend([
                self.W_AP, self.b_AP, self.W_PP, self.b_PP, self.W_P, self.b_P
            ])
Beispiel #18
0
  def build(self):
    """ Construct internal trainable weights.

        TODO(rbharath): Need to make this not set instance variables to
        follow style in other layers.
        """
    init = initializations.get(self.init)  # Set weight initialization

    self.W_AA = init([self.n_atom_input_feat, self.n_hidden_AA])
    self.b_AA = model_ops.zeros(shape=[
        self.n_hidden_AA,
    ])

    self.W_PA = init([self.n_pair_input_feat, self.n_hidden_PA])
    self.b_PA = model_ops.zeros(shape=[
        self.n_hidden_PA,
    ])

    self.W_A = init([self.n_hidden_A, self.n_atom_output_feat])
    self.b_A = model_ops.zeros(shape=[
        self.n_atom_output_feat,
    ])

    self.trainable_weights = [
        self.W_AA, self.b_AA, self.W_PA, self.b_PA, self.W_A, self.b_A
    ]
    if self.update_pair:
      self.W_AP = init([self.n_atom_input_feat * 2, self.n_hidden_AP])
      self.b_AP = model_ops.zeros(shape=[
          self.n_hidden_AP,
      ])

      self.W_PP = init([self.n_pair_input_feat, self.n_hidden_PP])
      self.b_PP = model_ops.zeros(shape=[
          self.n_hidden_PP,
      ])

      self.W_P = init([self.n_hidden_P, self.n_pair_output_feat])
      self.b_P = model_ops.zeros(shape=[
          self.n_pair_output_feat,
      ])

      self.trainable_weights.extend(
          [self.W_AP, self.b_AP, self.W_PP, self.b_PP, self.W_P, self.b_P])