I am using a sampling strategy during training that I think be implemented by changing a parameter of a HybridBlock during training. To give some context, I am implementing a graph convolutional neural network where I multiply an adjacency matrix A with a node features matrix X. I have the following block:
class GraphConv(HybridBlock): def __init__(self, A, in_units, out_units, activation=lambda x: x, **kwargs): super().__init__(**kwargs) self.activation = activation self.in_units = in_units self.out_units = out_units self.A = self.params.get_constant('A', A) self.W = self.params.get( 'W', shape=(self.in_units, self.out_units), ) def hybrid_forward(self, F, X, A, W): aggregate = F.dot(A, X) propagate = self.activation( F.dot(aggregate, W)) return propagate
I want to update the Constant A during each epoch during training, where I effectively subsample the full adjacency matrix. Any ideas on how to do this in the Gluon API?