Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'Predictor' object has no attribute 'model' #1

Open
afergadis opened this issue Jan 26, 2018 · 4 comments
Open

AttributeError: 'Predictor' object has no attribute 'model' #1

afergadis opened this issue Jan 26, 2018 · 4 comments
Assignees

Comments

@afergadis
Copy link

Running the baseline.py I get the error in the title. More precisely the log is the following

models/baseline:using ConllEvaluator for NCBI-disease-IOB-train
models/baseline:using ConllEvaluator for NCBI-disease-IOB-test
Epoch 1/20
135701/135701 [==============================] - 8s - loss: 0.1265 - acc: 0.9620       
models/baseline:Ep: 1 8s (start 2018-01-26 13:31:20, end 2018-01-26 13:31:29)
Traceback (most recent call last):
 File "models/baseline.py", line 71, in <module>
   verbose=config.verbosity
 File "/home/aris/py_envs/py2/local/lib/python2.7/site-packages/keras/engine/training.py", line 1196, in fit
   initial_epoch=initial_epoch)
 File "/home/aris/py_envs/py2/local/lib/python2.7/site-packages/keras/engine/training.py", line 867, in _fit_loop
   callbacks.on_epoch_begin(epoch)
 File "/home/aris/py_envs/py2/local/lib/python2.7/site-packages/keras/callbacks.py", line 62, in on_epoch_begin
   callback.on_epoch_begin(epoch, logs)
 File "/home/aris/biotools/MTL-Bioinformatics-2016/models/ltlib/callbacks.py", line 54, in on_epoch_begin
   callback.on_epoch_begin(*args, **kwargs)
 File "/home/aris/biotools/MTL-Bioinformatics-2016/models/ltlib/callbacks.py", line 31, in on_epoch_begin
   self.after_epoch_end(self.epoch)
 File "/home/aris/biotools/MTL-Bioinformatics-2016/models/ltlib/callbacks.py", line 137, in after_epoch_end
   predictions = self.model.predict(self.dataitems.inputs)
AttributeError: 'Predictor' object has no attribute 'model'

Indeed in line 137 of the callbacks.py there is an attempt to use self.model but call Predictor is never assigned a model in the token_evaluator function, line 200.

@GamalC GamalC self-assigned this Feb 13, 2018
@stelmath
Copy link

same issue here

@stelmath
Copy link

I think inside class CallbackChain(Callback), you should change the function _set_model() into:


    def set_model(self, *args, **kwargs):
        for callback in self._callbacks:
            callback.set_model(*args, **kwargs)

this allows the custom callback to access self.model

@GamalC
Copy link
Collaborator

GamalC commented Aug 25, 2020

Hi @stelmath, thanks for the suggestion. Did that work for you?

@stelmath
Copy link

Yes, works fine for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants