-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathdata_utils_test.py
48 lines (39 loc) · 1.56 KB
/
data_utils_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Copyright 2022 DeepMind Technologies Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Tests for data utilities."""
from absl.testing import absltest
from absl.testing import parameterized
import chex
import ml_collections as collections
import data as cpdata
import data_utils as cpdatautils
DATA_DIR = './data/'
class DataUtilsTest(parameterized.TestCase):
@parameterized.parameters([
dict(cifar_augmentation='standard+autoaugment+cutout'),
])
def test_apply_cifar_augmentation(self, cifar_augmentation):
batch_size = 100
data = cpdata.load_data_split(
'cifar10', val_examples=50000 - batch_size, data_dir=DATA_DIR)
config = collections.ConfigDict()
config.cifar_augmentation = cifar_augmentation
ds = cpdatautils.apply_cifar_augmentation(
config, data['train'], data['shape'])
ds = ds.batch(batch_size)
inputs, _ = next(cpdata.load_batches(ds))
chex.assert_shape(inputs, (batch_size, 32, 32, 3))
if __name__ == '__main__':
absltest.main()