molcraft 0.1.0a14__tar.gz → 0.1.0a15__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of molcraft might be problematic. Click here for more details.
- {molcraft-0.1.0a14 → molcraft-0.1.0a15}/PKG-INFO +1 -1
- {molcraft-0.1.0a14 → molcraft-0.1.0a15}/molcraft/__init__.py +1 -1
- molcraft-0.1.0a15/molcraft/apps/qsrr.py +47 -0
- {molcraft-0.1.0a14 → molcraft-0.1.0a15}/molcraft/featurizers.py +1 -1
- {molcraft-0.1.0a14 → molcraft-0.1.0a15}/molcraft/models.py +1 -1
- {molcraft-0.1.0a14 → molcraft-0.1.0a15}/molcraft/ops.py +11 -0
- {molcraft-0.1.0a14 → molcraft-0.1.0a15}/molcraft.egg-info/PKG-INFO +1 -1
- {molcraft-0.1.0a14 → molcraft-0.1.0a15}/molcraft.egg-info/SOURCES.txt +1 -0
- {molcraft-0.1.0a14 → molcraft-0.1.0a15}/LICENSE +0 -0
- {molcraft-0.1.0a14 → molcraft-0.1.0a15}/README.md +0 -0
- {molcraft-0.1.0a14 → molcraft-0.1.0a15}/molcraft/apps/__init__.py +0 -0
- {molcraft-0.1.0a14 → molcraft-0.1.0a15}/molcraft/apps/peptides.py +0 -0
- {molcraft-0.1.0a14 → molcraft-0.1.0a15}/molcraft/callbacks.py +0 -0
- {molcraft-0.1.0a14 → molcraft-0.1.0a15}/molcraft/chem.py +0 -0
- {molcraft-0.1.0a14 → molcraft-0.1.0a15}/molcraft/conformers.py +0 -0
- {molcraft-0.1.0a14 → molcraft-0.1.0a15}/molcraft/datasets.py +0 -0
- {molcraft-0.1.0a14 → molcraft-0.1.0a15}/molcraft/descriptors.py +0 -0
- {molcraft-0.1.0a14 → molcraft-0.1.0a15}/molcraft/features.py +0 -0
- {molcraft-0.1.0a14 → molcraft-0.1.0a15}/molcraft/layers.py +0 -0
- {molcraft-0.1.0a14 → molcraft-0.1.0a15}/molcraft/losses.py +0 -0
- {molcraft-0.1.0a14 → molcraft-0.1.0a15}/molcraft/records.py +0 -0
- {molcraft-0.1.0a14 → molcraft-0.1.0a15}/molcraft/tensors.py +0 -0
- {molcraft-0.1.0a14 → molcraft-0.1.0a15}/molcraft.egg-info/dependency_links.txt +0 -0
- {molcraft-0.1.0a14 → molcraft-0.1.0a15}/molcraft.egg-info/requires.txt +0 -0
- {molcraft-0.1.0a14 → molcraft-0.1.0a15}/molcraft.egg-info/top_level.txt +0 -0
- {molcraft-0.1.0a14 → molcraft-0.1.0a15}/pyproject.toml +0 -0
- {molcraft-0.1.0a14 → molcraft-0.1.0a15}/setup.cfg +0 -0
- {molcraft-0.1.0a14 → molcraft-0.1.0a15}/tests/test_chem.py +0 -0
- {molcraft-0.1.0a14 → molcraft-0.1.0a15}/tests/test_featurizers.py +0 -0
- {molcraft-0.1.0a14 → molcraft-0.1.0a15}/tests/test_layers.py +0 -0
- {molcraft-0.1.0a14 → molcraft-0.1.0a15}/tests/test_losses.py +0 -0
- {molcraft-0.1.0a14 → molcraft-0.1.0a15}/tests/test_models.py +0 -0
- {molcraft-0.1.0a14 → molcraft-0.1.0a15}/tests/test_tensors.py +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import molcraft
|
|
2
|
+
import keras
|
|
3
|
+
|
|
4
|
+
@keras.saving.register_keras_serializable(package='molcraft')
|
|
5
|
+
class AuxiliaryFeatureInjection(molcraft.layers.GraphLayer):
|
|
6
|
+
|
|
7
|
+
def __init__(
|
|
8
|
+
self,
|
|
9
|
+
field: str = 'auxiliary_feature',
|
|
10
|
+
depth: int = 2,
|
|
11
|
+
drop: bool = True,
|
|
12
|
+
activation: str | None = None,
|
|
13
|
+
**kwargs,
|
|
14
|
+
) -> None:
|
|
15
|
+
super().__init__(**kwargs)
|
|
16
|
+
self.field = field
|
|
17
|
+
self.depth = depth
|
|
18
|
+
self.drop = drop
|
|
19
|
+
self.activation = keras.activations.get(activation)
|
|
20
|
+
|
|
21
|
+
def build(self, spec: molcraft.tensors.GraphTensor.Spec) -> None:
|
|
22
|
+
units = spec.node['feature'].shape[1]
|
|
23
|
+
for i in range(self.depth):
|
|
24
|
+
setattr(
|
|
25
|
+
self, f'dense_{i}', self.get_dense(units, activation=self.activation)
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
def propagate(self, tensor: molcraft.tensors.GraphTensor) -> None:
|
|
29
|
+
x = tensor.context[self.field]
|
|
30
|
+
if self.drop:
|
|
31
|
+
tensor = tensor.update({'context': {self.field: None}})
|
|
32
|
+
for i in range(self.depth):
|
|
33
|
+
x = getattr(self, f'dense_{i}')(x)
|
|
34
|
+
node_feature = molcraft.ops.scatter_add(
|
|
35
|
+
tensor.node['feature'], tensor.node['super'], x
|
|
36
|
+
)
|
|
37
|
+
return tensor.update({'node': {'feature': node_feature}})
|
|
38
|
+
|
|
39
|
+
def get_config(self) -> dict:
|
|
40
|
+
config = super().get_config()
|
|
41
|
+
config.update({
|
|
42
|
+
'field': self.field,
|
|
43
|
+
'depth': self.depth,
|
|
44
|
+
'drop': self.drop,
|
|
45
|
+
'activation': keras.activations.serialize(self.activation)
|
|
46
|
+
})
|
|
47
|
+
return config
|
|
@@ -169,7 +169,7 @@ class MolGraphFeaturizer(Featurizer):
|
|
|
169
169
|
if default_atom_features:
|
|
170
170
|
atom_features = [features.AtomType()]
|
|
171
171
|
if not self.include_hs:
|
|
172
|
-
atom_features.append(features.
|
|
172
|
+
atom_features.append(features.NumHydrogens())
|
|
173
173
|
atom_features.append(features.Degree())
|
|
174
174
|
if not isinstance(self, MolGraphFeaturizer3D):
|
|
175
175
|
default_bond_features = (
|
|
@@ -397,7 +397,7 @@ class GraphModel(layers.GraphLayer, keras.models.Model):
|
|
|
397
397
|
raise ValueError(
|
|
398
398
|
'Could not extract output. `Readout` layer not found.'
|
|
399
399
|
)
|
|
400
|
-
return self.__class__(inputs, outputs, name=f'{self.name}
|
|
400
|
+
return self.__class__(inputs, outputs, name=f'{self.name}_backbone')
|
|
401
401
|
|
|
402
402
|
def head(self) -> functional.Functional:
|
|
403
403
|
if not isinstance(self, FunctionalGraphModel):
|
|
@@ -4,6 +4,7 @@ import tensorflow as tf
|
|
|
4
4
|
from keras import backend
|
|
5
5
|
|
|
6
6
|
|
|
7
|
+
@keras.saving.register_keras_serializable(package='molcraft')
|
|
7
8
|
def gather(
|
|
8
9
|
node_feature: tf.Tensor,
|
|
9
10
|
edge: tf.Tensor
|
|
@@ -16,6 +17,7 @@ def gather(
|
|
|
16
17
|
edge = keras.ops.expand_dims(edge, axis=-1)
|
|
17
18
|
return keras.ops.take_along_axis(node_feature, edge, axis=0)
|
|
18
19
|
|
|
20
|
+
@keras.saving.register_keras_serializable(package='molcraft')
|
|
19
21
|
def aggregate(
|
|
20
22
|
node_feature: tf.Tensor,
|
|
21
23
|
edge: tf.Tensor,
|
|
@@ -30,6 +32,7 @@ def aggregate(
|
|
|
30
32
|
node_feature, edge, num_nodes, sorted=False
|
|
31
33
|
)
|
|
32
34
|
|
|
35
|
+
@keras.saving.register_keras_serializable(package='molcraft')
|
|
33
36
|
def propagate(
|
|
34
37
|
node_feature: tf.Tensor,
|
|
35
38
|
edge_source: tf.Tensor,
|
|
@@ -49,6 +52,7 @@ def propagate(
|
|
|
49
52
|
|
|
50
53
|
return aggregate(node_feature, edge_target, num_nodes)
|
|
51
54
|
|
|
55
|
+
@keras.saving.register_keras_serializable(package='molcraft')
|
|
52
56
|
def scatter_update(
|
|
53
57
|
inputs: tf.Tensor,
|
|
54
58
|
indices: tf.Tensor,
|
|
@@ -62,6 +66,7 @@ def scatter_update(
|
|
|
62
66
|
indices = keras.ops.expand_dims(indices, axis=-1)
|
|
63
67
|
return keras.ops.scatter_update(inputs, indices, updates)
|
|
64
68
|
|
|
69
|
+
@keras.saving.register_keras_serializable(package='molcraft')
|
|
65
70
|
def scatter_add(
|
|
66
71
|
inputs: tf.Tensor,
|
|
67
72
|
indices: tf.Tensor,
|
|
@@ -78,6 +83,7 @@ def scatter_add(
|
|
|
78
83
|
updates = scatter_update(keras.ops.zeros_like(inputs), indices, updates)
|
|
79
84
|
return inputs + updates
|
|
80
85
|
|
|
86
|
+
@keras.saving.register_keras_serializable(package='molcraft')
|
|
81
87
|
def edge_softmax(
|
|
82
88
|
score: tf.Tensor,
|
|
83
89
|
edge_target: tf.Tensor
|
|
@@ -98,6 +104,7 @@ def edge_softmax(
|
|
|
98
104
|
denominator = gather(denominator, edge_target)
|
|
99
105
|
return numerator / denominator
|
|
100
106
|
|
|
107
|
+
@keras.saving.register_keras_serializable(package='molcraft')
|
|
101
108
|
def edge_weight(
|
|
102
109
|
edge: tf.Tensor,
|
|
103
110
|
edge_weight: tf.Tensor,
|
|
@@ -108,6 +115,7 @@ def edge_weight(
|
|
|
108
115
|
edge_weight = keras.ops.expand_dims(edge_weight, axis=-1)
|
|
109
116
|
return edge * edge_weight
|
|
110
117
|
|
|
118
|
+
@keras.saving.register_keras_serializable(package='molcraft')
|
|
111
119
|
def segment_mean(
|
|
112
120
|
data: tf.Tensor,
|
|
113
121
|
segment_ids: tf.Tensor,
|
|
@@ -142,6 +150,7 @@ def segment_mean(
|
|
|
142
150
|
)
|
|
143
151
|
return x / sizes[:, None]
|
|
144
152
|
|
|
153
|
+
@keras.saving.register_keras_serializable(package='molcraft')
|
|
145
154
|
def gaussian(
|
|
146
155
|
x: tf.Tensor,
|
|
147
156
|
mean: tf.Tensor,
|
|
@@ -155,6 +164,7 @@ def gaussian(
|
|
|
155
164
|
a = (2 * np.pi) ** 0.5
|
|
156
165
|
return keras.ops.exp(-0.5 * (((x - mean) / std) ** 2)) / (a * std)
|
|
157
166
|
|
|
167
|
+
@keras.saving.register_keras_serializable(package='molcraft')
|
|
158
168
|
def euclidean_distance(
|
|
159
169
|
x1: tf.Tensor,
|
|
160
170
|
x2: tf.Tensor,
|
|
@@ -169,6 +179,7 @@ def euclidean_distance(
|
|
|
169
179
|
)
|
|
170
180
|
)
|
|
171
181
|
|
|
182
|
+
@keras.saving.register_keras_serializable(package='molcraft')
|
|
172
183
|
def displacement(
|
|
173
184
|
x1: tf.Tensor,
|
|
174
185
|
x2: tf.Tensor,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|