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

get predictions for all tasks in single forward pass #6

Open
yurakuratov opened this issue May 20, 2021 · 0 comments
Open

get predictions for all tasks in single forward pass #6

yurakuratov opened this issue May 20, 2021 · 0 comments

Comments

@yurakuratov
Copy link

Hi!

Is it possible to use model trained on 4 facial-informatic tasks in a way that it can produce predictions for all tasks in single forward pass?

Something like in the following code:

class SphereNetMT(SphereNet):
    """ Multi-task version of SphereNet, returns predictions for all classifiers in single forward pass
    """
    
    def forward(self, x, tasks=['gender', 'emotion', 'age0']):
        x = self.relu1_1(self.conv1_1(x))
        x = x + self.relu1_3(self.conv1_3(self.relu1_2(self.conv1_2(x))))
        x = self.relu2_1(self.conv2_1(x))
        x = x + self.relu2_3(self.conv2_3(self.relu2_2(self.conv2_2(x))))
        x = x + self.relu2_5(self.conv2_5(self.relu2_4(self.conv2_4(x))))
        x = self.relu3_1(self.conv3_1(x))
        x = x + self.relu3_3(self.conv3_3(self.relu3_2(self.conv3_2(x))))
        x = x + self.relu3_5(self.conv3_5(self.relu3_4(self.conv3_4(x))))
        x = x + self.relu3_7(self.conv3_7(self.relu3_6(self.conv3_6(x))))
        x = x + self.relu3_9(self.conv3_9(self.relu3_8(self.conv3_8(x))))
        x = self.relu4_1(self.conv4_1(x))
        x = x + self.relu4_3(self.conv4_3(self.relu4_2(self.conv4_2(x))))
        x = self.flatten(x)
        predictions = {}
        for i, task in enumerate(tasks):
            predictions[task] = self.classifiers[self.datasets.index(task)](x)
        return predictions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant