smousavi05 / EQTransformer

EQTransformer, a python package for earthquake signal detection and phase picking using AI.
https://rebrand.ly/EQT-documentations
MIT License
301 stars 148 forks source link

TF2.5 class_weight error #162

Open Pengling2022 opened 9 months ago

Pengling2022 commented 9 months ago

Dear Dr. S.Mostafa Mousavi, hello!

I have encountered some tough problems in the process of trying to improve EQTransformer. I hope to get your reply.

I can successfully run Tensorflow=2.0.0+EQTransformer=0.1.59, but I can't use the GPU because my GPU is RTX3060

It is found that RTX3060 only supports CUDA>=11.1, in which case Tensorflow>=2.4 is required. An error occurs when I try to use Tensorflow=2.5.0+EQTransformer=0.1.61: class_weight is only supported for Models with a single output.

The specific location of the error is: trainer.py history = model.fit_generator(generator=training_generator, validation_data=validation_generator, use_multiprocessing=args['use_multiprocessing'], workers=multiprocessing.cpu_count(), callbacks=callbacks, epochs=args['epochs'], class_weight={0: 0.11, 1: 0.89}) data_adapter.py def _class_weights_map_fn(*data): """Convert class_weight to sample_weight.""" x, y, sw = unpack_x_y_sample_weight(data)

if nest.is_nested(y): raise ValueError( "class_weight is only supported for Models with a single output.")

I inquired the source code and found that this error was actually caused by TF update, but I had to use GPU again, so is there any good solution? Did you encounter this error with TF=2.5.0?

Thank you very much!