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

Sentiment analysis pytorch #1

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

Conversation

owoshch
Copy link

@owoshch owoshch commented Jun 6, 2018

No description provided.

Copy link

@Maerville Maerville left a comment

Choose a reason for hiding this comment

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

in def train i would recommend to set default values as well

what's the magic number 25000?

Copy link

@Maerville Maerville left a comment

Choose a reason for hiding this comment

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

what's the point in making ConvNet with customizable Emb layer size if this parameter is not accessible via command line args?

@Maerville
Copy link

Is it better to separate the script for two files: one for the network and utils and second for main?

as for now you are using this network only in one file, I would recommend to leave it as it is. it makes sense to put NN to separate file once you use it in at least 2-3 different workflows :)

@Maerville
Copy link

Also pls remove unnecessary blank lines

Copy link

@Maerville Maerville left a comment

Choose a reason for hiding this comment

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

How should I white docstrings?

Well, in this particular file I'd say def train is worth documenting params. Other functions are pretty much understandable even without excessive comments
http://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html

Copy link

@xyhuang xyhuang left a comment

Choose a reason for hiding this comment

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

Please see inline comments, also please check out the style guide for some styling conventions,
e.g.
https://www.python.org/dev/peps/pep-0008/#imports
https://www.python.org/dev/peps/pep-0008/#function-and-variable-names
https://www.python.org/dev/peps/pep-0008/#indentation
https://www.python.org/dev/peps/pep-0008/#blank-lines
https://www.python.org/dev/peps/pep-0257/
etc.
ideally you may want to run it through pylint or pep8 to fix styling issues but the aboves are what i spotted.

loss_log.append(loss)
return loss_log, acc_log

def plot_history(train_history, val_history, title='loss'):
Copy link

Choose a reason for hiding this comment

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

do we need this?

val_log.append((steps * (epoch + 1), np.mean(val_loss)))
val_acc_log.append((steps * (epoch + 1), np.mean(val_acc)))

plot_history(train_log, val_log)
Copy link

Choose a reason for hiding this comment

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

plotting will be a performance hit to the training, i don't think it is desirable in benchmark... correct me if i'm wrong.

@ddutta
Copy link

ddutta commented Jun 12, 2018 via email

len(TEXT.vocab) - vocabulary size. Necessary for the embedding layer
batch_size
"""
device = "cuda:0" if use_cuda else -1

Choose a reason for hiding this comment

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

did you test it on gpu?

def train_epoch(model, optimizer, train_iter):
loss_log, acc_log = [], []
model.train()
for batch in tqdm.tqdm(train_iter):

Choose a reason for hiding this comment

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

just tqdm(train_iter)?

tremblerz added a commit that referenced this pull request Jul 18, 2018
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.

5 participants