smousavi05 / EQTransformer

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

Problem with train function: training didn't start #142

Closed Andry92 closed 2 years ago

Andry92 commented 2 years ago

Dear @smousavi05,

I try to resume the issue briefly. I am encountered in this error when I start the training with the samples that you provide (100samples.hdf5 and 100samples.csv):

ValueError:class_weightis only supported for Models with a single output.

By searching online, I found that the problem was caused by tensorflow version, so I did the downgrade to the version 2.1.0 (with numpy 1.19.5). After this, I'm encountered in another error:

ValueError: Unknown entries in class_weight dictionary: [0, 1]. Only expected following keys: ['detector', 'picker_P', 'picker_S']

The line of code line that gave me the error was the number 323 in the trainer.py file. I changed the class_weight parameter from:

class_weight={0: 0.11, 1: 0.89})

to:

class_weight={'detector': 0.09, 'picker_P': 0.45, 'picker_S': 0.46})

then, the training starts. So, I think that there is an issue in the code because you give to the model 2 class_weight while it expects 3; I don't know if this is caused from the tensorflow version that I'm using.

Let me know what do you think.

Thank you in advance

smousavi05 commented 2 years ago

@Andry92 thanks for sharing this. Yes, as you correctly pointed out, the issue is regarding the TF versions. So to update EqT accordingly I have applied some changes to the EqT version on the GitHub page. So there are two different versions of EqT working with two different versions of TF. One on the pip and anaconda which works with older TF and the other one on the GitHub page which works with later TF. So there might be some discrepancies among these versions regarding the hyperparameters.

Andry92 commented 2 years ago

Thank you @smousavi05 I hope that this issue could be help someone else.