easy-cs-rec-custommodel 0.8.6__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of easy-cs-rec-custommodel might be problematic. Click here for more details.
- easy_cs_rec_custommodel-0.8.6.dist-info/LICENSE +203 -0
- easy_cs_rec_custommodel-0.8.6.dist-info/METADATA +48 -0
- easy_cs_rec_custommodel-0.8.6.dist-info/RECORD +336 -0
- easy_cs_rec_custommodel-0.8.6.dist-info/WHEEL +6 -0
- easy_cs_rec_custommodel-0.8.6.dist-info/top_level.txt +2 -0
- easy_rec/__init__.py +114 -0
- easy_rec/python/__init__.py +0 -0
- easy_rec/python/builders/__init__.py +0 -0
- easy_rec/python/builders/hyperparams_builder.py +78 -0
- easy_rec/python/builders/loss_builder.py +333 -0
- easy_rec/python/builders/optimizer_builder.py +211 -0
- easy_rec/python/builders/strategy_builder.py +44 -0
- easy_rec/python/compat/__init__.py +0 -0
- easy_rec/python/compat/adam_s.py +245 -0
- easy_rec/python/compat/array_ops.py +229 -0
- easy_rec/python/compat/dynamic_variable.py +542 -0
- easy_rec/python/compat/early_stopping.py +653 -0
- easy_rec/python/compat/embedding_ops.py +162 -0
- easy_rec/python/compat/embedding_parallel_saver.py +316 -0
- easy_rec/python/compat/estimator_train.py +116 -0
- easy_rec/python/compat/exporter.py +473 -0
- easy_rec/python/compat/feature_column/__init__.py +0 -0
- easy_rec/python/compat/feature_column/feature_column.py +3675 -0
- easy_rec/python/compat/feature_column/feature_column_v2.py +5233 -0
- easy_rec/python/compat/feature_column/sequence_feature_column.py +648 -0
- easy_rec/python/compat/feature_column/utils.py +154 -0
- easy_rec/python/compat/layers.py +329 -0
- easy_rec/python/compat/ops.py +14 -0
- easy_rec/python/compat/optimizers.py +619 -0
- easy_rec/python/compat/queues.py +311 -0
- easy_rec/python/compat/regularizers.py +208 -0
- easy_rec/python/compat/sok_optimizer.py +440 -0
- easy_rec/python/compat/sync_replicas_optimizer.py +528 -0
- easy_rec/python/compat/weight_decay_optimizers.py +475 -0
- easy_rec/python/core/__init__.py +0 -0
- easy_rec/python/core/easyrec_metrics/__init__.py +24 -0
- easy_rec/python/core/easyrec_metrics/distribute_metrics_impl_pai.py +3702 -0
- easy_rec/python/core/easyrec_metrics/distribute_metrics_impl_tf.py +3768 -0
- easy_rec/python/core/learning_schedules.py +228 -0
- easy_rec/python/core/metrics.py +402 -0
- easy_rec/python/core/sampler.py +844 -0
- easy_rec/python/eval.py +102 -0
- easy_rec/python/export.py +150 -0
- easy_rec/python/feature_column/__init__.py +0 -0
- easy_rec/python/feature_column/feature_column.py +664 -0
- easy_rec/python/feature_column/feature_group.py +89 -0
- easy_rec/python/hpo/__init__.py +0 -0
- easy_rec/python/hpo/emr_hpo.py +140 -0
- easy_rec/python/hpo/generate_hpo_sql.py +71 -0
- easy_rec/python/hpo/pai_hpo.py +297 -0
- easy_rec/python/inference/__init__.py +0 -0
- easy_rec/python/inference/csv_predictor.py +189 -0
- easy_rec/python/inference/hive_parquet_predictor.py +200 -0
- easy_rec/python/inference/hive_predictor.py +166 -0
- easy_rec/python/inference/odps_predictor.py +70 -0
- easy_rec/python/inference/parquet_predictor.py +147 -0
- easy_rec/python/inference/parquet_predictor_v2.py +147 -0
- easy_rec/python/inference/predictor.py +621 -0
- easy_rec/python/inference/processor/__init__.py +0 -0
- easy_rec/python/inference/processor/test.py +170 -0
- easy_rec/python/inference/vector_retrieve.py +124 -0
- easy_rec/python/input/__init__.py +0 -0
- easy_rec/python/input/batch_tfrecord_input.py +117 -0
- easy_rec/python/input/criteo_binary_reader.py +259 -0
- easy_rec/python/input/criteo_input.py +107 -0
- easy_rec/python/input/csv_input.py +175 -0
- easy_rec/python/input/csv_input_ex.py +72 -0
- easy_rec/python/input/csv_input_v2.py +68 -0
- easy_rec/python/input/datahub_input.py +320 -0
- easy_rec/python/input/dummy_input.py +58 -0
- easy_rec/python/input/hive_input.py +123 -0
- easy_rec/python/input/hive_parquet_input.py +140 -0
- easy_rec/python/input/hive_rtp_input.py +174 -0
- easy_rec/python/input/input.py +1064 -0
- easy_rec/python/input/kafka_dataset.py +144 -0
- easy_rec/python/input/kafka_input.py +235 -0
- easy_rec/python/input/load_parquet.py +317 -0
- easy_rec/python/input/odps_input.py +101 -0
- easy_rec/python/input/odps_input_v2.py +110 -0
- easy_rec/python/input/odps_input_v3.py +132 -0
- easy_rec/python/input/odps_rtp_input.py +187 -0
- easy_rec/python/input/odps_rtp_input_v2.py +104 -0
- easy_rec/python/input/parquet_input.py +397 -0
- easy_rec/python/input/parquet_input_v2.py +180 -0
- easy_rec/python/input/parquet_input_v3.py +203 -0
- easy_rec/python/input/rtp_input.py +225 -0
- easy_rec/python/input/rtp_input_v2.py +145 -0
- easy_rec/python/input/tfrecord_input.py +100 -0
- easy_rec/python/layers/__init__.py +0 -0
- easy_rec/python/layers/backbone.py +571 -0
- easy_rec/python/layers/capsule_layer.py +176 -0
- easy_rec/python/layers/cmbf.py +390 -0
- easy_rec/python/layers/common_layers.py +192 -0
- easy_rec/python/layers/dnn.py +87 -0
- easy_rec/python/layers/embed_input_layer.py +25 -0
- easy_rec/python/layers/fm.py +26 -0
- easy_rec/python/layers/input_layer.py +396 -0
- easy_rec/python/layers/keras/__init__.py +34 -0
- easy_rec/python/layers/keras/activation.py +114 -0
- easy_rec/python/layers/keras/attention.py +267 -0
- easy_rec/python/layers/keras/auxiliary_loss.py +47 -0
- easy_rec/python/layers/keras/blocks.py +262 -0
- easy_rec/python/layers/keras/bst.py +119 -0
- easy_rec/python/layers/keras/custom_ops.py +250 -0
- easy_rec/python/layers/keras/data_augment.py +133 -0
- easy_rec/python/layers/keras/din.py +67 -0
- easy_rec/python/layers/keras/einsum_dense.py +598 -0
- easy_rec/python/layers/keras/embedding.py +81 -0
- easy_rec/python/layers/keras/fibinet.py +251 -0
- easy_rec/python/layers/keras/interaction.py +416 -0
- easy_rec/python/layers/keras/layer_norm.py +364 -0
- easy_rec/python/layers/keras/mask_net.py +166 -0
- easy_rec/python/layers/keras/multi_head_attention.py +717 -0
- easy_rec/python/layers/keras/multi_task.py +125 -0
- easy_rec/python/layers/keras/numerical_embedding.py +376 -0
- easy_rec/python/layers/keras/ppnet.py +194 -0
- easy_rec/python/layers/keras/transformer.py +192 -0
- easy_rec/python/layers/layer_norm.py +51 -0
- easy_rec/python/layers/mmoe.py +83 -0
- easy_rec/python/layers/multihead_attention.py +162 -0
- easy_rec/python/layers/multihead_cross_attention.py +749 -0
- easy_rec/python/layers/senet.py +73 -0
- easy_rec/python/layers/seq_input_layer.py +134 -0
- easy_rec/python/layers/sequence_feature_layer.py +249 -0
- easy_rec/python/layers/uniter.py +301 -0
- easy_rec/python/layers/utils.py +248 -0
- easy_rec/python/layers/variational_dropout_layer.py +130 -0
- easy_rec/python/loss/__init__.py +0 -0
- easy_rec/python/loss/circle_loss.py +82 -0
- easy_rec/python/loss/contrastive_loss.py +79 -0
- easy_rec/python/loss/f1_reweight_loss.py +38 -0
- easy_rec/python/loss/focal_loss.py +93 -0
- easy_rec/python/loss/jrc_loss.py +128 -0
- easy_rec/python/loss/listwise_loss.py +161 -0
- easy_rec/python/loss/multi_similarity.py +68 -0
- easy_rec/python/loss/pairwise_loss.py +307 -0
- easy_rec/python/loss/softmax_loss_with_negative_mining.py +110 -0
- easy_rec/python/loss/zero_inflated_lognormal.py +76 -0
- easy_rec/python/main.py +878 -0
- easy_rec/python/model/__init__.py +0 -0
- easy_rec/python/model/autoint.py +73 -0
- easy_rec/python/model/cmbf.py +47 -0
- easy_rec/python/model/collaborative_metric_learning.py +182 -0
- easy_rec/python/model/custom_model.py +323 -0
- easy_rec/python/model/dat.py +138 -0
- easy_rec/python/model/dbmtl.py +116 -0
- easy_rec/python/model/dcn.py +70 -0
- easy_rec/python/model/deepfm.py +106 -0
- easy_rec/python/model/dlrm.py +73 -0
- easy_rec/python/model/dropoutnet.py +207 -0
- easy_rec/python/model/dssm.py +154 -0
- easy_rec/python/model/dssm_senet.py +143 -0
- easy_rec/python/model/dummy_model.py +48 -0
- easy_rec/python/model/easy_rec_estimator.py +739 -0
- easy_rec/python/model/easy_rec_model.py +467 -0
- easy_rec/python/model/esmm.py +242 -0
- easy_rec/python/model/fm.py +63 -0
- easy_rec/python/model/match_model.py +357 -0
- easy_rec/python/model/mind.py +445 -0
- easy_rec/python/model/mmoe.py +70 -0
- easy_rec/python/model/multi_task_model.py +303 -0
- easy_rec/python/model/multi_tower.py +62 -0
- easy_rec/python/model/multi_tower_bst.py +190 -0
- easy_rec/python/model/multi_tower_din.py +130 -0
- easy_rec/python/model/multi_tower_recall.py +68 -0
- easy_rec/python/model/pdn.py +203 -0
- easy_rec/python/model/ple.py +120 -0
- easy_rec/python/model/rank_model.py +485 -0
- easy_rec/python/model/rocket_launching.py +203 -0
- easy_rec/python/model/simple_multi_task.py +54 -0
- easy_rec/python/model/uniter.py +46 -0
- easy_rec/python/model/wide_and_deep.py +121 -0
- easy_rec/python/ops/1.12/incr_record.so +0 -0
- easy_rec/python/ops/1.12/kafka.so +0 -0
- easy_rec/python/ops/1.12/libcustom_ops.so +0 -0
- easy_rec/python/ops/1.12/libembed_op.so +0 -0
- easy_rec/python/ops/1.12/libhiredis.so.1.0.0 +0 -0
- easy_rec/python/ops/1.12/librdkafka++.so.1 +0 -0
- easy_rec/python/ops/1.12/librdkafka.so.1 +0 -0
- easy_rec/python/ops/1.12/libredis++.so +0 -0
- easy_rec/python/ops/1.12/libredis++.so.1 +0 -0
- easy_rec/python/ops/1.12/libredis++.so.1.2.3 +0 -0
- easy_rec/python/ops/1.12/libstr_avx_op.so +0 -0
- easy_rec/python/ops/1.12/libwrite_sparse_kv.so +0 -0
- easy_rec/python/ops/1.15/incr_record.so +0 -0
- easy_rec/python/ops/1.15/kafka.so +0 -0
- easy_rec/python/ops/1.15/libcustom_ops.so +0 -0
- easy_rec/python/ops/1.15/libembed_op.so +0 -0
- easy_rec/python/ops/1.15/libhiredis.so.1.0.0 +0 -0
- easy_rec/python/ops/1.15/librdkafka++.so +0 -0
- easy_rec/python/ops/1.15/librdkafka++.so.1 +0 -0
- easy_rec/python/ops/1.15/librdkafka.so +0 -0
- easy_rec/python/ops/1.15/librdkafka.so.1 +0 -0
- easy_rec/python/ops/1.15/libredis++.so.1 +0 -0
- easy_rec/python/ops/1.15/libstr_avx_op.so +0 -0
- easy_rec/python/ops/2.12/libcustom_ops.so +0 -0
- easy_rec/python/ops/2.12/libload_embed.so +0 -0
- easy_rec/python/ops/2.12/libstr_avx_op.so +0 -0
- easy_rec/python/ops/__init__.py +0 -0
- easy_rec/python/ops/gen_kafka_ops.py +193 -0
- easy_rec/python/ops/gen_str_avx_op.py +28 -0
- easy_rec/python/ops/incr_record.py +30 -0
- easy_rec/python/predict.py +170 -0
- easy_rec/python/protos/__init__.py +0 -0
- easy_rec/python/protos/autoint_pb2.py +122 -0
- easy_rec/python/protos/backbone_pb2.py +1416 -0
- easy_rec/python/protos/cmbf_pb2.py +435 -0
- easy_rec/python/protos/collaborative_metric_learning_pb2.py +252 -0
- easy_rec/python/protos/custom_model_pb2.py +57 -0
- easy_rec/python/protos/dat_pb2.py +262 -0
- easy_rec/python/protos/data_source_pb2.py +422 -0
- easy_rec/python/protos/dataset_pb2.py +1920 -0
- easy_rec/python/protos/dbmtl_pb2.py +191 -0
- easy_rec/python/protos/dcn_pb2.py +197 -0
- easy_rec/python/protos/deepfm_pb2.py +163 -0
- easy_rec/python/protos/dlrm_pb2.py +163 -0
- easy_rec/python/protos/dnn_pb2.py +329 -0
- easy_rec/python/protos/dropoutnet_pb2.py +239 -0
- easy_rec/python/protos/dssm_pb2.py +262 -0
- easy_rec/python/protos/dssm_senet_pb2.py +282 -0
- easy_rec/python/protos/easy_rec_model_pb2.py +1672 -0
- easy_rec/python/protos/esmm_pb2.py +133 -0
- easy_rec/python/protos/eval_pb2.py +930 -0
- easy_rec/python/protos/export_pb2.py +379 -0
- easy_rec/python/protos/feature_config_pb2.py +1359 -0
- easy_rec/python/protos/fm_pb2.py +90 -0
- easy_rec/python/protos/hive_config_pb2.py +138 -0
- easy_rec/python/protos/hyperparams_pb2.py +624 -0
- easy_rec/python/protos/keras_layer_pb2.py +692 -0
- easy_rec/python/protos/layer_pb2.py +1936 -0
- easy_rec/python/protos/loss_pb2.py +1713 -0
- easy_rec/python/protos/mind_pb2.py +497 -0
- easy_rec/python/protos/mmoe_pb2.py +215 -0
- easy_rec/python/protos/multi_tower_pb2.py +295 -0
- easy_rec/python/protos/multi_tower_recall_pb2.py +198 -0
- easy_rec/python/protos/optimizer_pb2.py +2017 -0
- easy_rec/python/protos/pdn_pb2.py +293 -0
- easy_rec/python/protos/pipeline_pb2.py +516 -0
- easy_rec/python/protos/ple_pb2.py +231 -0
- easy_rec/python/protos/predict_pb2.py +1140 -0
- easy_rec/python/protos/rocket_launching_pb2.py +169 -0
- easy_rec/python/protos/seq_encoder_pb2.py +1084 -0
- easy_rec/python/protos/simi_pb2.py +54 -0
- easy_rec/python/protos/simple_multi_task_pb2.py +97 -0
- easy_rec/python/protos/tf_predict_pb2.py +630 -0
- easy_rec/python/protos/tower_pb2.py +661 -0
- easy_rec/python/protos/train_pb2.py +1197 -0
- easy_rec/python/protos/uniter_pb2.py +307 -0
- easy_rec/python/protos/variational_dropout_pb2.py +91 -0
- easy_rec/python/protos/wide_and_deep_pb2.py +131 -0
- easy_rec/python/test/__init__.py +0 -0
- easy_rec/python/test/csv_input_test.py +340 -0
- easy_rec/python/test/custom_early_stop_func.py +19 -0
- easy_rec/python/test/dh_local_run.py +104 -0
- easy_rec/python/test/embed_test.py +155 -0
- easy_rec/python/test/emr_run.py +119 -0
- easy_rec/python/test/eval_metric_test.py +107 -0
- easy_rec/python/test/excel_convert_test.py +64 -0
- easy_rec/python/test/export_test.py +513 -0
- easy_rec/python/test/fg_test.py +70 -0
- easy_rec/python/test/hive_input_test.py +311 -0
- easy_rec/python/test/hpo_test.py +235 -0
- easy_rec/python/test/kafka_test.py +373 -0
- easy_rec/python/test/local_incr_test.py +122 -0
- easy_rec/python/test/loss_test.py +110 -0
- easy_rec/python/test/odps_command.py +61 -0
- easy_rec/python/test/odps_local_run.py +86 -0
- easy_rec/python/test/odps_run.py +254 -0
- easy_rec/python/test/odps_test_cls.py +39 -0
- easy_rec/python/test/odps_test_prepare.py +198 -0
- easy_rec/python/test/odps_test_util.py +237 -0
- easy_rec/python/test/pre_check_test.py +54 -0
- easy_rec/python/test/predictor_test.py +394 -0
- easy_rec/python/test/rtp_convert_test.py +133 -0
- easy_rec/python/test/run.py +138 -0
- easy_rec/python/test/train_eval_test.py +1299 -0
- easy_rec/python/test/util_test.py +85 -0
- easy_rec/python/test/zero_inflated_lognormal_test.py +53 -0
- easy_rec/python/tools/__init__.py +0 -0
- easy_rec/python/tools/add_boundaries_to_config.py +67 -0
- easy_rec/python/tools/add_feature_info_to_config.py +145 -0
- easy_rec/python/tools/convert_config_format.py +48 -0
- easy_rec/python/tools/convert_rtp_data.py +79 -0
- easy_rec/python/tools/convert_rtp_fg.py +106 -0
- easy_rec/python/tools/create_config_from_excel.py +427 -0
- easy_rec/python/tools/criteo/__init__.py +0 -0
- easy_rec/python/tools/criteo/convert_data.py +157 -0
- easy_rec/python/tools/edit_lookup_graph.py +134 -0
- easy_rec/python/tools/faiss_index_pai.py +116 -0
- easy_rec/python/tools/feature_selection.py +316 -0
- easy_rec/python/tools/hit_rate_ds.py +223 -0
- easy_rec/python/tools/hit_rate_pai.py +138 -0
- easy_rec/python/tools/pre_check.py +120 -0
- easy_rec/python/tools/predict_and_chk.py +111 -0
- easy_rec/python/tools/read_kafka.py +55 -0
- easy_rec/python/tools/split_model_pai.py +286 -0
- easy_rec/python/tools/split_pdn_model_pai.py +272 -0
- easy_rec/python/tools/test_saved_model.py +80 -0
- easy_rec/python/tools/view_saved_model.py +39 -0
- easy_rec/python/tools/write_kafka.py +65 -0
- easy_rec/python/train_eval.py +325 -0
- easy_rec/python/utils/__init__.py +15 -0
- easy_rec/python/utils/activation.py +120 -0
- easy_rec/python/utils/check_utils.py +87 -0
- easy_rec/python/utils/compat.py +14 -0
- easy_rec/python/utils/config_util.py +652 -0
- easy_rec/python/utils/constant.py +43 -0
- easy_rec/python/utils/convert_rtp_fg.py +616 -0
- easy_rec/python/utils/dag.py +192 -0
- easy_rec/python/utils/distribution_utils.py +268 -0
- easy_rec/python/utils/ds_util.py +65 -0
- easy_rec/python/utils/embedding_utils.py +73 -0
- easy_rec/python/utils/estimator_utils.py +1036 -0
- easy_rec/python/utils/export_big_model.py +630 -0
- easy_rec/python/utils/expr_util.py +118 -0
- easy_rec/python/utils/fg_util.py +53 -0
- easy_rec/python/utils/hit_rate_utils.py +220 -0
- easy_rec/python/utils/hive_utils.py +183 -0
- easy_rec/python/utils/hpo_util.py +137 -0
- easy_rec/python/utils/hvd_utils.py +56 -0
- easy_rec/python/utils/input_utils.py +108 -0
- easy_rec/python/utils/io_util.py +282 -0
- easy_rec/python/utils/load_class.py +249 -0
- easy_rec/python/utils/meta_graph_editor.py +941 -0
- easy_rec/python/utils/multi_optimizer.py +62 -0
- easy_rec/python/utils/numpy_utils.py +18 -0
- easy_rec/python/utils/odps_util.py +79 -0
- easy_rec/python/utils/pai_util.py +86 -0
- easy_rec/python/utils/proto_util.py +90 -0
- easy_rec/python/utils/restore_filter.py +89 -0
- easy_rec/python/utils/shape_utils.py +432 -0
- easy_rec/python/utils/static_shape.py +71 -0
- easy_rec/python/utils/test_utils.py +866 -0
- easy_rec/python/utils/tf_utils.py +56 -0
- easy_rec/version.py +4 -0
- test/__init__.py +0 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# -*- encoding:utf-8 -*-
|
|
2
|
+
# Copyright (c) Alibaba, Inc. and its affiliates.
|
|
3
|
+
|
|
4
|
+
import argparse
|
|
5
|
+
import logging
|
|
6
|
+
import os
|
|
7
|
+
import shutil
|
|
8
|
+
import sys
|
|
9
|
+
|
|
10
|
+
import tensorflow as tf
|
|
11
|
+
|
|
12
|
+
from easy_rec.python.test.odps_command import OdpsCommand
|
|
13
|
+
from easy_rec.python.test.odps_test_prepare import prepare
|
|
14
|
+
from easy_rec.python.test.odps_test_util import OdpsOSSConfig
|
|
15
|
+
from easy_rec.python.test.odps_test_util import delete_oss_path
|
|
16
|
+
from easy_rec.python.test.odps_test_util import get_oss_bucket
|
|
17
|
+
from easy_rec.python.utils import test_utils
|
|
18
|
+
|
|
19
|
+
logging.basicConfig(
|
|
20
|
+
level=logging.INFO, format='[%(asctime)s][%(levelname)s] %(message)s')
|
|
21
|
+
|
|
22
|
+
odps_oss_config = OdpsOSSConfig(script_path='./samples/emr_script')
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class TestPipelineOnEmr(tf.test.TestCase):
|
|
26
|
+
"""Train eval test on emr."""
|
|
27
|
+
|
|
28
|
+
def setUp(self):
|
|
29
|
+
logging.info('Testing %s.%s' % (type(self).__name__, self._testMethodName))
|
|
30
|
+
self._test_hdfs_dir = test_utils.get_hdfs_tmp_dir(
|
|
31
|
+
'hdfs://emr-header-1:9000/user/easy_rec/emr_test')
|
|
32
|
+
self._success = True
|
|
33
|
+
logging.info('test hdfs dir: %s' % self._test_hdfs_dir)
|
|
34
|
+
|
|
35
|
+
def tearDown(self):
|
|
36
|
+
if self._success:
|
|
37
|
+
pass
|
|
38
|
+
test_utils.clean_up_hdfs(self._test_hdfs_dir)
|
|
39
|
+
|
|
40
|
+
def test_deepfm_train_eval_export(self):
|
|
41
|
+
start = [
|
|
42
|
+
'deep_fm/create_external_deepfm_table.sql',
|
|
43
|
+
'deep_fm/create_inner_deepfm_table.sql'
|
|
44
|
+
]
|
|
45
|
+
end = ['deep_fm/drop_table.sql']
|
|
46
|
+
odps_cmd = OdpsCommand(odps_oss_config)
|
|
47
|
+
odps_cmd.run_list(start)
|
|
48
|
+
self._success = test_utils.test_hdfs_train_eval(
|
|
49
|
+
'%s/configs/deepfm.config' % odps_oss_config.temp_dir,
|
|
50
|
+
'%s/yaml_config/train.paitf.yaml' % odps_oss_config.temp_dir,
|
|
51
|
+
self._test_hdfs_dir)
|
|
52
|
+
self.assertTrue(self._success)
|
|
53
|
+
|
|
54
|
+
self._success = test_utils.test_hdfs_eval(
|
|
55
|
+
'%s/configs/deepfm_eval_pipeline.config' % odps_oss_config.temp_dir,
|
|
56
|
+
'%s/yaml_config/eval.tf.yaml' % odps_oss_config.temp_dir,
|
|
57
|
+
self._test_hdfs_dir)
|
|
58
|
+
self.assertTrue(self._success)
|
|
59
|
+
|
|
60
|
+
self._success = test_utils.test_hdfs_export(
|
|
61
|
+
'%s/configs/deepfm_eval_pipeline.config' % odps_oss_config.temp_dir,
|
|
62
|
+
'%s/yaml_config/export.tf.yaml' % odps_oss_config.temp_dir,
|
|
63
|
+
self._test_hdfs_dir)
|
|
64
|
+
self.assertTrue(self._success)
|
|
65
|
+
|
|
66
|
+
odps_cmd.run_list(end)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
if __name__ == '__main__':
|
|
70
|
+
parser = argparse.ArgumentParser()
|
|
71
|
+
parser.add_argument(
|
|
72
|
+
'--odps_config', type=str, default=None, help='odps config path')
|
|
73
|
+
parser.add_argument(
|
|
74
|
+
'--oss_config', type=str, default=None, help='ossutilconfig path')
|
|
75
|
+
parser.add_argument(
|
|
76
|
+
'--bucket_name', type=str, default=None, help='test oss bucket name')
|
|
77
|
+
parser.add_argument('--arn', type=str, default=None, help='oss rolearn')
|
|
78
|
+
parser.add_argument(
|
|
79
|
+
'--odpscmd', type=str, default='odpscmd', help='odpscmd path')
|
|
80
|
+
parser.add_argument(
|
|
81
|
+
'--algo_project', type=str, default=None, help='algo project name')
|
|
82
|
+
parser.add_argument(
|
|
83
|
+
'--algo_res_project',
|
|
84
|
+
type=str,
|
|
85
|
+
default=None,
|
|
86
|
+
help='algo resource project name')
|
|
87
|
+
parser.add_argument(
|
|
88
|
+
'--algo_version', type=str, default=None, help='algo version')
|
|
89
|
+
args, unknown_args = parser.parse_known_args()
|
|
90
|
+
sys.argv = [sys.argv[0]]
|
|
91
|
+
for unk_arg in unknown_args:
|
|
92
|
+
sys.argv.append(unk_arg)
|
|
93
|
+
|
|
94
|
+
if args.odps_config:
|
|
95
|
+
odps_oss_config.load_odps_config(args.odps_config)
|
|
96
|
+
os.environ['ODPS_CONFIG_FILE_PATH'] = args.odps_config
|
|
97
|
+
if args.oss_config:
|
|
98
|
+
odps_oss_config.load_oss_config(args.oss_config)
|
|
99
|
+
if args.odpscmd:
|
|
100
|
+
odps_oss_config.odpscmd_path = args.odpscmd
|
|
101
|
+
if args.algo_project:
|
|
102
|
+
odps_oss_config.algo_project = args.algo_project
|
|
103
|
+
if args.algo_res_project:
|
|
104
|
+
odps_oss_config.algo_res_project = args.algo_res_project
|
|
105
|
+
if args.algo_version:
|
|
106
|
+
odps_oss_config.algo_version = args.algo_version
|
|
107
|
+
if args.arn:
|
|
108
|
+
odps_oss_config.arn = args.arn
|
|
109
|
+
if args.bucket_name:
|
|
110
|
+
odps_oss_config.bucket_name = args.bucket_name
|
|
111
|
+
print(args)
|
|
112
|
+
prepare(odps_oss_config)
|
|
113
|
+
tf.test.main()
|
|
114
|
+
# delete oss path
|
|
115
|
+
bucket = get_oss_bucket(odps_oss_config.oss_key, odps_oss_config.oss_secret,
|
|
116
|
+
odps_oss_config.endpoint, odps_oss_config.bucket_name)
|
|
117
|
+
delete_oss_path(bucket, odps_oss_config.exp_dir, odps_oss_config.bucket_name)
|
|
118
|
+
# delete tmp
|
|
119
|
+
shutil.rmtree(odps_oss_config.temp_dir)
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# -*- encoding:utf-8 -*-
|
|
2
|
+
# Copyright (c) Alibaba, Inc. and its affiliates.
|
|
3
|
+
from __future__ import division
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
|
|
7
|
+
import tensorflow as tf
|
|
8
|
+
from absl.testing import parameterized
|
|
9
|
+
|
|
10
|
+
from easy_rec.python.utils.test_utils import RunAsSubprocess
|
|
11
|
+
|
|
12
|
+
if tf.__version__ >= '2.0':
|
|
13
|
+
tf = tf.compat.v1
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class MetricsTest(tf.test.TestCase, parameterized.TestCase):
|
|
17
|
+
|
|
18
|
+
def setUp(self):
|
|
19
|
+
logging.info('Testing %s.%s' % (type(self).__name__, self._testMethodName))
|
|
20
|
+
|
|
21
|
+
@RunAsSubprocess
|
|
22
|
+
def test_max_f1(self):
|
|
23
|
+
from easy_rec.python.core.metrics import max_f1
|
|
24
|
+
labels = tf.constant([1, 0, 0, 1], dtype=tf.int32)
|
|
25
|
+
probs = tf.constant([0.9, 0.8, 0.7, 0.6], dtype=tf.float32)
|
|
26
|
+
f1, f1_update_op = max_f1(labels, probs)
|
|
27
|
+
|
|
28
|
+
with tf.Session() as sess:
|
|
29
|
+
sess.run(tf.local_variables_initializer())
|
|
30
|
+
sess.run(f1_update_op)
|
|
31
|
+
f1_score = sess.run(f1)
|
|
32
|
+
self.assertAlmostEqual(f1_score, 2.0 / 3)
|
|
33
|
+
|
|
34
|
+
@RunAsSubprocess
|
|
35
|
+
def test_gauc_all_negative_label(self):
|
|
36
|
+
from easy_rec.python.core.metrics import gauc
|
|
37
|
+
labels = tf.constant([0, 0, 0, 0], dtype=tf.int32)
|
|
38
|
+
probs = tf.constant([0.9, 0.8, 0.7, 0.6], dtype=tf.float32)
|
|
39
|
+
uids = tf.constant([1, 1, 1, 1], dtype=tf.int32)
|
|
40
|
+
value_op, update_op = gauc(labels, probs, uids)
|
|
41
|
+
with tf.Session() as sess:
|
|
42
|
+
sess.run(update_op)
|
|
43
|
+
score = sess.run(value_op)
|
|
44
|
+
self.assertAlmostEqual(score, 0.0)
|
|
45
|
+
|
|
46
|
+
@parameterized.named_parameters(
|
|
47
|
+
[['_reduction_mean', 'mean', 0.5833333],
|
|
48
|
+
['_reduction_mean_by_sample_num', 'mean_by_sample_num', 0.5925926],
|
|
49
|
+
['_reduction_mean_by_positive_num', 'mean_by_positive_num', 0.6]])
|
|
50
|
+
@RunAsSubprocess
|
|
51
|
+
def test_gauc(self, reduction, expected):
|
|
52
|
+
from easy_rec.python.core.metrics import gauc
|
|
53
|
+
labels = tf.placeholder(dtype=tf.int32, shape=(None,))
|
|
54
|
+
probs = tf.placeholder(dtype=tf.float32, shape=(None,))
|
|
55
|
+
uids = tf.placeholder(dtype=tf.int32, shape=(None,))
|
|
56
|
+
value_op, update_op = gauc(labels, probs, uids, reduction=reduction)
|
|
57
|
+
with tf.Session() as sess:
|
|
58
|
+
sess.run(
|
|
59
|
+
update_op,
|
|
60
|
+
feed_dict={
|
|
61
|
+
labels: [1, 0, 1, 1, 0],
|
|
62
|
+
probs: [0.9, 0.8, 0.7, 0.6, 0.5],
|
|
63
|
+
uids: [1, 1, 1, 1, 1]
|
|
64
|
+
})
|
|
65
|
+
sess.run(
|
|
66
|
+
update_op,
|
|
67
|
+
feed_dict={
|
|
68
|
+
labels: [1, 0, 0, 1],
|
|
69
|
+
probs: [0.9, 0.8, 0.7, 0.6],
|
|
70
|
+
uids: [2, 2, 2, 2]
|
|
71
|
+
})
|
|
72
|
+
score = sess.run(value_op)
|
|
73
|
+
self.assertAlmostEqual(score, expected)
|
|
74
|
+
|
|
75
|
+
@parameterized.named_parameters(
|
|
76
|
+
[['_reduction_mean', 'mean', 0.5833333],
|
|
77
|
+
['_reduction_mean_by_sample_num', 'mean_by_sample_num', 0.5925926],
|
|
78
|
+
['_reduction_mean_by_positive_num', 'mean_by_positive_num', 0.6]])
|
|
79
|
+
@RunAsSubprocess
|
|
80
|
+
def test_session_auc(self, reduction, expected):
|
|
81
|
+
from easy_rec.python.core.metrics import session_auc
|
|
82
|
+
labels = tf.placeholder(dtype=tf.int32, shape=(None,))
|
|
83
|
+
probs = tf.placeholder(dtype=tf.float32, shape=(None,))
|
|
84
|
+
session_ids = tf.placeholder(dtype=tf.int32, shape=(None,))
|
|
85
|
+
value_op, update_op = session_auc(
|
|
86
|
+
labels, probs, session_ids, reduction=reduction)
|
|
87
|
+
with tf.Session() as sess:
|
|
88
|
+
sess.run(
|
|
89
|
+
update_op,
|
|
90
|
+
feed_dict={
|
|
91
|
+
labels: [1, 0, 1, 1, 0],
|
|
92
|
+
probs: [0.9, 0.8, 0.7, 0.6, 0.5],
|
|
93
|
+
session_ids: [1, 1, 1, 1, 1]
|
|
94
|
+
})
|
|
95
|
+
sess.run(
|
|
96
|
+
update_op,
|
|
97
|
+
feed_dict={
|
|
98
|
+
labels: [1, 0, 0, 1],
|
|
99
|
+
probs: [0.9, 0.8, 0.7, 0.6],
|
|
100
|
+
session_ids: [2, 2, 2, 2]
|
|
101
|
+
})
|
|
102
|
+
score = sess.run(value_op)
|
|
103
|
+
self.assertAlmostEqual(score, expected)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
if __name__ == '__main__':
|
|
107
|
+
tf.test.main()
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# -*- encoding:utf-8 -*-
|
|
2
|
+
# Copyright (c) Alibaba, Inc. and its affiliates.
|
|
3
|
+
|
|
4
|
+
import logging
|
|
5
|
+
import os
|
|
6
|
+
|
|
7
|
+
import tensorflow as tf
|
|
8
|
+
|
|
9
|
+
from easy_rec.python.utils import test_utils
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ExcelConvertTest(tf.test.TestCase):
|
|
13
|
+
|
|
14
|
+
def setUp(self):
|
|
15
|
+
logging.info('Testing %s.%s' % (type(self).__name__, self._testMethodName))
|
|
16
|
+
|
|
17
|
+
def tearDown(self):
|
|
18
|
+
test_utils.set_gpu_id(None)
|
|
19
|
+
|
|
20
|
+
def test_deepfm_convert(self):
|
|
21
|
+
test_dir = test_utils.get_tmp_dir()
|
|
22
|
+
logging.info('test dir: %s' % test_dir)
|
|
23
|
+
pipeline_config_path = os.path.join(test_dir, 'avazu_deepfm_excel.config')
|
|
24
|
+
convert_cmd = """
|
|
25
|
+
python -m easy_rec.python.tools.create_config_from_excel
|
|
26
|
+
--excel_path samples/excel_config/dwd_avazu_ctr_deepfm.xls
|
|
27
|
+
--model_type deepfm
|
|
28
|
+
--output_path %s
|
|
29
|
+
--train_input_path data/test/dwd_avazu_ctr_deepmodel_10w.csv
|
|
30
|
+
--eval_input_path data/test/dwd_avazu_ctr_deepmodel_10w.csv
|
|
31
|
+
""" % pipeline_config_path
|
|
32
|
+
proc = test_utils.run_cmd(convert_cmd,
|
|
33
|
+
'%s/log_%s.txt' % (test_dir, 'convert'))
|
|
34
|
+
proc.wait()
|
|
35
|
+
self.assertTrue(proc.returncode == 0)
|
|
36
|
+
self.assertTrue(
|
|
37
|
+
test_utils.test_single_train_eval(
|
|
38
|
+
pipeline_config_path, test_dir=test_dir))
|
|
39
|
+
test_utils.clean_up(test_dir)
|
|
40
|
+
|
|
41
|
+
def test_multi_tower_convert(self):
|
|
42
|
+
test_dir = test_utils.get_tmp_dir()
|
|
43
|
+
logging.info('test dir: %s' % test_dir)
|
|
44
|
+
pipeline_config_path = os.path.join(test_dir, 'avazu_deepfm_excel.config')
|
|
45
|
+
convert_cmd = """
|
|
46
|
+
python -m easy_rec.python.tools.create_config_from_excel
|
|
47
|
+
--excel_path samples/excel_config/dwd_avazu_ctr_deepfm.xls
|
|
48
|
+
--model_type multi_tower
|
|
49
|
+
--output_path %s
|
|
50
|
+
--train_input_path data/test/dwd_avazu_ctr_deepmodel_10w.csv
|
|
51
|
+
--eval_input_path data/test/dwd_avazu_ctr_deepmodel_10w.csv
|
|
52
|
+
""" % pipeline_config_path
|
|
53
|
+
proc = test_utils.run_cmd(convert_cmd,
|
|
54
|
+
'%s/log_%s.txt' % (test_dir, 'convert'))
|
|
55
|
+
proc.wait()
|
|
56
|
+
self.assertTrue(proc.returncode == 0)
|
|
57
|
+
self.assertTrue(
|
|
58
|
+
test_utils.test_single_train_eval(
|
|
59
|
+
pipeline_config_path, test_dir=test_dir))
|
|
60
|
+
test_utils.clean_up(test_dir)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
if __name__ == '__main__':
|
|
64
|
+
tf.test.main()
|