This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
Input
(shape, dtype=tf.float32, **kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
layer_number_dict
= {}¶none_tensors
()¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_tensors
(tensor)¶set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
InputFifoQueue
(shapes, names, capacity=5, **kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
This Queue Is used to allow asynchronous batching of inputs During the fitting process
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
layer_number_dict
= {}¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
InteratomicL2Distances
(N_atoms, M_nbrs, ndim, **kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
Compute (squared) L2 Distances between atoms given neighbors.
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
layer_number_dict
= {}¶none_tensors
()¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_tensors
(tensor)¶set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
IterRefLSTMEmbedding
(n_test, n_support, n_feat, max_depth, **kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
Implements the Iterative Refinement LSTM.
Much like AttnLSTMEmbedding, the IterRefLSTMEmbedding is another type of learnable metric which adjusts “test” and “support.” Recall that “support” is the small amount of data available in a low data machine learning problem, and that “test” is the query. The AttnLSTMEmbedding only modifies the “test” based on the contents of the support. However, the IterRefLSTM modifies both the “support” and “test” based on each other. This allows the learnable metric to be more malleable than that from AttnLSTMEmbeding.
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
create_tensor
(in_layers=None, set_tensors=True, **kwargs)[source]¶Execute this layer on input tensors.
| Parameters: | in_layers (list) – List of two tensors (X, Xp). X should be of shape (n_test, n_feat) and Xp should be of shape (n_support, n_feat) where n_test is the size of the test set, n_support that of the support set, and n_feat is the number of per-atom features. |
|---|---|
| Returns: | Returns two tensors of same shape as input. Namely the output shape will be [(n_test, n_feat), (n_support, n_feat)] |
| Return type: | list |
layer_number_dict
= {}¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
L1Loss
(in_layers=None, **kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
layer_number_dict
= {}¶none_tensors
()¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_tensors
(tensor)¶set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
L2Loss
(in_layers=None, **kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
layer_number_dict
= {}¶none_tensors
()¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_tensors
(tensor)¶set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
LSTMStep
(output_dim, input_dim, init_fn=<function glorot_uniform>, inner_init_fn=<function orthogonal>, activation_fn=<function tanh>, inner_activation_fn=<function hard_sigmoid>, **kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
Layer that performs a single step LSTM update.
This layer performs a single step LSTM update. Note that it is not a full LSTM recurrent network. The LSTMStep layer is useful as a primitive for designing layers such as the AttnLSTMEmbedding or the IterRefLSTMEmbedding below.
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
create_tensor
(in_layers=None, set_tensors=True, **kwargs)[source]¶Execute this layer on input tensors.
| Parameters: | in_layers (list) – List of three tensors (x, h_tm1, c_tm1). h_tm1 means “h, t-1”. |
|---|---|
| Returns: | Returns h, [h + c] |
| Return type: | list |
layer_number_dict
= {}¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
Label
(**kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Input
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
create_pre_q
(batch_size)¶create_tensor
(in_layers=None, set_tensors=True, **kwargs)¶get_pre_q_name
()¶layer_number_dict
= {}¶none_tensors
()¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_tensors
(tensor)¶set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
Layer
(in_layers=None, **kwargs)[source]¶Bases: object
add_summary_to_tg
()[source]¶Can only be called after self.create_layer to gaurentee that name is not none
copy
(replacements={}, variables_graph=None, shared=False)[source]¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
layer_number_dict
= {}¶set_summary
(summary_op, summary_description=None, collections=None)[source]¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_variable_initial_values
(values)[source]¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
LayerSplitter
(output_num, **kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
Layer which takes a tensor from in_tensor[0].out_tensors at an index Only layers which need to output multiple layers set and use the variable self.out_tensors. This is a utility for those special layers which set self.out_tensors to return a layer wrapping a specific tensor in in_layers[0].out_tensors
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
layer_number_dict
= {}¶none_tensors
()¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_tensors
(tensor)¶set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
Log
(in_layers=None, **kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
Compute the natural log of the input.
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
layer_number_dict
= {}¶none_tensors
()¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_tensors
(tensor)¶set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
MaxPool1D
(window_shape=2, strides=1, padding='SAME', **kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
A 1D max pooling on the input.
This layer expects its input to be a three dimensional tensor of shape (batch size, width, # channels).
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
layer_number_dict
= {}¶none_tensors
()¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_tensors
(tensor)¶set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
MaxPool2D
(ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME', **kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
layer_number_dict
= {}¶none_tensors
()¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_tensors
(tensor)¶set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
MaxPool3D
(ksize=[1, 2, 2, 2, 1], strides=[1, 2, 2, 2, 1], padding='SAME', **kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
A 3D max pooling on the input.
This layer expects its input to be a five dimensional tensor of shape (batch size, height, width, depth, # channels).
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
layer_number_dict
= {}¶none_tensors
()¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_tensors
(tensor)¶set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
Multiply
(in_layers=None, **kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
Compute the product of the input layers.
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
layer_number_dict
= {}¶none_tensors
()¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_tensors
(tensor)¶set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
NeighborList
(N_atoms, M_nbrs, ndim, nbr_cutoff, start, stop, **kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
Computes a neighbor-list in Tensorflow.
Neighbor-lists (also called Verlet Lists) are a tool for grouping atoms which are close to each other spatially
TODO(rbharath): Make this layer support batching.
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
compute_nbr_list
(coords)[source]¶Get closest neighbors for atoms.
Needs to handle padding for atoms with no neighbors.
| Parameters: | coords (tf.Tensor) – Shape (N_atoms, ndim) |
|---|---|
| Returns: | nbr_list – Shape (N_atoms, M_nbrs) of atom indices |
| Return type: | tf.Tensor |
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
create_tensor
(in_layers=None, set_tensors=True, **kwargs)[source]¶Creates tensors associated with neighbor-listing.
get_atoms_in_nbrs
(coords, cells)[source]¶Get the atoms in neighboring cells for each cells.
| Returns: | |
|---|---|
| Return type: | atoms_in_nbrs = (N_atoms, n_nbr_cells, M_nbrs) |
get_cells
()[source]¶Returns the locations of all grid points in box.
Suppose start is -10 Angstrom, stop is 10 Angstrom, nbr_cutoff is 1. Then would return a list of length 20^3 whose entries would be [(-10, -10, -10), (-10, -10, -9), ..., (9, 9, 9)]
| Returns: | cells – (n_cells, ndim) shape. |
|---|---|
| Return type: | tf.Tensor |
get_cells_for_atoms
(coords, cells)[source]¶Compute the cells each atom belongs to.
| Parameters: |
|
|---|---|
| Returns: | cells_for_atoms – Shape (N_atoms, 1) |
| Return type: | tf.Tensor |
get_closest_atoms
(coords, cells)[source]¶For each cell, find M_nbrs closest atoms.
Let N_atoms be the number of atoms.
| Parameters: |
|
|---|---|
| Returns: | closest_inds – Of shape (n_cells, M_nbrs) |
| Return type: | tf.Tensor |
get_neighbor_cells
(cells)[source]¶Compute neighbors of cells in grid.
# TODO(rbharath): Do we need to handle periodic boundary conditions properly here? # TODO(rbharath): This doesn’t handle boundaries well. We hard-code # looking for n_nbr_cells neighbors, which isn’t right for boundary cells in # the cube.
| Parameters: | cells (tf.Tensor) – (n_cells, ndim) shape. |
|---|---|
| Returns: | nbr_cells – (n_cells, n_nbr_cells) |
| Return type: | tf.Tensor |
layer_number_dict
= {}¶none_tensors
()¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_tensors
(tensor)¶set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
ReduceMean
(in_layers=None, axis=None, **kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
layer_number_dict
= {}¶none_tensors
()¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_tensors
(tensor)¶set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
ReduceSquareDifference
(in_layers=None, axis=None, **kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
layer_number_dict
= {}¶none_tensors
()¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_tensors
(tensor)¶set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
ReduceSum
(in_layers=None, axis=None, **kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
layer_number_dict
= {}¶none_tensors
()¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_tensors
(tensor)¶set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
Repeat
(n_times, **kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
layer_number_dict
= {}¶none_tensors
()¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_tensors
(tensor)¶set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
Reshape
(shape, **kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
layer_number_dict
= {}¶none_tensors
()¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_tensors
(tensor)¶set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
Bases: deepchem.models.tensorgraph.layers.Layer
A Layer that can share variables with another layer via name scope.
This abstract class can be used as a parent for any layer that implements shared() by means of the variable name scope. It exists to avoid duplicated code.
Can only be called after self.create_layer to gaurentee that name is not none
Create a copy of this layer with different inputs.
Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
Get the shape of this Layer’s output.
deepchem.models.tensorgraph.layers.
SluiceLoss
(**kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
Calculates the loss in a Sluice Network Every input into an AlphaShare should be used in SluiceLoss
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
layer_number_dict
= {}¶none_tensors
()¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_tensors
(tensor)¶set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
SoftMax
(in_layers=None, **kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
layer_number_dict
= {}¶none_tensors
()¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_tensors
(tensor)¶set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
SoftMaxCrossEntropy
(in_layers=None, **kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
layer_number_dict
= {}¶none_tensors
()¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_tensors
(tensor)¶set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
SparseSoftMaxCrossEntropy
(in_layers=None, **kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
layer_number_dict
= {}¶none_tensors
()¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_tensors
(tensor)¶set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
Squeeze
(in_layers=None, squeeze_dims=None, **kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
layer_number_dict
= {}¶none_tensors
()¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_tensors
(tensor)¶set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
Stack
(in_layers=None, axis=1, **kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
layer_number_dict
= {}¶none_tensors
()¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_tensors
(tensor)¶set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
StopGradient
(in_layers=None, **kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
Block the flow of gradients.
This layer copies its input directly to its output, but reports that all gradients of its output are zero. This means, for example, that optimizers will not try to optimize anything “upstream” of this layer.
For example, suppose you have pre-trained a stack of layers to perform a calculation. You want to use the result of that calculation as the input to another layer, but because they are already pre-trained, you do not want the optimizer to modify them. You can wrap the output in a StopGradient layer, then use that as the input to the next layer.
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
layer_number_dict
= {}¶none_tensors
()¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_tensors
(tensor)¶set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
TensorWrapper
(out_tensor, **kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
Used to wrap a tensorflow tensor.
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
layer_number_dict
= {}¶none_tensors
()¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_tensors
(tensor)¶set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
TimeSeriesDense
(out_channels, **kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
layer_number_dict
= {}¶none_tensors
()¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_tensors
(tensor)¶set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
ToFloat
(in_layers=None, **kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
layer_number_dict
= {}¶none_tensors
()¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_tensors
(tensor)¶set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
Transpose
(perm, **kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
layer_number_dict
= {}¶none_tensors
()¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_tensors
(tensor)¶set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
Variable
(initial_value, dtype=tf.float32, **kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
Output a trainable value.
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
layer_number_dict
= {}¶none_tensors
()¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_tensors
(tensor)¶set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
VinaFreeEnergy
(N_atoms, M_nbrs, ndim, nbr_cutoff, start, stop, stddev=0.3, Nrot=1, **kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
Computes free-energy as defined by Autodock Vina.
TODO(rbharath): Make this layer support batching.
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
create_tensor
(in_layers=None, set_tensors=True, **kwargs)[source]¶| Parameters: |
|
|---|---|
| Returns: | layer – The free energy of each complex in batch |
| Return type: | tf.Tensor of shape (B) |
layer_number_dict
= {}¶none_tensors
()¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_tensors
(tensor)¶set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
WeightDecay
(penalty, penalty_type, **kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
Apply a weight decay penalty.
The input should be the loss value. This layer adds a weight decay penalty to it and outputs the sum.
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
layer_number_dict
= {}¶none_tensors
()¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_tensors
(tensor)¶set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
WeightedError
(in_layers=None, **kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
layer_number_dict
= {}¶none_tensors
()¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_tensors
(tensor)¶set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
WeightedLinearCombo
(in_layers=None, std=0.3, **kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Layer
Computes a weighted linear combination of input layers, with the weights defined by trainable variables.
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
layer_number_dict
= {}¶none_tensors
()¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_tensors
(tensor)¶set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
deepchem.models.tensorgraph.layers.
Weights
(**kwargs)[source]¶Bases: deepchem.models.tensorgraph.layers.Input
add_summary_to_tg
()¶Can only be called after self.create_layer to gaurentee that name is not none
clone
(in_layers)¶Create a copy of this layer with different inputs.
copy
(replacements={}, variables_graph=None, shared=False)¶Duplicate this Layer and all its inputs.
This is similar to clone(), but instead of only cloning one layer, it also recursively calls copy() on all of this layer’s inputs to clone the entire hierarchy of layers. In the process, you can optionally tell it to replace particular layers with specific existing ones. For example, you can clone a stack of layers, while connecting the topmost ones to different inputs.
For example, consider a stack of dense layers that depend on an input:
>>> input = Feature(shape=(None, 100))
>>> dense1 = Dense(100, in_layers=input)
>>> dense2 = Dense(100, in_layers=dense1)
>>> dense3 = Dense(100, in_layers=dense2)
The following will clone all three dense layers, but not the input layer. Instead, the input to the first dense layer will be a different layer specified in the replacements map.
>>> replacements = {input: new_input}
>>> dense3_copy = dense3.copy(replacements)
| Parameters: |
|
|---|
create_pre_q
(batch_size)¶create_tensor
(in_layers=None, set_tensors=True, **kwargs)¶get_pre_q_name
()¶layer_number_dict
= {}¶none_tensors
()¶set_summary
(summary_op, summary_description=None, collections=None)¶Annotates a tensor with a tf.summary operation Collects data from self.out_tensor by default but can be changed by setting self.tb_input to another tensor in create_tensor
| Parameters: |
|
|---|
set_tensors
(tensor)¶set_variable_initial_values
(values)¶Set the initial values of all variables.
This takes a list, which contains the initial values to use for all of this layer’s values (in the same order retured by TensorGraph.get_layer_variables()). When this layer is used in a TensorGraph, it will automatically initialize each variable to the value specified in the list. Note that some layers also have separate mechanisms for specifying variable initializers; this method overrides them. The purpose of this method is to let a Layer object represent a pre-trained layer, complete with trained values for its variables.
shape
¶Get the shape of this Layer’s output.
Create a copy of this layer that shares variables with it.
This is similar to clone(), but where clone() creates two independent layers, this causes the layers to share variables with each other.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: |
Ops for graph construction.
Large amounts of code borrowed from Keras. Will try to incorporate into DeepChem properly.
deepchem.models.tensorgraph.model_ops.
add_bias
(tensor, init=None, name=None)[source]¶Add a bias term to a tensor.
| Parameters: | |
|---|---|
| Returns: | A biased tensor with the same shape as the input tensor. |
| Return type: | tf.Tensor |
deepchem.models.tensorgraph.model_ops.
binary_crossentropy
(output, target, from_logits=False)[source]¶Binary crossentropy between an output tensor and a target tensor.
output: A tensor. target: A tensor with the same shape as output. from_logits: Whether output is expected to be a logits tensor.
By default, we consider that output encodes a probability distribution.
deepchem.models.tensorgraph.model_ops.
cast_to_floatx
(x)[source]¶Cast a Numpy array to the default Keras float type.
| Parameters: | x (Numpy array.) – |
|---|---|
| Returns: | |
| Return type: | The same Numpy array, cast to its new type. |
deepchem.models.tensorgraph.model_ops.
categorical_crossentropy
(output, target, from_logits=False)[source]¶Categorical crossentropy between an output tensor and a target tensor, where the target is a tensor of the same shape as the output.
# TODO(rbharath): Should probably swap this over to tf mode.
deepchem.models.tensorgraph.model_ops.
clip
(x, min_value, max_value)[source]¶Element-wise value clipping.
| Returns: | |
|---|---|
| Return type: | A tensor. |
deepchem.models.tensorgraph.model_ops.
concatenate
(tensors, axis=-1)[source]¶Concatenates a list of tensors alongside the specified axis.
| Returns: | |
|---|---|
| Return type: | A tensor. |
deepchem.models.tensorgraph.model_ops.
cosine_distances
(test, support)[source]¶Computes pairwise cosine distances between provided tensors
| Parameters: |
|
|---|---|
| Returns: | Of shape (n_test, n_support) |
| Return type: | tf.Tensor |
deepchem.models.tensorgraph.model_ops.
dot
(x, y)[source]¶Multiplies 2 tensors (and/or variables) and returns a tensor. When attempting to multiply a ND tensor with a ND tensor, it reproduces the Theano behavior. (e.g. (2, 3).(4, 3, 5) = (2, 4, 5))
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: | A tensor, dot product of x and y. |
deepchem.models.tensorgraph.model_ops.
dropout
(tensor, dropout_prob, training=True, training_only=True)[source]¶Random dropout.
This implementation supports “always-on” dropout (training_only=False), which can be used to calculate model uncertainty. See Gal and Ghahramani, http://arxiv.org/abs/1506.02142.
| Parameters: | |
|---|---|
| Returns: | A tensor with the same shape as the input tensor. |
| Return type: | tf.Tensor |
deepchem.models.tensorgraph.model_ops.
elu
(x, alpha=1.0)[source]¶Exponential linear unit.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: | A tensor. |
deepchem.models.tensorgraph.model_ops.
epsilon
()[source]¶Returns the value of the fuzz factor used in numeric expressions.
| Returns: | |
|---|---|
| Return type: | A float. |
deepchem.models.tensorgraph.model_ops.
euclidean_distance
(test, support, max_dist_sq=20)[source]¶Computes pairwise euclidean distances between provided tensors
TODO(rbharath): BROKEN! THIS DOESN’T WORK!
| Parameters: |
|
|---|---|
| Returns: | Of shape (n_test, n_support) |
| Return type: | tf.Tensor |
deepchem.models.tensorgraph.model_ops.
fully_connected_layer
(tensor, size=None, weight_init=None, bias_init=None, name=None)[source]¶Fully connected layer.
| Parameters: | |
|---|---|
| Returns: | A new tensor representing the output of the fully connected layer. |
| Return type: | tf.Tensor |
| Raises: |
|
deepchem.models.tensorgraph.model_ops.
get_dtype
(x)[source]¶Returns the dtype of a Keras tensor or variable, as a string.
| Parameters: | x (Tensor or variable.) – |
|---|---|
| Returns: | |
| Return type: | String, dtype of x. |
deepchem.models.tensorgraph.model_ops.
get_ndim
(x)[source]¶Returns the number of axes in a tensor, as an integer.
| Parameters: | x (Tensor or variable.) – |
|---|---|
| Returns: | |
| Return type: | Integer (scalar), number of axes. |
deepchem.models.tensorgraph.model_ops.
hard_sigmoid
(x)[source]¶Segment-wise linear approximation of sigmoid.
Faster than sigmoid. Returns 0. if x < -2.5, 1. if x > 2.5. In -2.5 <= x <= 2.5, returns 0.2 * x + 0.5.
| Parameters: | x (A tensor or variable.) – |
|---|---|
| Returns: | |
| Return type: | A tensor. |
deepchem.models.tensorgraph.model_ops.
int_shape
(x)[source]¶Returns the shape of a Keras tensor or a Keras variable as a tuple of integers or None entries.
| Parameters: | x (Tensor or variable.) – |
|---|---|
| Returns: | |
| Return type: | A tuple of integers (or None entries). |
deepchem.models.tensorgraph.model_ops.
l2_normalize
(x, axis)[source]¶Normalizes a tensor wrt the L2 norm alongside the specified axis.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: | A tensor. |
deepchem.models.tensorgraph.model_ops.
logits
(features, num_classes=2, weight_init=None, bias_init=None, dropout_prob=None, name=None)[source]¶Create a logits tensor for a single classification task.
You almost certainly don’t want dropout on there – it’s like randomly setting the (unscaled) probability of a target class to 0.5.
| Parameters: |
|
|---|---|
| Returns: | A logits tensor with shape batch_size x num_classes. |
deepchem.models.tensorgraph.model_ops.
lrelu
(alpha=0.01)[source]¶Create a leaky rectified linear unit function.
This function returns a new function that implements the LReLU with a specified alpha. The returned value can be used as an activation function in network layers.
| Parameters: | alpha (float) – the slope of the function when x<0 |
|---|---|
| Returns: | |
| Return type: | a function f(x) that returns alpha*x when x<0, and x when x>0. |
deepchem.models.tensorgraph.model_ops.
max
(x, axis=None, keepdims=False)[source]¶Maximum value in a tensor.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: | A tensor with maximum values of x. |
deepchem.models.tensorgraph.model_ops.
mean
(x, axis=None, keepdims=False)[source]¶Mean of a tensor, alongside the specified axis.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: | A tensor with the mean of elements of x. |
deepchem.models.tensorgraph.model_ops.
multitask_logits
(features, num_tasks, num_classes=2, weight_init=None, bias_init=None, dropout_prob=None, name=None)[source]¶Create a logit tensor for each classification task.
| Parameters: |
|
|---|---|
| Returns: | A list of logit tensors; one for each classification task. |
deepchem.models.tensorgraph.model_ops.
ones
(shape, dtype=None, name=None)[source]¶Instantiates an all-ones tensor variable and returns it.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: | A Keras variable, filled with 1.0. |
deepchem.models.tensorgraph.model_ops.
optimizer
(optimizer='adam', learning_rate=0.001, momentum=0.9)[source]¶Create model optimizer.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: | A training Optimizer. |
| Raises: |
|
deepchem.models.tensorgraph.model_ops.
random_normal_variable
(shape, mean, scale, dtype=tf.float32, name=None, seed=None)[source]¶Instantiates an Keras variable filled with samples drawn from a normal distribution and returns it.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: | A tf.Variable, filled with drawn samples. |
deepchem.models.tensorgraph.model_ops.
random_uniform_variable
(shape, low, high, dtype=tf.float32, name=None, seed=None)[source]¶Instantiates an variable filled with samples drawn from a uniform distribution and returns it.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: | A tf.Variable, filled with drawn samples. |
deepchem.models.tensorgraph.model_ops.
relu
(x, alpha=0.0, max_value=None)[source]¶Rectified linear unit. With default values, it returns element-wise max(x, 0).
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: | A tensor. |
deepchem.models.tensorgraph.model_ops.
selu
(x)[source]¶Scaled Exponential Linear unit.
| Parameters: | x (A tensor or variable.) – |
|---|---|
| Returns: | |
| Return type: | A tensor. |
References
deepchem.models.tensorgraph.model_ops.
softmax_N
(tensor, name=None)[source]¶Apply softmax across last dimension of a tensor.
| Parameters: |
|
|---|---|
| Returns: | A tensor with softmax-normalized values on the last dimension. |
deepchem.models.tensorgraph.model_ops.
sparse_categorical_crossentropy
(output, target, from_logits=False)[source]¶Categorical crossentropy between an output tensor and a target tensor, where the target is an integer tensor.
deepchem.models.tensorgraph.model_ops.
sqrt
(x)[source]¶Element-wise square root.
| Parameters: | x (input tensor.) – |
|---|---|
| Returns: | |
| Return type: | A tensor. |
deepchem.models.tensorgraph.model_ops.
sum
(x, axis=None, keepdims=False)[source]¶Sum of the values in a tensor, alongside the specified axis.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: | A tensor with sum of x. |
deepchem.models.tensorgraph.model_ops.
var
(x, axis=None, keepdims=False)[source]¶Variance of a tensor, alongside the specified axis.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: | A tensor with the variance of elements of x. |
deepchem.models.tensorgraph.model_ops.
weight_decay
(penalty_type, penalty)[source]¶Add weight decay.
| Parameters: | model – TensorflowGraph. |
|---|---|
| Returns: | A scalar tensor containing the weight decay cost. |
| Raises: | NotImplementedError –
If an unsupported penalty type is requested. |
deepchem.models.tensorgraph.model_ops.
zeros
(shape, dtype=tf.float32, name=None)[source]¶Instantiates an all-zeros variable and returns it.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: | A variable (including Keras metadata), filled with 0.0. |
Optimizers and related classes for use with TensorGraph.
deepchem.models.tensorgraph.optimizers.
Adam
(learning_rate=0.001, beta1=0.9, beta2=0.999, epsilon=1e-08)[source]¶Bases: deepchem.models.tensorgraph.optimizers.Optimizer
The Adam optimization algorithm.
deepchem.models.tensorgraph.optimizers.
ExponentialDecay
(initial_rate, decay_rate, decay_steps, staircase=True)[source]¶Bases: deepchem.models.tensorgraph.optimizers.LearningRateSchedule
A learning rate that decreases exponentially with the number of training steps.
deepchem.models.tensorgraph.optimizers.
GradientDescent
(learning_rate=0.001)[source]¶Bases: deepchem.models.tensorgraph.optimizers.Optimizer
The gradient descent optimization algorithm.
deepchem.models.tensorgraph.optimizers.
LearningRateSchedule
[source]¶Bases: object
A schedule for changing the learning rate over the course of optimization.
This is an abstract class. Subclasses represent specific schedules.
deepchem.models.tensorgraph.optimizers.
Optimizer
[source]¶Bases: object
An algorithm for optimizing a TensorGraph based model.
This is an abstract class. Subclasses represent specific optimization algorithms.
deepchem.models.tensorgraph.optimizers.
PolynomialDecay
(initial_rate, final_rate, decay_steps, power=1.0)[source]¶Bases: deepchem.models.tensorgraph.optimizers.LearningRateSchedule
A learning rate that decreases from an initial value to a final value over a fixed number of training steps.
Ops for regularizers
Code borrowed from Keras.
deepchem.models.tensorgraph.regularizers.
ActivityRegularizer
¶alias of L1L2Regularizer
deepchem.models.tensorgraph.regularizers.
L1L2Regularizer
(l1=0.0, l2=0.0)[source]¶Bases: deepchem.models.tensorgraph.regularizers.Regularizer
Regularizer for L1 and L2 regularization.
deepchem.models.tensorgraph.regularizers.
WeightRegularizer
¶alias of L1L2Regularizer
deepchem.models.tensorgraph.robust_multitask.
RobustMultitaskClassifier
(n_tasks, n_features, layer_sizes=[1000], weight_init_stddevs=0.02, bias_init_consts=1.0, weight_decay_penalty=0.0, weight_decay_penalty_type='l2', dropouts=0.5, activation_fns=<function relu>, n_classes=2, bypass_layer_sizes=[100], bypass_weight_init_stddevs=[0.02], bypass_bias_init_consts=[1.0], bypass_dropouts=[0.5], **kwargs)[source]¶Bases: deepchem.models.tensorgraph.tensor_graph.TensorGraph
Implements a neural network for robust multitasking.
Key idea is to have bypass layers that feed directly from features to task output. Hopefully will allow tasks to route around bad multitasking.
add_output
(layer)¶build
()¶create_submodel
(layers=None, loss=None, optimizer=None)¶Create an alternate objective for training one piece of a TensorGraph.
A TensorGraph consists of a set of layers, and specifies a loss function and optimizer to use for training those layers. Usually this is sufficient, but there are cases where you want to train different parts of a model separately. For example, a GAN consists of a generator and a discriminator. They are trained separately, and they use different loss functions.
A submodel defines an alternate objective to use in cases like this. It may optionally specify any of the following: a subset of layers in the model to train; a different loss function; and a different optimizer to use. This method creates a submodel, which you can then pass to fit() to use it for training.
| Parameters: |
|
|---|---|
| Returns: |
|
evaluate
(dataset, metrics, transformers=[], per_task_metrics=False)¶Evaluates the performance of this model on specified dataset.
| Parameters: |
|
|---|---|
| Returns: | Maps tasks to scores under metric. |
| Return type: |
evaluate_generator
(feed_dict_generator, metrics, transformers=[], labels=None, outputs=None, weights=[], per_task_metrics=False)¶fit
(dataset, nb_epoch=10, max_checkpoints_to_keep=5, checkpoint_interval=1000, deterministic=False, restore=False, submodel=None)¶Train this model on a dataset.
| Parameters: |
|
|---|
fit_generator
(feed_dict_generator, max_checkpoints_to_keep=5, checkpoint_interval=1000, restore=False, submodel=None)¶Train this model on data from a generator.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: | the average loss over the most recent checkpoint interval |
fit_on_batch
(X, y, w, submodel=None)¶get_global_step
()¶get_layer_variables
(layer)¶Get the list of trainable variables in a layer of the graph.
get_model_filename
(model_dir)¶Given model directory, obtain filename for the model itself.
get_num_tasks
()¶get_params
(deep=True)¶Get parameters for this estimator.
| Parameters: | deep (boolean, optional) – If True, will return the parameters for this estimator and contained subobjects that are estimators. |
|---|---|
| Returns: | params – Parameter names mapped to their values. |
| Return type: | mapping of string to any |
get_params_filename
(model_dir)¶Given model directory, obtain filename for the model itself.
get_pickling_errors
(obj, seen=None)¶get_pre_q_input
(input_layer)¶get_task_type
()¶Currently models can only be classifiers or regressors.
load_from_dir
(model_dir)¶predict_on_batch
(X, transformers=[], outputs=None)¶Generates predictions for input samples, processing samples in a batch.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: | A Numpy array of predictions. |
predict_on_generator
(generator, transformers=[], outputs=None)¶| Parameters: |
|
|---|
predict_proba_on_batch
(X, transformers=[], outputs=None)¶Generates predictions for input samples, processing samples in a batch.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: | A Numpy array of predictions. |
predict_proba_on_generator
(generator, transformers=[], outputs=None)¶| Returns: | numpy ndarray of shape (n_samples, n_classes*n_tasks) |
|---|---|
| Return type: | y_pred |
reload
()¶Reload trained model from disk.
restore
()¶Reload the values of all variables from the most recent checkpoint file.
save
()¶save_checkpoint
(max_checkpoints_to_keep=5)¶Save a checkpoint to disk.
Usually you do not need to call this method, since fit() saves checkpoints automatically. If you have disabled automatic checkpointing during fitting, this can be called to manually write checkpoints.
| Parameters: | max_checkpoints_to_keep (int) – the maximum number of checkpoints to keep. Older checkpoints are discarded. |
|---|
set_loss
(layer)¶set_optimizer
(optimizer)¶Set the optimizer to use for fitting.
set_params
(**params)¶Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects
(such as pipelines). The latter have parameters of the form
<component>__<parameter>
so that it’s possible to update each
component of a nested object.
| Returns: | |
|---|---|
| Return type: | self |
topsort
()¶deepchem.models.tensorgraph.robust_multitask.
RobustMultitaskRegressor
(n_tasks, n_features, layer_sizes=[1000], weight_init_stddevs=0.02, bias_init_consts=1.0, weight_decay_penalty=0.0, weight_decay_penalty_type='l2', dropouts=0.5, activation_fns=<function relu>, bypass_layer_sizes=[100], bypass_weight_init_stddevs=[0.02], bypass_bias_init_consts=[1.0], bypass_dropouts=[0.5], **kwargs)[source]¶Bases: deepchem.models.tensorgraph.tensor_graph.TensorGraph
Implements a neural network for robust multitasking.
Key idea is to have bypass layers that feed directly from features to task output. Hopefully will allow tasks to route around bad multitasking.
add_output
(layer)¶build
()¶create_submodel
(layers=None, loss=None, optimizer=None)¶Create an alternate objective for training one piece of a TensorGraph.
A TensorGraph consists of a set of layers, and specifies a loss function and optimizer to use for training those layers. Usually this is sufficient, but there are cases where you want to train different parts of a model separately. For example, a GAN consists of a generator and a discriminator. They are trained separately, and they use different loss functions.
A submodel defines an alternate objective to use in cases like this. It may optionally specify any of the following: a subset of layers in the model to train; a different loss function; and a different optimizer to use. This method creates a submodel, which you can then pass to fit() to use it for training.
| Parameters: |
|
|---|---|
| Returns: |
|
evaluate
(dataset, metrics, transformers=[], per_task_metrics=False)¶Evaluates the performance of this model on specified dataset.
| Parameters: |
|
|---|---|
| Returns: | Maps tasks to scores under metric. |
| Return type: |
evaluate_generator
(feed_dict_generator, metrics, transformers=[], labels=None, outputs=None, weights=[], per_task_metrics=False)¶fit
(dataset, nb_epoch=10, max_checkpoints_to_keep=5, checkpoint_interval=1000, deterministic=False, restore=False, submodel=None)¶Train this model on a dataset.
| Parameters: |
|
|---|
fit_generator
(feed_dict_generator, max_checkpoints_to_keep=5, checkpoint_interval=1000, restore=False, submodel=None)¶Train this model on data from a generator.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: | the average loss over the most recent checkpoint interval |
fit_on_batch
(X, y, w, submodel=None)¶get_global_step
()¶get_layer_variables
(layer)¶Get the list of trainable variables in a layer of the graph.
get_model_filename
(model_dir)¶Given model directory, obtain filename for the model itself.
get_num_tasks
()¶get_params
(deep=True)¶Get parameters for this estimator.
| Parameters: | deep (boolean, optional) – If True, will return the parameters for this estimator and contained subobjects that are estimators. |
|---|---|
| Returns: | params – Parameter names mapped to their values. |
| Return type: | mapping of string to any |
get_params_filename
(model_dir)¶Given model directory, obtain filename for the model itself.
get_pickling_errors
(obj, seen=None)¶get_pre_q_input
(input_layer)¶get_task_type
()¶Currently models can only be classifiers or regressors.
load_from_dir
(model_dir)¶predict
(dataset, transformers=[], outputs=None)¶Uses self to make predictions on provided Dataset object.
| Parameters: |
|
|---|---|
| Returns: | results |
| Return type: | numpy ndarray or list of numpy ndarrays |
predict_on_batch
(X, transformers=[], outputs=None)¶Generates predictions for input samples, processing samples in a batch.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: | A Numpy array of predictions. |
predict_on_generator
(generator, transformers=[], outputs=None)¶| Parameters: |
|
|---|
predict_proba
(dataset, transformers=[], outputs=None)¶| Parameters: |
|
|---|---|
| Returns: | y_pred |
| Return type: | numpy ndarray or list of numpy ndarrays |
predict_proba_on_batch
(X, transformers=[], outputs=None)¶Generates predictions for input samples, processing samples in a batch.
| Parameters: |
|
|---|---|
| Returns: | |
| Return type: | A Numpy array of predictions. |
predict_proba_on_generator
(generator, transformers=[], outputs=None)¶| Returns: | numpy ndarray of shape (n_samples, n_classes*n_tasks) |
|---|---|
| Return type: | y_pred |
reload
()¶Reload trained model from disk.
restore
()¶Reload the values of all variables from the most recent checkpoint file.
save
()¶save_checkpoint
(max_checkpoints_to_keep=5)¶Save a checkpoint to disk.
Usually you do not need to call this method, since fit() saves checkpoints automatically. If you have disabled automatic checkpointing during fitting, this can be called to manually write checkpoints.
| Parameters: | max_checkpoints_to_keep (int) – the maximum number of checkpoints to keep. Older checkpoints are discarded. |
|---|
set_loss
(layer)¶set_optimizer
(optimizer)¶Set the optimizer to use for fitting.
set_params
(**params)¶Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects
(such as pipelines). The latter have parameters of the form
<component>__<parameter>
so that it’s possible to update each
component of a nested object.
| Returns: | |
|---|---|
| Return type: | self |
topsort
()¶Convenience class for building sequential deep networks.
deepchem.models.tensorgraph.sequential.
Sequential
(**kwargs)[source]¶Bases: deepchem.models.tensorgraph.tensor_graph.TensorGraph
Sequential models are linear stacks of layers.
Analogous to the Sequential model from Keras and allows for less verbose construction of simple deep learning model.
Example
>>> import deepchem as dc
>>> import numpy as np
>>> from deepchem.models.tensorgraph import layers
>>> # Define Data
>>> X = np.random.rand(20, 2)
>>> y = [[0, 1] for x in range(20)]
>>> dataset = dc.data.NumpyDataset(X, y)
>>> model = dc.models.Sequential(learning_rate=0.01)
>>> model.add(layers.Dense(out_channels=2))
>>> model.add(layers.SoftMax())
add_output
(layer)¶build
()¶create_submodel
(layers=None, loss=None, optimizer=None)¶Create an alternate objective for training one piece of a TensorGraph.