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

Added Temporal Score functions #72

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open

Conversation

harsh4799
Copy link
Contributor

No description provided.

@codecov
Copy link

codecov bot commented May 23, 2020

Codecov Report

Merging #72 into master will increase coverage by 0.36%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #72      +/-   ##
==========================================
+ Coverage   94.91%   95.27%   +0.36%     
==========================================
  Files           8        9       +1     
  Lines         334      360      +26     
==========================================
+ Hits          317      343      +26     
  Misses         17       17              
Impacted Files Coverage Δ
decepticonlp/metrics/char_metrics.py 100.00% <ø> (ø)
decepticonlp/metrics/temporal_metrics.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 64f9991...8cb7762. Read the comment docs.

import json
from pathlib import Path

json_path = Path("decepticonlp/metrics/glove_sample.json")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the glove file be in tests directory?


class RankCharacters:
"""
Accepts a feature vector torch tensor and outputs a temporal ranking of characters
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have proper docstrings here?

def temporal_score(self, sentence):
"""
Considering a input sequence x1,x2,...,xn
we calculate T(xi) = F(x1,x2,...,xi) - F(x1,x2,...,xi-1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docstrings in our preferred format needed here too? Including information about params and return values?


def temportal_tail_score(self, sentence):
"""
Considering a input sequence x1,x2,...,xn
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docstring needed


def combined_score(self, sentence, lambda_):
"""
Computes combined temporal_score, temportal_tail_score
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proper docstrings needed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add all of the docstrings

import torch.nn as nn


class RankCharacters:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it ranking characters or words?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, this is rank characters. Before this I did it on a character level but later changed it to a word level, forgot to change the class name :P. I'll change this rn.

inputs = sentence.reshape(len(sentence), 1, -1)
model = nn.RNN(inputs.shape[2], 1)
with torch.no_grad():
_, pred = model(inputs)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the model be pre-trained on the task? I mean user should have an option to use his own models to test this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rajaswa , this is the temporal scorer, it selects words based on highest decrease in rnn outputs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I am aware of that. But monitoring output from an untrained RNN doesn't make sense at all
  2. This should be usable by all models working with text sequences

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool I'll make the changes in that way then !

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

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

Successfully merging this pull request may close these issues.

3 participants