rosasalberto/mil

Error Training DeepAttentionMIL

AaronMcDaniel opened this issue · 0 comments

(bags_train, y_train), (bags_test, y_test) = musk1.load()
trainer = Trainer()
metrics = [AUC, BinaryAccuracy]
model = AttentionDeepPoolingMil(gated=False, threshold=0.4)
pipeline = [('scale', StandarizerBagsList()), ('padding', Padding())]
trainer.prepare(model, preprocess_pipeline=pipeline ,metrics=metrics)
valid = KFold(n_splits=10, shuffle=True)
history = trainer.fit(bags_train, y_train, validation_strategy=valid, sample_weights='balanced',
                              verbose=1, model__epochs=10, model__batch_size=2, model__verbose=0)

gives the following error:

Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "C:\Users\amcdaniel39\Anaconda3\envs\emade37\lib\site-packages\mil\trainer\trainer.py", line 124, in fit
    self.__eval_training_data(X_train, y_train, **kwargs)
  File "C:\Users\amcdaniel39\Anaconda3\envs\emade37\lib\site-packages\mil\trainer\trainer.py", line 157, in __eval_training_data
    self.pipeline.fit(X_train, y_train, model__sample_weight=sample_weights, **kwargs)
  File "C:\Users\amcdaniel39\Anaconda3\envs\emade37\lib\site-packages\sklearn\pipeline.py", line 346, in fit
    self._final_estimator.fit(Xt, y, **fit_params_last_step)
  File "C:\Users\amcdaniel39\Anaconda3\envs\emade37\lib\site-packages\tensorflow\python\keras\wrappers\scikit_learn.py", line 223, in fit
    return super(KerasClassifier, self).fit(x, y, **kwargs)
  File "C:\Users\amcdaniel39\Anaconda3\envs\emade37\lib\site-packages\tensorflow\python\keras\wrappers\scikit_learn.py", line 166, in fit
    history = self.model.fit(x, y, **fit_args)
  File "C:\Users\amcdaniel39\Anaconda3\envs\emade37\lib\site-packages\tensorflow\python\keras\engine\training.py", line 709, in fit
    shuffle=shuffle)
  File "C:\Users\amcdaniel39\Anaconda3\envs\emade37\lib\site-packages\tensorflow\python\keras\engine\training.py", line 2673, in _standardize_user_data
    exception_prefix='target')
  File "C:\Users\amcdaniel39\Anaconda3\envs\emade37\lib\site-packages\tensorflow\python\keras\engine\training_utils.py", line 346, in standardize_input_data
    str(len(data)) + ' arrays: ' + str(data)[:200] + '...')
ValueError: Error when checking model target: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 2 array(s), but instead got the following list of 1
arrays: ...

The error implies that the model expects 2 inputs for training labels, while the example for DeepAttentionMIL has a single input. I am using TensoerFlow V1.14.0, and sklearn v0.24.2. is there a specific version that should be used for either of those dependancies?