google-research

Форк
0
56 строк · 2.0 Кб
1
# coding=utf-8
2
# Copyright 2024 The Google Research Authors.
3
#
4
# Licensed under the Apache License, Version 2.0 (the "License");
5
# you may not use this file except in compliance with the License.
6
# You may obtain a copy of the License at
7
#
8
#     http://www.apache.org/licenses/LICENSE-2.0
9
#
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS,
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
# See the License for the specific language governing permissions and
14
# limitations under the License.
15

16
"""Tests for criteo.data_lib."""
17

18
from __future__ import absolute_import
19
from __future__ import division
20
from __future__ import print_function
21

22
from absl.testing import absltest
23
import six
24
from six.moves import range
25
import tensorflow.compat.v2 as tf
26

27
from uq_benchmark_2019.criteo import data_lib
28

29

30
class DataLibTest(absltest.TestCase):
31

32
  def test_build_dataset(self):
33
    config = data_lib.DataConfig(split='train', fake_data=True)
34
    dataset = data_lib.build_dataset(config, batch_size=8,
35
                                     is_training=False, fake_training=False)
36

37
    # Check output_shapes.
38
    features_shapes, label_shape = dataset.output_shapes
39
    self.assertEqual([None], label_shape.as_list())
40
    expected_keys = [data_lib.feature_name(i)
41
                     for i in range(1, data_lib.NUM_TOTAL_FEATURES+1)]
42
    self.assertSameElements(expected_keys, list(features_shapes.keys()))
43
    for key, shape in six.iteritems(features_shapes):
44
      self.assertEqual([None], shape.as_list(), 'Unexpected shape at key='+key)
45

46
    # Check output_types.
47
    features_types, label_type = tf.compat.v1.data.get_output_types(dataset)
48
    self.assertEqual(tf.float32, label_type)
49
    for idx in data_lib.INT_FEATURE_INDICES:
50
      self.assertEqual(tf.float32, features_types[data_lib.feature_name(idx)])
51
    for idx in data_lib.CAT_FEATURE_INDICES:
52
      self.assertEqual(tf.string, features_types[data_lib.feature_name(idx)])
53

54

55
if __name__ == '__main__':
56
  absltest.main()
57

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.