ModuleNotFoundError: No module named 'utils.gradcheck'

#13 · closed · 1 comments

View on GitHub ↗

voaneves

Hello, I encountered an error today while trying to execute python run.py, in the EP1 folder: ``` Traceback (most recent call last): File "C:\Users\victo\OneDrive\Desktop\NLPortugues-master\NLPortugues-master\EP 1\run.py", line 11, in <module> from word2vec import * File "C:\Users\victo\OneDrive\Desktop\NLPortugues-master\NLPortugues-master\EP 1\word2vec.py", line 6, in <module> from utils.gradcheck import gradcheck_naive, grad_tests_softmax, grad_tests_negsamp ModuleNotFoundError: No module named 'utils.gradcheck' ``` Is it safe to remove the import line for utils? The necessary functionalities from utils are already implemented throughout the file. Thanks!

Comments

voaneves

I've also encountered an issue in the `treebank.py` script within the B2WSentiment class, particularly related to file path handling and CSV reading. The original code snippet is as follows: ``` class B2WSentiment: def __init__(self, path=None, tablesize=1000000): if not path: path = "data/B2W-Reviews01.csv" self.path = path self.df = pd.read_csv(path, nrows=15000, sep=';')[[ "review_text", "overall_rating" ]].drop_duplicates(subset=['review_text']) self.tablesize = tablesize ``` While this works well in certain environments (like linux), it wasn`t working on windows, throwing erros about the `overall_rating` column (that doesn't exist) and also the file name that changed. To enhance portability and ensure more consistent behavior across different operating systems, I propose the following modifications: ``` class B2WSentiment: def __init__(self, path=None, tablesize=1000000): if not path: path = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', 'data/b2w.csv')) self.path = path self.df = pd.read_csv(path, nrows=15000, sep=',', quotechar='"')[[ "review_text", "rating" ]].drop_duplicates(subset=['review_text']) self.tablesize = tablesize ``` @alan-barzilay , could you please review these changes? Your insights would be greatly appreciated to ensure the best practices and optimal functionality!