YerevaNN / Dynamic-memory-networks-in-Theano

Implementation of Dynamic memory networks by Kumar et al. http://arxiv.org/abs/1506.07285
MIT License
333 stars 111 forks source link

TypeError: float() argument must be a string or a number, not 'map' #9

Closed KaranBulani closed 5 years ago

KaranBulani commented 5 years ago

While testing the model using command on cmd:

python main.py --network dmn_basic --mode test --babi_id 1 --load_state states/dmn_basic.mh5.n40.babi1.epoch4.test0.00033.state

the error which occurs is:

Traceback (most recent call last):
  File "main.py", line 72, in <module>
    dmn = dmn_basic.DMN_basic(**args_dict)
  File "C:\Users\Karan\Desktop\DMT\dmn_basic.py", line 38, in __init__
    self.train_input, self.train_q, self.train_answer, self.train_input_mask = self._process_input(babi_train_raw)
  File "C:\Users\Karan\Desktop\DMT\dmn_basic.py", line 299, in _process_input
    inputs.append(np.vstack(inp_vector).astype(floatX))
TypeError: float() argument must be a string or a number, not 'map'

Whole CMD output is:

C:\Users\Karan\Desktop\DMT>python main.py --network dmn_basic --mode test --babi_id 1 --load_state states/dmn_basic.mh5.n40.babi1.epoch4.test0.00033.state
C:\Users\Karan\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy\core\__init__.py:29: UserWarning: loaded more than 1 DLL from .libs:
C:\Users\Karan\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy\.libs\libopenblas.IPBC74C7KURV7CB2PKT5Z5FNR3SIBV4J.gfortran-win_amd64.dll
C:\Users\Karan\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy\.libs\libopenblas.TXA6YQSD3GCQQC22GEQ54J2UDCXDXHWN.gfortran-win_amd64.dll
  stacklevel=1)
WARNING (theano.configdefaults): g++ not available, if using conda: `conda install m2w64-toolchain`
C:\Users\Karan\AppData\Local\Programs\Python\Python36\lib\site-packages\theano\configdefaults.py:560: UserWarning: DeprecationWarning: there is no c++ compiler.This is deprecated and with Theano 0.11 a c++ compiler will be mandatory
  warnings.warn("DeprecationWarning: there is no c++ compiler."
WARNING (theano.configdefaults): g++ not detected ! Theano will be unable to execute optimized C-implementations (for both CPU and GPU) and will default to Python implementations. Performance will be severely degraded. To remove this warning, set Theano flags cxx to an empty string.
WARNING (theano.tensor.blas): Using NumPy C-API based implementation for BLAS functions.
==> parsing input arguments
Namespace(answer_module='feedforward', babi_id='1', babi_test_id='', batch_norm=False, batch_size=10, dim=40, dropout=0.0, epochs=500, input_mask_mode='sentence', l2=0, load_state='states/dmn_basic.mh5.n40.babi1.epoch4.test0.00033.state', log_every=1, memory_hops=5, mode='test', network='dmn_basic', normalize_attention=False, prefix='', save_every=1, shuffle=True, word_vector_size=50)
==> Loading test from C:\Users\Karan\Desktop\DMT\data/en/qa1_single-supporting-fact_train.txt
==> Loading test from C:\Users\Karan\Desktop\DMT\data/en/qa1_single-supporting-fact_test.txt
==> loading glove
==> glove is loaded
==> no minibatch training, argument batch_size is useless
==> not used params in DMN class: dict_keys(['babi_id', 'babi_test_id', 'batch_norm', 'batch_size', 'dropout', 'epochs', 'load_state', 'log_every', 'network', 'prefix', 'save_every', 'shuffle'])
Traceback (most recent call last):
  File "main.py", line 72, in <module>
    dmn = dmn_basic.DMN_basic(**args_dict)
  File "C:\Users\Karan\Desktop\DMT\dmn_basic.py", line 38, in __init__
    self.train_input, self.train_q, self.train_answer, self.train_input_mask = self._process_input(babi_train_raw)
  File "C:\Users\Karan\Desktop\DMT\dmn_basic.py", line 299, in _process_input
    inputs.append(np.vstack(inp_vector).astype(floatX))
TypeError: float() argument must be a string or a number, not 'map'

Error is in this section of code in dwn_basic.py and at _process_input function

inputs.append(np.vstack(inp_vector).astype(floatX)) questions.append(np.vstack(q_vector).astype(floatX))

i have solved all the print statement related errors, i am using _pickle instead of cPickle as cPickle was in python 2 and i am currently on python 3. another error which i solved is:

UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 2273: character maps to <undefined>

by adding encoding="utf8" in utils.py under load_glove(dim) function This is the changed code: with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), "data/glove/glove.6B." + str(dim) + "d.txt"),encoding="utf8") as f:

I want to know how to solve (not 'map') above error and are my changes done to code responsible for it?

KaranBulani commented 5 years ago

i just had to install Mingdw on windows 10