1 // Copyright 2017 The TensorFlow Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 // =============================================================================
15 #ifndef TENSORFLOW_CONTRIB_BOOSTED_TREES_LIB_TESTUTIL_BATCH_FEATURES_TESTUTIL_H_
16 #define TENSORFLOW_CONTRIB_BOOSTED_TREES_LIB_TESTUTIL_BATCH_FEATURES_TESTUTIL_H_
17 
18 #include "tensorflow/contrib/boosted_trees/lib/utils/batch_features.h"
19 #include "tensorflow/core/framework/tensor.h"
20 #include "tensorflow/core/lib/random/simple_philox.h"
21 
22 namespace tensorflow {
23 namespace boosted_trees {
24 namespace testutil {
25 
26 // This method calls Initialize on the given 'batch_features', which will be
27 // populated with randomly generated feature values when the call returns.
28 // 'tensors' returns a vector of all tensors used in the initialization,
29 // because they must outlive 'batch_features'.
30 //
31 // All float features will be either missing or uniformly randomly chosen
32 // from [0, 1). For sparse (float) features, a sparsity is uniformly randomly
33 // chosen from ['sparsity_lo', 'sparsity_hi') per feature, and each instance
34 // will have a probability of sparsity of missing that feature, in other words,
35 // sparsity = 1 - density.
36 void RandomlyInitializeBatchFeatures(
37     tensorflow::random::SimplePhilox* rng, uint32 num_dense_float_features,
38     uint32 num_sparse_float_features, double sparsity_lo, double sparsity_hi,
39     boosted_trees::utils::BatchFeatures* batch_features);
40 
41 }  // namespace testutil
42 }  // namespace boosted_trees
43 }  // namespace tensorflow
44 
45 #endif  // TENSORFLOW_CONTRIB_BOOSTED_TREES_LIB_TESTUTIL_BATCH_FEATURES_TESTUTIL_H_
46