Farm: Missing calculate_class_weights definition in StreamingDataSilo class

Created on 1 May 2020  路  2Comments  路  Source: deepset-ai/FARM

Hi all,

first of all - thanks for this great project! I am currently trying to adapt the text_pair_classification.py example to my own use case. Due to a large dataset, I want to make use of the StreamingDataSilo class and using a StreamingDataSilo object instead of the traditional DataSilo object.

Executing with the StreamingDataSilo object throws this error:

Traceback (most recent call last):
  File "text_pair_classification.py", line 126, in <module>
    text_pair_classification()
  File "text_pair_classification.py", line 75, in text_pair_classification
    class_weights=data_silo.calculate_class_weights(
AttributeError: 'StreamingDataSilo' object has no attribute 'calculate_class_weights'

Looking into FARM/farm/data_handler/data_silo.py, there is, in fact, no definition for calculate_class_weight for the StreamingDataSilo class compared to the DataSilo class.

Simply copying the method from the DataSilo class does not resolve the problem as the following error is thrown then:

Traceback (most recent call last):
  File "text_pair_classification.py", line 126, in <module>
    text_pair_classification()
  File "text_pair_classification.py", line 76, in text_pair_classification
    task_name="text_classification"),
  File "/home/nialde/FARM_framework/FARM/farm/data_handler/data_silo.py", line 585, in calculate_class_weights
    tensor_idx = list(self.tensor_names).index(tensor_name)
AttributeError: 'StreamingDataSilo' object has no attribute 'tensor_names'

Is there any wrong assumption on how to use the StreamingDataSilo object or is this a bug?
(With the normal DataSilo object, the code runs smoothly.)

Cheers,
Nicolas

bug

Most helpful comment

Misunderstood the calculate_weights function - obviously it cannot be used if the dataset is not fully known yet. I set the weights manually.

All 2 comments

Misunderstood the calculate_weights function - obviously it cannot be used if the dataset is not fully known yet. I set the weights manually.

Awesome.
This is exactly how we would wish issues to be handled! : )
Thanks @NicolasBenjamin

Could you see another way of inserting the functionality into the streamingdatasilo though - does it make sense to approximate the weights on the first batch? If you find a good solution we would be happy if you raise a PR.

Was this page helpful?
0 / 5 - 0 ratings