webis-de / small-text

Active Learning for Text Classification in Python
https://small-text.readthedocs.io/
MIT License
557 stars 61 forks source link

arrays doesn't match. #1

Closed aditya624 closed 3 years ago

aditya624 commented 3 years ago

I tried multi classification, but the following error occurs when training. any solution?.

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-97-34924934fd19> in <module>
      1 logging.getLogger('small_text').setLevel(logging.INFO)
----> 2 main()

<ipython-input-96-e3cc4fd7354b> in main()
     30         for i in range(20):
     31             # ...where each iteration consists of labelling 20 samples
---> 32             q_indices = active_learner.query(num_samples=20, x=train)
     33 
     34             # Simulate user interaction here. Replace this for real-world usage.

/opt/anaconda3/envs/small_text/lib/python3.7/site-packages/small_text-1.0.0a4-py3.7.egg/small_text/active_learner.py in query(self, num_samples, x, query_strategy_kwargs)
    175 
    176         self.mask = np.ones(size, bool)
--> 177         self.mask[np.concatenate([self.x_indices_labeled, self.x_indices_ignored])] = False
    178         indices = np.arange(size)
    179 

<__array_function__ internals> in concatenate(*args, **kwargs)

ValueError: all the input arrays must have same number of dimensions, but the array at index 0 has 1 dimension(s) and the array at index 1 has 0 dimension(s)
chschroeder commented 3 years ago

Hi Aditya,

thank you very much for reporting this problem!

Some parts of the examples seem to have not been adapted to recent changes. I fixed this just now and released 1.0.0a6. If you reinstall now (pip install small-text[pytorch]==1.0.0.a6) this problem should be solved.

In case you are using a newer pytorch version, also have a look at issue #2 (and downgrade pytorch if necessary).

aditya624 commented 3 years ago

Thank you. this works. :)

Hi Aditya,

thank you very much for reporting this problem!

Some parts of the examples seem to have not been adapted to recent changes. I fixed this just now and released 1.0.0a6. If you reinstall now (pip install small-text[pytorch]==1.0.0.a6) this problem should be solved.

In case you are using a newer pytorch version, also have a look at issue #2 (and downgrade pytorch if necessary).