udacity / deep-learning-v2-pytorch

Projects and exercises for the latest Deep Learning ND program https://www.udacity.com/course/deep-learning-nanodegree--nd101
MIT License
5.31k stars 5.33k forks source link

Remove unnecessary code in Sentiment RNN exercise and solution #185

Closed goelakash closed 5 years ago

goelakash commented 5 years ago

In the pre-processing step, I see this block of code:

# split by new lines and spaces
reviews_split = all_text.split('\n')
all_text = ' '.join(reviews_split)

# create a list of words
words = all_text.split()

that can be simplified to

# split by new lines and spaces
reviews_split = all_text.split('\n')

# create a list of words
words = all_text.split()

(https://github.com/goelakash/deep-learning-v2-pytorch/blob/master/sentiment-rnn/Sentiment_RNN_Exercise.ipynb)

Both spaces and newlines are treated as same. Hence we can remove the redundant code.

See for reference: python2 python3