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

improve edge weight #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 15 additions & 6 deletions libs/models/networks/graph_connectivity_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,24 @@ def forward(self, x):


class EdgeWeights(nn.Module):
def __init__(self, embedding_size=1, hidden=4):
def __init__(self, class_embedding_size, hidden_sizes):
super(EdgeWeights, self).__init__()
self.linear = Linear(embedding_size + 2, hidden, activation="relu")
self.out = Linear(hidden, 1, activation="relu")
layers = []
# self.linear = Linear(embedding_size + 2, hidden, activation="relu")
current_dim = class_embedding_size + 2 # +2 for pair of node confidences
for h in hidden_sizes:
layers.append(Linear(current_dim, h, activation="relu"))
current_dim = h
self.hidden_layers = nn.ModuleList(layers)
self.out = Linear(current_dim, 1, activation="relu")

def forward(self, x):
x = self.linear(x)
x = self.out(x)
return x
# x = self.linear(x)
# x = self.out(x)
for layer in self.hidden_layers:
x = layer(x)
out = self.out(x)
return out


class VisualFeatureEmbedding(nn.Module):
Expand Down
2 changes: 1 addition & 1 deletion scripts/train_300w.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
graph_model_config = {"num_classes": 68,
"embedding_hidden_sizes": [32],
"class_embedding_size": 1,
"edge_hidden_size": 4,
"edge_hidden_size": [128, 64, 64],
# "visual_feature_dim": 1920, # Stacked Hourglass
"visual_feature_dim": 270, # HRNet18
"visual_hidden_sizes": [512, 128, 32],
Expand Down
2 changes: 1 addition & 1 deletion scripts/train_wflw.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
graph_model_config = {"num_classes": 98,
"embedding_hidden_sizes": [32],
"class_embedding_size": 1,
"edge_hidden_size": 4,
"edge_hidden_size": [128, 64, 64],
# "visual_feature_dim": 1920, # Stacked Hourglass
"visual_feature_dim": 270, # HRNet18
"visual_hidden_sizes": [512, 128, 32],
Expand Down