hfawaz/InceptionTime

TypeError: 'str' object cannot be interpreted as an integer

czarmanu opened this issue · 7 comments

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pandas/core/indexes/base.py", line 2566, in get_value
return libts.get_value_box(s, key)
File "pandas/_libs/tslib.pyx", line 1017, in pandas._libs.tslib.get_value_box
File "pandas/_libs/tslib.pyx", line 1025, in pandas._libs.tslib.get_value_box
TypeError: 'str' object cannot be interpreted as an integer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "main.py", line 117, in
fit_classifier()
File "main.py", line 49, in fit_classifier
classifier.fit(x_train, y_train, x_test, y_test, y_true)
File "/home/pf/pfstaff/projects/LakeIce_2/Experiments/GeoLocalize/InceptionTime/classifiers/inception.py", line 145, in fit
plot_test_acc=plot_test_acc)
File "/home/pf/pfstaff/projects/LakeIce_2/Experiments/GeoLocalize/InceptionTime/utils/utils.py", line 211, in save_logs
df_best_model['best_model_train_acc'] = row_best_model['acc']
File "/usr/lib/python3/dist-packages/pandas/core/series.py", line 623, in getitem
result = self.index.get_value(self, key)
File "/usr/lib/python3/dist-packages/pandas/core/indexes/base.py", line 2574, in get_value
raise e1
File "/usr/lib/python3/dist-packages/pandas/core/indexes/base.py", line 2560, in get_value
tz=getattr(series.dtype, 'tz', None))
File "pandas/_libs/index.pyx", line 83, in pandas._libs.index.IndexEngine.get_value
File "pandas/_libs/index.pyx", line 91, in pandas._libs.index.IndexEngine.get_value
File "pandas/_libs/index.pyx", line 139, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/hashtable_class_helper.pxi", line 1265, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas/_libs/hashtable_class_helper.pxi", line 1273, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'acc'

Thanks for posting, what command did you run ?

python3 main.py InceptionTime

How does this issue relate to the other one you have just opened ?

Did you resolve this one ?

I am trying on two machines:

  1. Cluster with GTX 1080 Ti (This issue is solved when i did pip3 install pandas==0.23.0) which throws out [the other error]
  2. Local PC with GTX 1080 Ti (This issue still exist even after the pip as above)

Okay I think I cannot help with this error as I am not able to re-produce it.

I will check out the other error ASAP.

I guess the problem on your local machine has something to do with your python environment.

It worked fine when the panda version was upgraded to 0.25.1 and the following change was done in utils.py:

if 'acc' in row_best_model.index:
df_best_model['best_model_train_acc'] = row_best_model['acc']
else:
df_best_model['best_model_train_acc'] = 0

same issue here.
I fixed it by changing two lines of code:

 df_best_model['best_model_train_acc'] = row_best_model['accuracy']
 if plot_test_acc:
     df_best_model['best_model_val_acc'] = row_best_model['val_accuracy']

I guess this problem is due to the version of pandas or something because I did not install all the lib in requirements.txt. You can print row_best_model to check it out.

Hope it helps.