-
Notifications
You must be signed in to change notification settings - Fork 0
Sourcery refactored master branch #1
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,7 +61,7 @@ def forward(self, x, edge_index, edge_weight): | |
|
||
model.train() | ||
|
||
for epoch in range(epochs): | ||
for _ in range(epochs): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
optimizer.zero_grad() | ||
x, edge_index = create_mock_data(node_count, edge_per_node, node_features) | ||
edge_weight = create_mock_edge_weight(edge_index) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,7 +59,7 @@ def forward(self, x, edge_index, edge_weight): | |
|
||
model.train() | ||
|
||
for epoch in range(epochs): | ||
for _ in range(epochs): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
optimizer.zero_grad() | ||
x, edge_index = create_mock_data(node_count, edge_per_node, node_features) | ||
edge_weight = create_mock_edge_weight(edge_index) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,7 +60,7 @@ def forward(self, x, edge_index, edge_weight): | |
|
||
model.train() | ||
|
||
for epoch in range(epochs): | ||
for _ in range(epochs): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
optimizer.zero_grad() | ||
x, edge_index = create_mock_data(node_count, edge_per_node, node_features) | ||
edge_weight = create_mock_edge_weight(edge_index) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,7 +59,7 @@ def forward(self, x, edge_index, edge_weight): | |
|
||
model.train() | ||
|
||
for epoch in range(epochs): | ||
for _ in range(epochs): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
optimizer.zero_grad() | ||
x, edge_index = create_mock_data(node_count, edge_per_node, node_features) | ||
edge_weight = create_mock_edge_weight(edge_index) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,5 +67,4 @@ def forward(self, X: torch.FloatTensor, edge_index: torch.LongTensor, | |
W = self.conv_layer.weight[None, :, :] | ||
W, _ = self.recurrent_layer(W) | ||
self.conv_layer.weight = torch.nn.Parameter(W.squeeze()) | ||
X = self.conv_layer(X, edge_index, edge_weight) | ||
return X | ||
return self.conv_layer(X, edge_index, edge_weight) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,8 +148,7 @@ def _calculate_cell_state(self, X, edge_index, edge_weight, H, C, I, F): | |
T = T + self.conv_c(H, edge_index, edge_weight) | ||
T = T + self.b_c | ||
T = torch.tanh(T) | ||
C = F*C + I*T | ||
return C | ||
return F*C + I*T | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
def _calculate_output_gate(self, X, edge_index, edge_weight, H, C): | ||
O = torch.matmul(X, self.W_o) | ||
|
@@ -160,8 +159,7 @@ def _calculate_output_gate(self, X, edge_index, edge_weight, H, C): | |
|
||
|
||
def _calculate_hidden_state(self, O, C): | ||
H = O * torch.tanh(C) | ||
return H | ||
return O * torch.tanh(C) | ||
Comment on lines
-163
to
+162
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
|
||
def forward(self, X: torch.FloatTensor, edge_index: torch.LongTensor, edge_weight: torch.FloatTensor=None, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,8 +125,7 @@ def _calculate_candidate_state(self, X, edge_index, edge_weight, H, R): | |
|
||
|
||
def _calculate_hidden_state(self, Z, H, H_tilde): | ||
H = Z*H + (1-Z)*H_tilde | ||
return H | ||
return Z*H + (1-Z)*H_tilde | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
|
||
def forward(self, X: torch.FloatTensor, edge_index: torch.LongTensor, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -172,8 +172,7 @@ def _calculate_cell_state(self, X, edge_index, edge_weight, H, C, I, F): | |
T = T + self.conv_h_c(H, edge_index, edge_weight) | ||
T = T + self.b_c | ||
T = torch.tanh(T) | ||
C = F*C + I*T | ||
return C | ||
return F*C + I*T | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
def _calculate_output_gate(self, X, edge_index, edge_weight, H, C): | ||
O = self.conv_x_o(X, edge_index, edge_weight) | ||
|
@@ -185,8 +184,7 @@ def _calculate_output_gate(self, X, edge_index, edge_weight, H, C): | |
|
||
|
||
def _calculate_hidden_state(self, O, C): | ||
H = O * torch.tanh(C) | ||
return H | ||
return O * torch.tanh(C) | ||
Comment on lines
-188
to
+187
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
|
||
def forward(self, X: torch.FloatTensor, edge_index: torch.LongTensor, edge_weight: torch.FloatTensor=None, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,8 +115,7 @@ def _calculate_cell_state(self, X, edge_index, edge_type, H, C, I, F): | |
T = self.conv_x_c(X, edge_index, edge_type) | ||
T = T + self.conv_h_c(H, edge_index, edge_type) | ||
T = torch.tanh(T) | ||
C = F*C + I*T | ||
return C | ||
return F*C + I*T | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
|
||
def _calculate_output_gate(self, X, edge_index, edge_type, H, C): | ||
|
@@ -127,8 +126,7 @@ def _calculate_output_gate(self, X, edge_index, edge_type, H, C): | |
|
||
|
||
def _calculate_hidden_state(self, O, C): | ||
H = O * torch.tanh(C) | ||
return H | ||
return O * torch.tanh(C) | ||
Comment on lines
-130
to
+129
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
|
||
def forward(self, X: torch.FloatTensor, edge_index: torch.LongTensor, edge_type: torch.LongTensor, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines
66-66
refactored with the following changes:for-index-underscore
)