Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skeleton for LR encoding ED model with extension of estimator #44

Merged
merged 22 commits into from
Nov 7, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
f99ff95
skeleton for LR encoding ED model with extension of estimator
davidsebfischer Oct 12, 2021
f84f8a7
enabled extraction of scaled adj matrix
davidsebfischer Oct 12, 2021
162ba4e
debugged unit tests
davidsebfischer Oct 13, 2021
37ec983
added disclaimer
davidsebfischer Oct 13, 2021
64ae03e
Merge branch 'feature/lr_encoder' of github.com:theislab/ncem into fe…
AnnaChristina Oct 14, 2021
3dc14a3
simplify output layers with get_out in remaining models
AnnaChristina Oct 14, 2021
427ffb5
simplify output layers with get_out in remaining models
AnnaChristina Oct 14, 2021
833ec07
add disclaimer to cond layers
AnnaChristina Oct 14, 2021
21f54c9
fix max and gcn layer for single gnn
AnnaChristina Oct 19, 2021
998c8cc
Bump version from 0.3.2 to 0.4.0
AnnaChristina Oct 25, 2021
01438aa
added node embedding and output weight saving in EDncem models
davidsebfischer Oct 28, 2021
7405baa
Merge pull request #53 from theislab/development
AnnaChristina Nov 3, 2021
e26132a
fix conflicts
AnnaChristina Nov 3, 2021
9209a78
Merge branch 'release' of github.com:theislab/ncem into release
AnnaChristina Nov 3, 2021
e61d30c
Merge pull request #54 from theislab/release
AnnaChristina Nov 3, 2021
0c2839e
Bump version from 0.4.6 to 0.4.7
AnnaChristina Nov 3, 2021
0e2711f
add n_top_genes to dataloader
AnnaChristina Nov 4, 2021
2f03c77
Bump version from 0.4.7 to 0.4.8
AnnaChristina Nov 4, 2021
be89c0b
add hgnc names for schuerch
AnnaChristina Nov 7, 2021
803063d
Merge branch 'feature/embedding_saving' of github.com:theislab/ncem i…
AnnaChristina Nov 7, 2021
8a4bcfa
add saving of LR names to model class
AnnaChristina Nov 7, 2021
bd2f900
Merge pull request #51 from theislab/feature/embedding_saving
AnnaChristina Nov 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix max and gcn layer for single gnn
  • Loading branch information
AnnaChristina committed Oct 19, 2021
commit 21f54c99e6153c2c9d436a3e5e8f99fc9955cc17
13 changes: 8 additions & 5 deletions ncem/models/layers/single_gnn_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ class SingleGcnLayer(tf.keras.layers.Layer):
"""
TODO GCN implementation here is not complete yet.
"""
def __init__(self, input_dim, latent_dim, dropout_rate, activation, l2_reg, use_bias: bool = False, **kwargs):
def __init__(self, latent_dim, dropout_rate, activation, l2_reg, use_bias: bool = False, **kwargs):
super().__init__(**kwargs)
self.input_dim = input_dim
self.latent_dim = latent_dim
self.dropout_rate = dropout_rate
self.activation = tf.keras.activations.get(activation)
Expand All @@ -32,15 +31,19 @@ def __init__(self, input_dim, latent_dim, dropout_rate, activation, l2_reg, use_

self.kernel = None
self.bias = None

def build(self, input_shapes):
input_shape = input_shapes[0]
# Layer kernel
self.kernel = self.add_weight(
name="kernel",
shape=(self.input_dim, self.latent_dim),
shape=(int(input_shape[2]), self.latent_dim),
initializer=tf.keras.initializers.glorot_uniform(),
regularizer=tf.keras.regularizers.l2(self.l2_reg),
)
# Layer bias
if self.use_bias:
self.bias = self.add_weight(name="bias", shape=(self.output_dim,))
self.bias = self.add_weight(name="bias", shape=(self.latent_dim,))

def call(self, inputs, **kwargs):
targets = inputs[0] # (batch, target nodes, features)
Expand All @@ -49,7 +52,7 @@ def call(self, inputs, **kwargs):
a = inputs[2] # (batch, target nodes, padded neighbor nodes)

# (batch, target nodes, padded neighbor nodes, latent)
y = tf.matmul(neighborhood, self.kernel, axes=1)
y = tf.matmul(neighborhood, self.kernel)
y = tf.reduce_sum(y, axis=-2) # (batch, target nodes, latent)
# Normalise neighborhood size in embedding:
factor = tf.reduce_sum(a, axis=-1, keepdims=True) # (batch, target nodes, 1)
Expand Down
5 changes: 5 additions & 0 deletions ncem/models/model_ed_single_ncem.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ def __init__(
)([input_x_neighbors, input_a])
elif cond_type == "gcn":
x_encoder = SingleGcnLayer(
latent_dim=latent_dim,
dropout_rate=dropout_rate,
activation="relu",
l2_reg=l2_coef,
use_bias=True,
name=f"gcn_layer"
)([input_x_targets, input_x_neighbors, input_a])
else:
Expand Down