NTMC-Community / MatchZoo

Facilitating the design, comparison and sharing of deep text matching models.
Apache License 2.0
3.84k stars 898 forks source link

ValueError: Validator not satifised. #685

Closed jibrilfrej closed 5 years ago

jibrilfrej commented 5 years ago

Describe the bug

Please provide a clear and concise description of what the bug is. If applicable, add screenshots to help explain your problem, especially for visualization related problems.

I am on matchzoo 2.0.0 and when I try to play with the code found in model_tuning.ipynb, i get an error when trying to tune the model.

To Reproduce

Please provide a Minimal, Complete, and Verifiable example here. We hope we can simply copy/paste/run it. It is also nice to share a hosted runnable script (e.g. Google Colab), especially for hardware-related problems.

import matchzoo as mz
import pandas as pd

train_data_pack = mz.datasets.wiki_qa.load_data(stage='train', task='ranking')
test_data_pack = mz.datasets.wiki_qa.load_data(stage='test', task='ranking')

preprocessor = mz.models.DenseBaseline.get_default_preprocessor()
train = preprocessor.fit_transform(train_data_pack, verbose=0)
test = preprocessor.transform(test_data_pack, verbose=0)

model = mz.models.DenseBaseline()
model.params['input_shapes'] = preprocessor.context['input_shapes']
model.params['task'] = mz.tasks.Ranking()

tuner = mz.auto.Tuner(
    params=model.params,
    train_data=train,
    test_data=test,
    num_runs=5
)
ValueError                                Traceback (most recent call last)
<ipython-input-7-d047b92d3eb1> in <module>
      3     train_data=train,
      4     test_data=test,
----> 5     num_runs=5
      6 )

~/anaconda3/envs/python3.6-env/lib/python3.6/site-packages/matchzoo/auto/tuner.py in __init__(self, **kwargs)
     20 
     21         self._params.add(engine.Param(
---> 22             'model', validator=self._validate_model
     23         ))
     24         self._params.add(engine.Param(

~/anaconda3/envs/python3.6-env/lib/python3.6/site-packages/matchzoo/engine/param.py in __init__(self, name, value, hyper_space, validator, desc)
    127         self.validator = validator
    128         self.hyper_space = hyper_space
--> 129         self.value = value
    130 
    131     @property

~/anaconda3/envs/python3.6-env/lib/python3.6/site-packages/matchzoo/engine/param.py in value(self, new_value)
    152         if self._pre_assignment_hook:
    153             new_value = self._pre_assignment_hook(new_value)
--> 154         self._validate(new_value)
    155         self._value = new_value
    156         if not self._pre_assignment_hook:

~/anaconda3/envs/python3.6-env/lib/python3.6/site-packages/matchzoo/engine/param.py in _validate(self, value)
    200                 error_msg += "The validator's definition is as follows:\n"
    201                 error_msg += inspect.getsource(self._validator).strip()
--> 202                 raise ValueError(error_msg)
    203 
    204     def __bool__(self):

ValueError: Validator not satifised.
The validator's definition is as follows:
@classmethod
    def _validate_model(cls, model):
        if not isinstance(model, engine.BaseModel):
            return False
        elif not model.params.hyper_space:
            print("Model hyper space empty.")
            return False
        else:
            return True

Describe your attempts

You should also provide code snippets you tried as a workaround, StackOverflow solution that you have walked through, or your best guess of the cause that you can't locate (e.g. cosmic radiation).

Context

In addition, figure out your MatchZoo version by running import matchzoo; matchzoo.__version__. If this gives you an error, then you're probably using 1.0, and 1.0 is no longer supported. Then attach the corresponding label on the issue.

Additional Information

Other things you want the developers to know.

uduse commented 5 years ago

You're running the newer version of the tutorial on the old version of matchzoo. Please make sure your code base is updated to the master branch.

jibrilfrej commented 5 years ago

ok thanks I installed matchzoo with pip maybe thats why