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

Fix transformer model output shape error #197

Open
wants to merge 1 commit into
base: r0.8
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __init__(self, image_features, gru_layers, hidden_size, num_classes, num_cla
self.linear_4 = nn.Linear(self.linear_3_size, self.linear_4_size)
self.linear_5 = nn.Linear(self.linear_4_size, self.linear_5_size)

self.output_layer = nn.Linear(self.linear_5_size, self.num_classes)
self.output_layer = nn.Linear(self.linear_5_size, self.num_classes_type)

def forward(self, x, hidden, cell_state, train_mode=False):
# Reshape for CNN
Expand Down Expand Up @@ -94,4 +94,4 @@ def init_hidden(self, batch_size, num_layers, bidirectional=True):
if bidirectional:
num_directions = 2

return torch.zeros(batch_size, num_directions * num_layers, self.hidden_size)
return torch.zeros(batch_size, num_directions * num_layers, self.hidden_size)