Skip to content

AssertionError when do augment policy #30

@monkeyDemon

Description

@monkeyDemon

I write a simple script like this:

import os
from deepaugment import DeepAugment
from keras.datasets import cifar10

(x_train, y_train), (x_test, y_test) = cifar10.load_data()
deepaug = DeepAugment(x_train, y_train)
best_policies = deepaug.optimize(300)

after run it, about one minute, I got a AssertionError:

...
...
Epoch 48/50
 - 1s - loss: 0.2101 - acc: 0.9382 - val_loss: 2.6119 - val_acc: 0.5540
Epoch 49/50
 - 1s - loss: 0.2101 - acc: 0.9347 - val_loss: 2.7725 - val_acc: 0.5430
Epoch 50/50
 - 1s - loss: 0.2075 - acc: 0.9388 - val_loss: 1.9880 - val_acc: 0.5510
fit()'s runtime:  55.3912 sec.
0, 0.567111111190584, ['rotate', 0.0, 'rotate', 0.0, 'rotate', 0.0, 'rotate', 0.0, 'rotate', 0.0, 'rotate', 0.0, 'rotate', 0.0, 'rotate', 0.0, 'rotate', 0.0, 'rotate', 0.0]
('trial:', 1, '\n', ['gamma-contrast', 0.8442657485810175, 'coarse-salt-pepper', 0.8472517387841256, 'brighten', 0.38438170729269994, 'translate-y', 0.056712977317443194, 'translate-y', 0.47766511732135, 'add-to-hue-and-saturation', 0.47997717237505744, 'emboss', 0.8360787635373778, 'sharpen', 0.6481718720511973, 'emboss', 0.9571551589530466, 'rotate', 0.8700872583584366])
Traceback (most recent call last):
  File "test.py", line 29, in <module>
    best_policies = deepaug.optimize(300)
  File "/data/ansheng/cv_strategy/autoML/deep_augment/deepaugment-master/deepaugment/deepaugment.py", line 151, in optimize
    f_val = self.objective_func.evaluate(trial_no, trial_hyperparams)
  File "/data/ansheng/cv_strategy/autoML/deep_augment/deepaugment-master/deepaugment/objective.py", line 44, in evaluate
    self.data["X_train"], self.data["y_train"], *trial_hyperparams
  File "/data/ansheng/cv_strategy/autoML/deep_augment/deepaugment-master/deepaugment/augmenter.py", line 166, in augment_by_policy
    ), "first transform is unvalid"
AssertionError: first transform is unvalid

The code that throw Error is:

X_portion_aug = transform(hyperparams[i], hyperparams[i+1], X_portion)  # first transform
assert (
    X_portion_aug.min() >= -0.1 and X_portion_aug.max() <= 255.1
), "first transform is unvalid"

It seems the code after data-augmentation is out of range [0,255].

So if the function augment_by_policy() in augmenter.py has some bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions