Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
coolalex776
Paddle
提交
35e6abd7
P
Paddle
项目概览
coolalex776
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
35e6abd7
编写于
7月 26, 2018
作者:
M
minqiyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Change iter_parameters back and port unittests code to Python3
上级
e8493620
变更
195
展开全部
隐藏空白更改
内联
并排
Showing
195 changed file
with
383 addition
and
371 deletion
+383
-371
python/paddle/fluid/framework.py
python/paddle/fluid/framework.py
+3
-3
python/paddle/fluid/tests/test_beam_search_decoder.py
python/paddle/fluid/tests/test_beam_search_decoder.py
+4
-4
python/paddle/fluid/tests/unittests/dist_se_resnext.py
python/paddle/fluid/tests/unittests/dist_se_resnext.py
+2
-2
python/paddle/fluid/tests/unittests/op_test.py
python/paddle/fluid/tests/unittests/op_test.py
+13
-11
python/paddle/fluid/tests/unittests/test_accuracy_op.py
python/paddle/fluid/tests/unittests/test_accuracy_op.py
+2
-2
python/paddle/fluid/tests/unittests/test_activation_mkldnn_op.py
...paddle/fluid/tests/unittests/test_activation_mkldnn_op.py
+2
-2
python/paddle/fluid/tests/unittests/test_activation_op.py
python/paddle/fluid/tests/unittests/test_activation_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_adadelta_op.py
python/paddle/fluid/tests/unittests/test_adadelta_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_adagrad_op.py
python/paddle/fluid/tests/unittests/test_adagrad_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_adam_op.py
python/paddle/fluid/tests/unittests/test_adam_op.py
+3
-3
python/paddle/fluid/tests/unittests/test_adamax_op.py
python/paddle/fluid/tests/unittests/test_adamax_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_anchor_generator_op.py
.../paddle/fluid/tests/unittests/test_anchor_generator_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_arg_min_max_op.py
python/paddle/fluid/tests/unittests/test_arg_min_max_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_argsort_op.py
python/paddle/fluid/tests/unittests/test_argsort_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_array_read_write_op.py
.../paddle/fluid/tests/unittests/test_array_read_write_op.py
+3
-2
python/paddle/fluid/tests/unittests/test_assign_op.py
python/paddle/fluid/tests/unittests/test_assign_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_assign_value_op.py
python/paddle/fluid/tests/unittests/test_assign_value_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_auc_op.py
python/paddle/fluid/tests/unittests/test_auc_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_batch_norm_mkldnn_op.py
...paddle/fluid/tests/unittests/test_batch_norm_mkldnn_op.py
+2
-2
python/paddle/fluid/tests/unittests/test_batch_norm_op.py
python/paddle/fluid/tests/unittests/test_batch_norm_op.py
+2
-2
python/paddle/fluid/tests/unittests/test_beam_search_op.py
python/paddle/fluid/tests/unittests/test_beam_search_op.py
+1
-2
python/paddle/fluid/tests/unittests/test_bilinear_interp_op.py
...n/paddle/fluid/tests/unittests/test_bilinear_interp_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_bilinear_tensor_product_op.py
.../fluid/tests/unittests/test_bilinear_tensor_product_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_bipartite_match_op.py
...n/paddle/fluid/tests/unittests/test_bipartite_match_op.py
+2
-2
python/paddle/fluid/tests/unittests/test_box_coder_op.py
python/paddle/fluid/tests/unittests/test_box_coder_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_cast_op.py
python/paddle/fluid/tests/unittests/test_cast_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_chunk_eval_op.py
python/paddle/fluid/tests/unittests/test_chunk_eval_op.py
+5
-4
python/paddle/fluid/tests/unittests/test_clip_by_norm_op.py
python/paddle/fluid/tests/unittests/test_clip_by_norm_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_clip_op.py
python/paddle/fluid/tests/unittests/test_clip_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_compare_op.py
python/paddle/fluid/tests/unittests/test_compare_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_concat_op.py
python/paddle/fluid/tests/unittests/test_concat_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_conditional_block.py
...on/paddle/fluid/tests/unittests/test_conditional_block.py
+2
-2
python/paddle/fluid/tests/unittests/test_conv2d_mkldnn_op.py
python/paddle/fluid/tests/unittests/test_conv2d_mkldnn_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_conv2d_op.py
python/paddle/fluid/tests/unittests/test_conv2d_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_conv2d_transpose_op.py
.../paddle/fluid/tests/unittests/test_conv2d_transpose_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_conv3d_op.py
python/paddle/fluid/tests/unittests/test_conv3d_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_conv3d_transpose_op.py
.../paddle/fluid/tests/unittests/test_conv3d_transpose_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_conv_shift_op.py
python/paddle/fluid/tests/unittests/test_conv_shift_op.py
+3
-3
python/paddle/fluid/tests/unittests/test_cos_sim_op.py
python/paddle/fluid/tests/unittests/test_cos_sim_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_create_op_doc_string.py
...paddle/fluid/tests/unittests/test_create_op_doc_string.py
+1
-1
python/paddle/fluid/tests/unittests/test_crf_decoding_op.py
python/paddle/fluid/tests/unittests/test_crf_decoding_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_crop_op.py
python/paddle/fluid/tests/unittests/test_crop_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_cross_entropy_op.py
python/paddle/fluid/tests/unittests/test_cross_entropy_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_ctc_align.py
python/paddle/fluid/tests/unittests/test_ctc_align.py
+2
-2
python/paddle/fluid/tests/unittests/test_cumsum_op.py
python/paddle/fluid/tests/unittests/test_cumsum_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_data_balance.py
python/paddle/fluid/tests/unittests/test_data_balance.py
+4
-4
python/paddle/fluid/tests/unittests/test_decayed_adagrad_op.py
...n/paddle/fluid/tests/unittests/test_decayed_adagrad_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_default_scope_funcs.py
.../paddle/fluid/tests/unittests/test_default_scope_funcs.py
+1
-1
python/paddle/fluid/tests/unittests/test_detection_map_op.py
python/paddle/fluid/tests/unittests/test_detection_map_op.py
+2
-2
python/paddle/fluid/tests/unittests/test_dist_mnist.py
python/paddle/fluid/tests/unittests/test_dist_mnist.py
+3
-2
python/paddle/fluid/tests/unittests/test_dist_transpiler.py
python/paddle/fluid/tests/unittests/test_dist_transpiler.py
+3
-3
python/paddle/fluid/tests/unittests/test_dist_word2vec.py
python/paddle/fluid/tests/unittests/test_dist_word2vec.py
+2
-2
python/paddle/fluid/tests/unittests/test_dropout_op.py
python/paddle/fluid/tests/unittests/test_dropout_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_dyn_rnn.py
python/paddle/fluid/tests/unittests/test_dyn_rnn.py
+1
-1
python/paddle/fluid/tests/unittests/test_dynrnn_gradient_check.py
...addle/fluid/tests/unittests/test_dynrnn_gradient_check.py
+31
-29
python/paddle/fluid/tests/unittests/test_dynrnn_static_input.py
.../paddle/fluid/tests/unittests/test_dynrnn_static_input.py
+9
-9
python/paddle/fluid/tests/unittests/test_edit_distance_op.py
python/paddle/fluid/tests/unittests/test_edit_distance_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_elementwise_add_mkldnn_op.py
...e/fluid/tests/unittests/test_elementwise_add_mkldnn_op.py
+2
-2
python/paddle/fluid/tests/unittests/test_elementwise_add_op.py
...n/paddle/fluid/tests/unittests/test_elementwise_add_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_elementwise_div_op.py
...n/paddle/fluid/tests/unittests/test_elementwise_div_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_elementwise_gradient_op.py
...dle/fluid/tests/unittests/test_elementwise_gradient_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_elementwise_max_op.py
...n/paddle/fluid/tests/unittests/test_elementwise_max_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_elementwise_min_op.py
...n/paddle/fluid/tests/unittests/test_elementwise_min_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_elementwise_mul_op.py
...n/paddle/fluid/tests/unittests/test_elementwise_mul_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_elementwise_pow_op.py
...n/paddle/fluid/tests/unittests/test_elementwise_pow_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_elementwise_sub_op.py
...n/paddle/fluid/tests/unittests/test_elementwise_sub_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_expand_op.py
python/paddle/fluid/tests/unittests/test_expand_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_fake_dequantize_op.py
...n/paddle/fluid/tests/unittests/test_fake_dequantize_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_fake_quantize_op.py
python/paddle/fluid/tests/unittests/test_fake_quantize_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_fc_mkldnn_op.py
python/paddle/fluid/tests/unittests/test_fc_mkldnn_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_fetch_var.py
python/paddle/fluid/tests/unittests/test_fetch_var.py
+1
-1
python/paddle/fluid/tests/unittests/test_fill_constant_batch_size_like_op.py
.../tests/unittests/test_fill_constant_batch_size_like_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_fill_constant_op.py
python/paddle/fluid/tests/unittests/test_fill_constant_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_fill_op.py
python/paddle/fluid/tests/unittests/test_fill_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_fill_zeros_like_op.py
...n/paddle/fluid/tests/unittests/test_fill_zeros_like_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_ftrl_op.py
python/paddle/fluid/tests/unittests/test_ftrl_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_gather_op.py
python/paddle/fluid/tests/unittests/test_gather_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_gaussian_random_batch_size_like_op.py
...ests/unittests/test_gaussian_random_batch_size_like_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_gaussian_random_mkldnn_op.py
...e/fluid/tests/unittests/test_gaussian_random_mkldnn_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_get_places_op.py
python/paddle/fluid/tests/unittests/test_get_places_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_gru_op.py
python/paddle/fluid/tests/unittests/test_gru_op.py
+7
-6
python/paddle/fluid/tests/unittests/test_gru_unit_op.py
python/paddle/fluid/tests/unittests/test_gru_unit_op.py
+2
-2
python/paddle/fluid/tests/unittests/test_hinge_loss_op.py
python/paddle/fluid/tests/unittests/test_hinge_loss_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_hsigmoid_op.py
python/paddle/fluid/tests/unittests/test_hsigmoid_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_huber_loss_op.py
python/paddle/fluid/tests/unittests/test_huber_loss_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_im2sequence_op.py
python/paddle/fluid/tests/unittests/test_im2sequence_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_image_classification_layer.py
.../fluid/tests/unittests/test_image_classification_layer.py
+3
-3
python/paddle/fluid/tests/unittests/test_inference_model_io.py
...n/paddle/fluid/tests/unittests/test_inference_model_io.py
+1
-1
python/paddle/fluid/tests/unittests/test_iou_similarity_op.py
...on/paddle/fluid/tests/unittests/test_iou_similarity_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_is_empty_op.py
python/paddle/fluid/tests/unittests/test_is_empty_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_l1_norm_op.py
python/paddle/fluid/tests/unittests/test_l1_norm_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_label_smooth_op.py
python/paddle/fluid/tests/unittests/test_label_smooth_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_layer_norm_op.py
python/paddle/fluid/tests/unittests/test_layer_norm_op.py
+1
-0
python/paddle/fluid/tests/unittests/test_layers.py
python/paddle/fluid/tests/unittests/test_layers.py
+3
-3
python/paddle/fluid/tests/unittests/test_linear_chain_crf_op.py
.../paddle/fluid/tests/unittests/test_linear_chain_crf_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_listen_and_serv_op.py
...n/paddle/fluid/tests/unittests/test_listen_and_serv_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_lod_rank_table.py
python/paddle/fluid/tests/unittests/test_lod_rank_table.py
+1
-1
python/paddle/fluid/tests/unittests/test_lod_reset_op.py
python/paddle/fluid/tests/unittests/test_lod_reset_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_lod_tensor_array.py
python/paddle/fluid/tests/unittests/test_lod_tensor_array.py
+2
-2
python/paddle/fluid/tests/unittests/test_lod_tensor_array_ops.py
...paddle/fluid/tests/unittests/test_lod_tensor_array_ops.py
+10
-6
python/paddle/fluid/tests/unittests/test_log_loss_op.py
python/paddle/fluid/tests/unittests/test_log_loss_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_logical_op.py
python/paddle/fluid/tests/unittests/test_logical_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_lookup_sparse_table_op.py
...ddle/fluid/tests/unittests/test_lookup_sparse_table_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_lookup_table_op.py
python/paddle/fluid/tests/unittests/test_lookup_table_op.py
+2
-2
python/paddle/fluid/tests/unittests/test_lrn_mkldnn_op.py
python/paddle/fluid/tests/unittests/test_lrn_mkldnn_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_lrn_op.py
python/paddle/fluid/tests/unittests/test_lrn_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_lstm_op.py
python/paddle/fluid/tests/unittests/test_lstm_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_lstm_unit_op.py
python/paddle/fluid/tests/unittests/test_lstm_unit_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_lstmp_op.py
python/paddle/fluid/tests/unittests/test_lstmp_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_margin_rank_loss_op.py
.../paddle/fluid/tests/unittests/test_margin_rank_loss_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_math_op_patch.py
python/paddle/fluid/tests/unittests/test_math_op_patch.py
+1
-1
python/paddle/fluid/tests/unittests/test_matmul_op.py
python/paddle/fluid/tests/unittests/test_matmul_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_maxout_op.py
python/paddle/fluid/tests/unittests/test_maxout_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_mean_iou.py
python/paddle/fluid/tests/unittests/test_mean_iou.py
+2
-2
python/paddle/fluid/tests/unittests/test_mean_op.py
python/paddle/fluid/tests/unittests/test_mean_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_merge_ids_op.py
python/paddle/fluid/tests/unittests/test_merge_ids_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_mine_hard_examples_op.py
...addle/fluid/tests/unittests/test_mine_hard_examples_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_minus_op.py
python/paddle/fluid/tests/unittests/test_minus_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_modified_huber_loss_op.py
...ddle/fluid/tests/unittests/test_modified_huber_loss_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_momentum_op.py
python/paddle/fluid/tests/unittests/test_momentum_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_mul_op.py
python/paddle/fluid/tests/unittests/test_mul_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_multiclass_nms_op.py
...on/paddle/fluid/tests/unittests/test_multiclass_nms_op.py
+3
-3
python/paddle/fluid/tests/unittests/test_multiplex_op.py
python/paddle/fluid/tests/unittests/test_multiplex_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_nce.py
python/paddle/fluid/tests/unittests/test_nce.py
+2
-2
python/paddle/fluid/tests/unittests/test_norm_op.py
python/paddle/fluid/tests/unittests/test_norm_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_one_hot_op.py
python/paddle/fluid/tests/unittests/test_one_hot_op.py
+6
-6
python/paddle/fluid/tests/unittests/test_pad_op.py
python/paddle/fluid/tests/unittests/test_pad_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_parallel_executor_crf.py
...addle/fluid/tests/unittests/test_parallel_executor_crf.py
+3
-3
python/paddle/fluid/tests/unittests/test_parallel_executor_fetch_feed.py
...luid/tests/unittests/test_parallel_executor_fetch_feed.py
+3
-3
python/paddle/fluid/tests/unittests/test_parallel_executor_mnist.py
...dle/fluid/tests/unittests/test_parallel_executor_mnist.py
+7
-7
python/paddle/fluid/tests/unittests/test_parallel_executor_seresnext.py
...fluid/tests/unittests/test_parallel_executor_seresnext.py
+3
-3
python/paddle/fluid/tests/unittests/test_parallel_executor_test_while_train.py
...ests/unittests/test_parallel_executor_test_while_train.py
+2
-2
python/paddle/fluid/tests/unittests/test_parallel_executor_transformer.py
...uid/tests/unittests/test_parallel_executor_transformer.py
+2
-2
python/paddle/fluid/tests/unittests/test_parallel_op.py
python/paddle/fluid/tests/unittests/test_parallel_op.py
+2
-2
python/paddle/fluid/tests/unittests/test_polygon_box_transform.py
...addle/fluid/tests/unittests/test_polygon_box_transform.py
+3
-3
python/paddle/fluid/tests/unittests/test_pool2d_mkldnn_op.py
python/paddle/fluid/tests/unittests/test_pool2d_mkldnn_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_pool2d_op.py
python/paddle/fluid/tests/unittests/test_pool2d_op.py
+5
-5
python/paddle/fluid/tests/unittests/test_pool3d_op.py
python/paddle/fluid/tests/unittests/test_pool3d_op.py
+7
-7
python/paddle/fluid/tests/unittests/test_pool_max_op.py
python/paddle/fluid/tests/unittests/test_pool_max_op.py
+10
-10
python/paddle/fluid/tests/unittests/test_positive_negative_pair_op.py
...e/fluid/tests/unittests/test_positive_negative_pair_op.py
+2
-2
python/paddle/fluid/tests/unittests/test_precision_recall_op.py
.../paddle/fluid/tests/unittests/test_precision_recall_op.py
+11
-11
python/paddle/fluid/tests/unittests/test_prelu_op.py
python/paddle/fluid/tests/unittests/test_prelu_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_prior_box_op.py
python/paddle/fluid/tests/unittests/test_prior_box_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_protobuf_descs.py
python/paddle/fluid/tests/unittests/test_protobuf_descs.py
+2
-2
python/paddle/fluid/tests/unittests/test_proximal_adagrad_op.py
.../paddle/fluid/tests/unittests/test_proximal_adagrad_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_proximal_gd_op.py
python/paddle/fluid/tests/unittests/test_proximal_gd_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_random_crop_op.py
python/paddle/fluid/tests/unittests/test_random_crop_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_rank_loss_op.py
python/paddle/fluid/tests/unittests/test_rank_loss_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_reader_reset.py
python/paddle/fluid/tests/unittests/test_reader_reset.py
+1
-1
python/paddle/fluid/tests/unittests/test_recurrent_op.py
python/paddle/fluid/tests/unittests/test_recurrent_op.py
+4
-4
python/paddle/fluid/tests/unittests/test_reduce_op.py
python/paddle/fluid/tests/unittests/test_reduce_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_registry.py
python/paddle/fluid/tests/unittests/test_registry.py
+1
-1
python/paddle/fluid/tests/unittests/test_reshape_op.py
python/paddle/fluid/tests/unittests/test_reshape_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_reverse_op.py
python/paddle/fluid/tests/unittests/test_reverse_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_rmsprop_op.py
python/paddle/fluid/tests/unittests/test_rmsprop_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_roi_pool_op.py
python/paddle/fluid/tests/unittests/test_roi_pool_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_row_conv_op.py
python/paddle/fluid/tests/unittests/test_row_conv_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_rpn_target_assign_op.py
...paddle/fluid/tests/unittests/test_rpn_target_assign_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_scale_op.py
python/paddle/fluid/tests/unittests/test_scale_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_scatter_op.py
python/paddle/fluid/tests/unittests/test_scatter_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_seq_concat_op.py
python/paddle/fluid/tests/unittests/test_seq_concat_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_seq_conv.py
python/paddle/fluid/tests/unittests/test_seq_conv.py
+4
-4
python/paddle/fluid/tests/unittests/test_seq_pool.py
python/paddle/fluid/tests/unittests/test_seq_pool.py
+1
-1
python/paddle/fluid/tests/unittests/test_sequence_erase_op.py
...on/paddle/fluid/tests/unittests/test_sequence_erase_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_sequence_expand.py
python/paddle/fluid/tests/unittests/test_sequence_expand.py
+3
-3
python/paddle/fluid/tests/unittests/test_sequence_reshape.py
python/paddle/fluid/tests/unittests/test_sequence_reshape.py
+2
-2
python/paddle/fluid/tests/unittests/test_sequence_slice_op.py
...on/paddle/fluid/tests/unittests/test_sequence_slice_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_sequence_softmax_op.py
.../paddle/fluid/tests/unittests/test_sequence_softmax_op.py
+2
-2
python/paddle/fluid/tests/unittests/test_sgd_op.py
python/paddle/fluid/tests/unittests/test_sgd_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_shape_op.py
python/paddle/fluid/tests/unittests/test_shape_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_shrink_rnn_memory.py
...on/paddle/fluid/tests/unittests/test_shrink_rnn_memory.py
+1
-1
python/paddle/fluid/tests/unittests/test_sigmoid_cross_entropy_with_logits_op.py
...ts/unittests/test_sigmoid_cross_entropy_with_logits_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_sign_op.py
python/paddle/fluid/tests/unittests/test_sign_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_slice_op.py
python/paddle/fluid/tests/unittests/test_slice_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_smooth_l1_loss_op.py
...on/paddle/fluid/tests/unittests/test_smooth_l1_loss_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_softmax_op.py
python/paddle/fluid/tests/unittests/test_softmax_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_softmax_with_cross_entropy_op.py
...uid/tests/unittests/test_softmax_with_cross_entropy_op.py
+2
-2
python/paddle/fluid/tests/unittests/test_split_ids_op.py
python/paddle/fluid/tests/unittests/test_split_ids_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_split_op.py
python/paddle/fluid/tests/unittests/test_split_op.py
+2
-2
python/paddle/fluid/tests/unittests/test_split_selected_rows_op.py
...ddle/fluid/tests/unittests/test_split_selected_rows_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_spp_op.py
python/paddle/fluid/tests/unittests/test_spp_op.py
+4
-4
python/paddle/fluid/tests/unittests/test_squared_l2_distance_op.py
...ddle/fluid/tests/unittests/test_squared_l2_distance_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_squared_l2_norm_op.py
...n/paddle/fluid/tests/unittests/test_squared_l2_norm_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_squeeze_op.py
python/paddle/fluid/tests/unittests/test_squeeze_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_sum_mkldnn_op.py
python/paddle/fluid/tests/unittests/test_sum_mkldnn_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_sum_op.py
python/paddle/fluid/tests/unittests/test_sum_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_target_assign_op.py
python/paddle/fluid/tests/unittests/test_target_assign_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_top_k_op.py
python/paddle/fluid/tests/unittests/test_top_k_op.py
+3
-3
python/paddle/fluid/tests/unittests/test_transpose_op.py
python/paddle/fluid/tests/unittests/test_transpose_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_uniform_random_batch_size_like_op.py
...tests/unittests/test_uniform_random_batch_size_like_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_uniform_random_op.py
...on/paddle/fluid/tests/unittests/test_uniform_random_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_unpool_op.py
python/paddle/fluid/tests/unittests/test_unpool_op.py
+9
-9
python/paddle/fluid/tests/unittests/test_unsqueeze_op.py
python/paddle/fluid/tests/unittests/test_unsqueeze_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_warpctc_op.py
python/paddle/fluid/tests/unittests/test_warpctc_op.py
+2
-2
python/paddle/fluid/tests/unittests/test_while_op.py
python/paddle/fluid/tests/unittests/test_while_op.py
+1
-1
未找到文件。
python/paddle/fluid/framework.py
浏览文件 @
35e6abd7
...
...
@@ -963,9 +963,9 @@ class Block(object):
raise
ValueError
(
"Var {0} is not found recursively"
.
format
(
name
))
def
all_parameters
(
self
):
return
list
(
self
.
_
iter_parameters
())
return
list
(
self
.
iter_parameters
())
def
_
iter_parameters
(
self
):
def
iter_parameters
(
self
):
return
(
item
[
1
]
for
item
in
list
(
self
.
vars
.
items
())
if
isinstance
(
item
[
1
],
Parameter
))
...
...
@@ -1199,7 +1199,7 @@ class Block(object):
if
not
isinstance
(
other
,
Block
):
raise
TypeError
(
"_copy_param_info_from should be invoked with Block"
)
for
p
in
other
.
_
iter_parameters
():
for
p
in
other
.
iter_parameters
():
assert
isinstance
(
p
,
Parameter
)
v
=
self
.
vars
.
get
(
p
.
name
,
None
)
if
v
is
None
:
...
...
python/paddle/fluid/tests/test_beam_search_decoder.py
浏览文件 @
35e6abd7
...
...
@@ -155,7 +155,7 @@ def train_main(use_cuda):
]
feeder
=
fluid
.
DataFeeder
(
feed_list
,
place
)
for
pass_id
in
x
range
(
1
):
for
pass_id
in
range
(
1
):
for
batch_id
,
data
in
enumerate
(
train_reader
()):
outs
=
exe
.
run
(
main_program
,
feed
=
feeder
.
feed
(
data
),
...
...
@@ -204,8 +204,8 @@ def decode_main(use_cuda):
]
feeder
=
fluid
.
DataFeeder
(
feed_list
,
place
)
data
=
train_reader
().
next
(
)
feed_dict
=
feeder
.
feed
(
map
(
lambda
x
:
[
x
[
0
]],
data
)
)
data
=
next
(
train_reader
()
)
feed_dict
=
feeder
.
feed
(
[[
x
[
0
]]
for
x
in
data
]
)
feed_dict
[
'init_ids'
]
=
init_ids
feed_dict
[
'init_scores'
]
=
init_scores
...
...
@@ -214,7 +214,7 @@ def decode_main(use_cuda):
feed
=
feed_dict
,
fetch_list
=
[
translation_ids
,
translation_scores
],
return_numpy
=
False
)
print
result_ids
.
lod
(
)
print
(
result_ids
.
lod
()
)
class
TestBeamSearchDecoder
(
unittest
.
TestCase
):
...
...
python/paddle/fluid/tests/unittests/dist_se_resnext.py
浏览文件 @
35e6abd7
...
...
@@ -301,7 +301,7 @@ class DistSeResneXt2x2:
trainer_id
=
trainer_id
)
feed_var_list
=
[
var
for
var
in
trainer_prog
.
global_block
().
vars
.
iter
values
()
var
for
var
in
trainer_prog
.
global_block
().
vars
.
values
()
if
var
.
is_data
]
...
...
@@ -309,7 +309,7 @@ class DistSeResneXt2x2:
reader_generator
=
train_reader
()
first_loss
,
=
exe
.
run
(
fetch_list
=
[
avg_cost
.
name
])
print
(
first_loss
)
for
i
in
x
range
(
5
):
for
i
in
range
(
5
):
loss
,
=
exe
.
run
(
fetch_list
=
[
avg_cost
.
name
])
last_loss
,
=
exe
.
run
(
fetch_list
=
[
avg_cost
.
name
])
print
(
last_loss
)
...
...
python/paddle/fluid/tests/unittests/op_test.py
浏览文件 @
35e6abd7
...
...
@@ -25,14 +25,16 @@ from paddle.fluid.backward import append_backward
from
paddle.fluid.op
import
Operator
from
paddle.fluid.executor
import
Executor
from
paddle.fluid.framework
import
Program
,
OpProtoHolder
,
Variable
from
testsuite
import
create_op
,
set_input
,
append_input_output
,
append_loss_ops
from
.testsuite
import
create_op
,
set_input
,
append_input_output
,
append_loss_ops
from
functools
import
reduce
from
six.moves
import
zip
def
randomize_probability
(
batch_size
,
class_num
,
dtype
=
'float32'
):
prob
=
np
.
random
.
uniform
(
0.1
,
1.0
,
size
=
(
batch_size
,
class_num
)).
astype
(
dtype
)
prob_sum
=
prob
.
sum
(
axis
=
1
)
for
i
in
x
range
(
len
(
prob
)):
for
i
in
range
(
len
(
prob
)):
prob
[
i
]
/=
prob_sum
[
i
]
return
prob
...
...
@@ -86,7 +88,7 @@ def get_numeric_gradient(place,
# we only compute gradient of one element each time.
# we use a for loop to compute the gradient of every element.
for
i
in
x
range
(
tensor_size
):
for
i
in
range
(
tensor_size
):
if
in_place
:
set_input
(
scope
,
op
,
inputs
,
place
)
...
...
@@ -139,7 +141,7 @@ class OpTest(unittest.TestCase):
assert
isinstance
(
numpy_dict
,
dict
),
"self.inputs, self.outputs must be numpy_dict"
for
var_name
,
var_value
in
numpy_dict
.
ite
rite
ms
():
for
var_name
,
var_value
in
numpy_dict
.
items
():
if
isinstance
(
var_value
,
(
np
.
ndarray
,
np
.
generic
)):
self
.
try_call_once
(
var_value
.
dtype
)
elif
isinstance
(
var_value
,
(
list
,
tuple
)):
...
...
@@ -197,7 +199,7 @@ class OpTest(unittest.TestCase):
def
_get_io_vars
(
self
,
block
,
numpy_inputs
):
inputs
=
{}
for
name
,
value
in
numpy_inputs
.
ite
rite
ms
():
for
name
,
value
in
numpy_inputs
.
items
():
if
isinstance
(
value
,
list
):
var_list
=
[
block
.
var
(
sub_name
)
for
sub_name
,
sub_value
in
value
...
...
@@ -240,7 +242,7 @@ class OpTest(unittest.TestCase):
# if the fetch_list is customized by user, we use it directly.
# if not, fill the fetch_list by the user configured outputs in test.
if
len
(
fetch_list
)
==
0
:
for
var_name
,
var
in
outputs
.
ite
rite
ms
():
for
var_name
,
var
in
outputs
.
items
():
if
isinstance
(
var
,
list
):
for
v
in
var
:
fetch_list
.
append
(
v
)
...
...
@@ -252,7 +254,7 @@ class OpTest(unittest.TestCase):
fetch_list
.
append
(
str
(
out_name
))
# fetch_list = map(block.var, fetch_list)
if
not
isinstance
(
fetch_list
[
0
],
fluid
.
framework
.
Variable
):
fetch_list
=
map
(
block
.
var
,
fetch_list
)
fetch_list
=
list
(
map
(
block
.
var
,
fetch_list
)
)
outs
=
executor
.
run
(
program
,
feed
=
feed_map
,
fetch_list
=
fetch_list
,
...
...
@@ -334,7 +336,7 @@ class OpTest(unittest.TestCase):
def
__assert_is_close
(
self
,
numeric_grads
,
analytic_grads
,
names
,
max_relative_error
,
msg_prefix
):
for
a
,
b
,
name
in
itertools
.
i
zip
(
numeric_grads
,
analytic_grads
,
names
):
for
a
,
b
,
name
in
zip
(
numeric_grads
,
analytic_grads
,
names
):
abs_a
=
np
.
abs
(
a
)
abs_a
[
abs_a
<
1e-3
]
=
1
...
...
@@ -460,6 +462,6 @@ class OpTest(unittest.TestCase):
use_cuda
=
use_cuda
,
loss_name
=
loss
.
name
,
main_program
=
program
)
else
:
executor
=
Executor
(
place
)
return
map
(
np
.
array
,
executor
.
run
(
prog
,
feed_dict
,
fetch_list
,
return_numpy
=
False
))
return
list
(
map
(
np
.
array
,
executor
.
run
(
prog
,
feed_dict
,
fetch_list
,
return_numpy
=
False
)
))
python/paddle/fluid/tests/unittests/test_accuracy_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
TestAccuracyOp
(
OpTest
):
...
...
@@ -26,7 +26,7 @@ class TestAccuracyOp(OpTest):
label
=
np
.
random
.
randint
(
0
,
2
,
(
n
,
1
))
self
.
inputs
=
{
'Out'
:
infer
,
'Indices'
:
indices
,
"Label"
:
label
}
num_correct
=
0
for
rowid
in
x
range
(
n
):
for
rowid
in
range
(
n
):
for
ele
in
indices
[
rowid
]:
if
ele
==
label
[
rowid
]:
num_correct
+=
1
...
...
python/paddle/fluid/tests/unittests/test_activation_mkldnn_op.py
浏览文件 @
35e6abd7
...
...
@@ -15,9 +15,9 @@
import
unittest
import
numpy
as
np
import
paddle.fluid.core
as
core
from
op_test
import
OpTest
from
.
op_test
import
OpTest
from
scipy.special
import
expit
from
test_activation_op
import
TestRelu
,
TestTanh
,
TestSqrt
,
TestAbs
from
.
test_activation_op
import
TestRelu
,
TestTanh
,
TestSqrt
,
TestAbs
class
TestMKLDNNReluDim2
(
TestRelu
):
...
...
python/paddle/fluid/tests/unittests/test_activation_op.py
浏览文件 @
35e6abd7
...
...
@@ -15,7 +15,7 @@
import
unittest
import
numpy
as
np
import
paddle.fluid.core
as
core
from
op_test
import
OpTest
from
.
op_test
import
OpTest
from
scipy.special
import
expit
...
...
python/paddle/fluid/tests/unittests/test_adadelta_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
TestAdadeltaOp1
(
OpTest
):
...
...
python/paddle/fluid/tests/unittests/test_adagrad_op.py
浏览文件 @
35e6abd7
...
...
@@ -16,7 +16,7 @@ import unittest
import
numpy
as
np
import
paddle.fluid.core
as
core
from
paddle.fluid.op
import
Operator
from
op_test
import
OpTest
from
.
op_test
import
OpTest
import
math
...
...
python/paddle/fluid/tests/unittests/test_adam_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
from
paddle.fluid
import
core
from
paddle.fluid.op
import
Operator
...
...
@@ -273,7 +273,7 @@ class TestSparseAdamOp(unittest.TestCase):
self
.
setup
(
scope
,
place
)
op_args
=
dict
()
for
key
,
np_array
in
self
.
dense_inputs
.
ite
rite
ms
():
for
key
,
np_array
in
self
.
dense_inputs
.
items
():
var
=
scope
.
var
(
key
).
get_tensor
()
var
.
set
(
np_array
,
place
)
op_args
[
key
]
=
key
...
...
@@ -290,7 +290,7 @@ class TestSparseAdamOp(unittest.TestCase):
adam_op
=
Operator
(
"adam"
,
**
op_args
)
adam_op
.
run
(
scope
,
place
)
for
key
,
np_array
in
self
.
outputs
.
ite
rite
ms
():
for
key
,
np_array
in
self
.
outputs
.
items
():
out_var
=
scope
.
var
(
key
).
get_tensor
()
actual
=
np
.
array
(
out_var
)
actual
=
actual
.
reshape
([
actual
.
size
])
...
...
python/paddle/fluid/tests/unittests/test_adamax_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
TestAdamaxOp1
(
OpTest
):
...
...
python/paddle/fluid/tests/unittests/test_anchor_generator_op.py
浏览文件 @
35e6abd7
...
...
@@ -16,7 +16,7 @@ import unittest
import
numpy
as
np
import
sys
import
math
from
op_test
import
OpTest
from
.
op_test
import
OpTest
def
anchor_generator_in_python
(
input_feat
,
anchor_sizes
,
aspect_ratios
,
...
...
python/paddle/fluid/tests/unittests/test_arg_min_max_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
BaseTestCase
(
OpTest
):
...
...
python/paddle/fluid/tests/unittests/test_argsort_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
TestArgsortOp
(
OpTest
):
...
...
python/paddle/fluid/tests/unittests/test_array_read_write_op.py
浏览文件 @
35e6abd7
...
...
@@ -80,8 +80,9 @@ class TestArrayReadWrite(unittest.TestCase):
append_backward
(
total_sum_scaled
)
g_vars
=
map
(
default_main_program
().
global_block
().
var
,
[
each_x
.
name
+
"@GRAD"
for
each_x
in
x
])
g_vars
=
list
(
map
(
default_main_program
().
global_block
().
var
,
[
each_x
.
name
+
"@GRAD"
for
each_x
in
x
]))
g_out
=
[
item
.
sum
()
for
item
in
exe
.
run
(
...
...
python/paddle/fluid/tests/unittests/test_assign_op.py
浏览文件 @
35e6abd7
...
...
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import
op_test
from
.
import
op_test
import
numpy
import
unittest
...
...
python/paddle/fluid/tests/unittests/test_assign_value_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
paddle.fluid
as
fluid
import
paddle.fluid.layers
as
layers
import
op_test
from
.
import
op_test
import
numpy
import
unittest
import
paddle.fluid.framework
as
framework
...
...
python/paddle/fluid/tests/unittests/test_auc_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
from
paddle.fluid
import
metrics
...
...
python/paddle/fluid/tests/unittests/test_batch_norm_mkldnn_op.py
浏览文件 @
35e6abd7
...
...
@@ -17,9 +17,9 @@ import numpy as np
import
paddle.fluid.core
as
core
from
paddle.fluid.op
import
Operator
import
paddle.fluid
as
fluid
from
op_test
import
OpTest
from
.
op_test
import
OpTest
from
paddle.fluid.framework
import
grad_var_name
from
test_batch_norm_op
import
TestBatchNormOpInference
,
TestBatchNormOpTraining
,
_reference_training
,
_reference_grad
from
.
test_batch_norm_op
import
TestBatchNormOpInference
,
TestBatchNormOpTraining
,
_reference_training
,
_reference_grad
class
TestMKLDNNBatchNormOpTraining
(
TestBatchNormOpTraining
):
...
...
python/paddle/fluid/tests/unittests/test_batch_norm_op.py
浏览文件 @
35e6abd7
...
...
@@ -17,7 +17,7 @@ import numpy as np
import
paddle.fluid.core
as
core
from
paddle.fluid.op
import
Operator
import
paddle.fluid
as
fluid
from
op_test
import
OpTest
from
.
op_test
import
OpTest
from
paddle.fluid.framework
import
grad_var_name
...
...
@@ -415,7 +415,7 @@ class TestBatchNormOpTraining(unittest.TestCase):
self
.
__assert_close
(
scale_grad
,
out
[
6
],
"scale_grad"
)
self
.
__assert_close
(
bias_grad
,
out
[
7
],
"bias_grad"
)
print
"op test forward passed: "
,
str
(
place
),
data_layout
print
(
"op test forward passed: "
,
str
(
place
),
data_layout
)
places
=
[
core
.
CPUPlace
()]
...
...
python/paddle/fluid/tests/unittests/test_beam_search_op.py
浏览文件 @
35e6abd7
...
...
@@ -59,8 +59,7 @@ class BeamSearchOpTester(unittest.TestCase):
np
.
allclose
(
np
.
array
(
selected_scores
),
np
.
array
([
0.5
,
0.6
,
0.9
,
0.7
])[:,
np
.
newaxis
]))
self
.
assertEqual
(
selected_ids
.
lod
(),
[[
0L
,
2L
,
4L
],
[
0L
,
1L
,
2L
,
3L
,
4L
]])
self
.
assertEqual
(
selected_ids
.
lod
(),
[[
0
,
2
,
4
],
[
0
,
1
,
2
,
3
,
4
]])
def
_create_pre_ids
(
self
):
np_data
=
np
.
array
([[
1
,
2
,
3
,
4
]],
dtype
=
'int64'
)
...
...
python/paddle/fluid/tests/unittests/test_bilinear_interp_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
import
paddle.fluid.core
as
core
...
...
python/paddle/fluid/tests/unittests/test_bilinear_tensor_product_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
TestBilinearTensorProductOp
(
OpTest
):
...
...
python/paddle/fluid/tests/unittests/test_bipartite_match_op.py
浏览文件 @
35e6abd7
...
...
@@ -13,7 +13,7 @@
#limitations under the License.
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
def
bipartite_match
(
distance
,
match_indices
,
match_dist
):
...
...
@@ -48,7 +48,7 @@ def bipartite_match(distance, match_indices, match_dist):
def
argmax_match
(
distance
,
match_indices
,
match_dist
,
threshold
):
r
,
c
=
distance
.
shape
for
j
in
x
range
(
c
):
for
j
in
range
(
c
):
if
match_indices
[
j
]
!=
-
1
:
continue
col_dist
=
distance
[:,
j
]
...
...
python/paddle/fluid/tests/unittests/test_box_coder_op.py
浏览文件 @
35e6abd7
...
...
@@ -16,7 +16,7 @@ import unittest
import
numpy
as
np
import
sys
import
math
from
op_test
import
OpTest
from
.
op_test
import
OpTest
def
box_coder
(
target_box
,
prior_box
,
prior_box_var
,
output_box
,
code_type
,
...
...
python/paddle/fluid/tests/unittests/test_cast_op.py
浏览文件 @
35e6abd7
...
...
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import
op_test
from
.
import
op_test
import
unittest
import
numpy
as
np
import
paddle.fluid.core
as
core
...
...
python/paddle/fluid/tests/unittests/test_chunk_eval_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
Segment
(
object
):
...
...
@@ -63,7 +63,7 @@ class TestChunkEvalOp(OpTest):
# generate chunk beginnings
chunk_begins
=
sorted
(
np
.
random
.
choice
(
range
(
starts
[
-
1
]
),
num_chunks
,
replace
=
False
))
list
(
range
(
starts
[
-
1
])
),
num_chunks
,
replace
=
False
))
seq_chunk_begins
=
[]
begin_idx
=
0
# divide chunks into sequences
...
...
@@ -93,7 +93,7 @@ class TestChunkEvalOp(OpTest):
self
.
num_infer_chunks
+
self
.
num_label_chunks
-
self
.
num_correct_chunks
)
correct_chunks
=
np
.
random
.
choice
(
range
(
len
(
chunks
)),
self
.
num_correct_chunks
,
replace
=
False
)
list
(
range
(
len
(
chunks
)
)),
self
.
num_correct_chunks
,
replace
=
False
)
infer_chunks
=
np
.
random
.
choice
(
[
x
for
x
in
range
(
len
(
chunks
))
if
x
not
in
correct_chunks
],
self
.
num_infer_chunks
-
self
.
num_correct_chunks
,
...
...
@@ -138,7 +138,8 @@ class TestChunkEvalOp(OpTest):
infer
.
fill
(
self
.
num_chunk_types
*
self
.
num_tag_types
)
label
=
np
.
copy
(
infer
)
starts
=
np
.
random
.
choice
(
range
(
1
,
self
.
batch_size
),
self
.
num_sequences
-
1
,
list
(
range
(
1
,
self
.
batch_size
)),
self
.
num_sequences
-
1
,
replace
=
False
).
tolist
()
starts
.
extend
([
0
,
self
.
batch_size
])
starts
=
sorted
(
starts
)
...
...
python/paddle/fluid/tests/unittests/test_clip_by_norm_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
TestClipByNormOp
(
OpTest
):
...
...
python/paddle/fluid/tests/unittests/test_clip_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
TestClipOp
(
OpTest
):
...
...
python/paddle/fluid/tests/unittests/test_compare_op.py
浏览文件 @
35e6abd7
...
...
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import
op_test
from
.
import
op_test
import
unittest
import
numpy
...
...
python/paddle/fluid/tests/unittests/test_concat_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
TestConcatOp
(
OpTest
):
...
...
python/paddle/fluid/tests/unittests/test_conditional_block.py
浏览文件 @
35e6abd7
...
...
@@ -39,7 +39,7 @@ class ConditionalBlockTest(unittest.TestCase):
x
=
numpy
.
random
.
random
(
size
=
(
10
,
1
)).
astype
(
'float32'
)
outs
=
exe
.
run
(
feed
=
{
'X'
:
x
},
fetch_list
=
[
out
])[
0
]
print
outs
print
(
outs
)
loss
=
layers
.
mean
(
out
)
append_backward
(
loss
=
loss
)
outs
=
exe
.
run
(
...
...
@@ -47,7 +47,7 @@ class ConditionalBlockTest(unittest.TestCase):
fetch_list
=
[
default_main_program
().
block
(
0
).
var
(
data
.
name
+
"@GRAD"
)
])[
0
]
print
outs
print
(
outs
)
if
__name__
==
'__main__'
:
...
...
python/paddle/fluid/tests/unittests/test_conv2d_mkldnn_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
from
test_conv2d_op
import
TestConv2dOp
,
TestWithPad
,
TestWithStride
from
.
test_conv2d_op
import
TestConv2dOp
,
TestWithPad
,
TestWithStride
class
TestMKLDNN
(
TestConv2dOp
):
...
...
python/paddle/fluid/tests/unittests/test_conv2d_op.py
浏览文件 @
35e6abd7
...
...
@@ -16,7 +16,7 @@ import unittest
import
numpy
as
np
import
paddle.fluid.core
as
core
from
op_test
import
OpTest
from
.
op_test
import
OpTest
def
conv2d_forward_naive
(
input
,
filter
,
group
,
conv_param
):
...
...
python/paddle/fluid/tests/unittests/test_conv2d_transpose_op.py
浏览文件 @
35e6abd7
...
...
@@ -16,7 +16,7 @@ import unittest
import
numpy
as
np
import
paddle.fluid.core
as
core
from
op_test
import
OpTest
from
.
op_test
import
OpTest
def
conv2dtranspose_forward_naive
(
input_
,
filter_
,
attrs
):
...
...
python/paddle/fluid/tests/unittests/test_conv3d_op.py
浏览文件 @
35e6abd7
...
...
@@ -16,7 +16,7 @@ import unittest
import
numpy
as
np
import
paddle.fluid.core
as
core
from
op_test
import
OpTest
from
.
op_test
import
OpTest
def
conv3d_forward_naive
(
input
,
filter
,
group
,
conv_param
):
...
...
python/paddle/fluid/tests/unittests/test_conv3d_transpose_op.py
浏览文件 @
35e6abd7
...
...
@@ -16,7 +16,7 @@ import unittest
import
numpy
as
np
import
paddle.fluid.core
as
core
from
op_test
import
OpTest
from
.
op_test
import
OpTest
def
conv3dtranspose_forward_naive
(
input_
,
filter_
,
attrs
):
...
...
python/paddle/fluid/tests/unittests/test_conv_shift_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
def
conv_shift_forward
(
x
,
y
):
...
...
@@ -22,8 +22,8 @@ def conv_shift_forward(x, y):
M
=
x
.
shape
[
1
]
N
=
y
.
shape
[
1
]
y_half_width
=
(
N
-
1
)
/
2
for
i
in
x
range
(
M
):
for
j
in
x
range
(
N
):
for
i
in
range
(
M
):
for
j
in
range
(
N
):
out
[:,
i
]
+=
x
[:,
(
i
+
j
+
M
-
y_half_width
)
%
M
]
*
y
[:,
j
]
return
out
...
...
python/paddle/fluid/tests/unittests/test_cos_sim_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
TestCosSimOp
(
OpTest
):
...
...
python/paddle/fluid/tests/unittests/test_create_op_doc_string.py
浏览文件 @
35e6abd7
...
...
@@ -18,7 +18,7 @@ import paddle.fluid.layers as layers
class
TestDocString
(
unittest
.
TestCase
):
def
test_layer_doc_string
(
self
):
print
layers
.
dropout
.
__doc__
print
(
layers
.
dropout
.
__doc__
)
if
__name__
==
'__main__'
:
...
...
python/paddle/fluid/tests/unittests/test_crf_decoding_op.py
浏览文件 @
35e6abd7
...
...
@@ -16,7 +16,7 @@ import unittest
import
random
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
CRFDecoding
(
object
):
...
...
python/paddle/fluid/tests/unittests/test_crop_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
def
crop
(
data
,
offsets
,
crop_shape
):
...
...
python/paddle/fluid/tests/unittests/test_cross_entropy_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
,
randomize_probability
from
.
op_test
import
OpTest
,
randomize_probability
class
TestCrossEntropyOp1
(
OpTest
):
...
...
python/paddle/fluid/tests/unittests/test_ctc_align.py
浏览文件 @
35e6abd7
...
...
@@ -15,8 +15,8 @@
import
sys
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
test_softmax_op
import
stable_softmax
from
.
op_test
import
OpTest
from
.
test_softmax_op
import
stable_softmax
def
CTCAlign
(
input
,
lod
,
blank
,
merge_repeated
):
...
...
python/paddle/fluid/tests/unittests/test_cumsum_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
TestSumOp1
(
OpTest
):
...
...
python/paddle/fluid/tests/unittests/test_data_balance.py
浏览文件 @
35e6abd7
...
...
@@ -21,7 +21,7 @@ import numpy as np
class
TestDataBalance
(
unittest
.
TestCase
):
def
prepare_data
(
self
):
def
fake_data_generator
():
for
n
in
x
range
(
self
.
total_ins_num
):
for
n
in
range
(
self
.
total_ins_num
):
yield
np
.
ones
((
3
,
4
))
*
n
,
n
# Prepare data
...
...
@@ -41,7 +41,7 @@ class TestDataBalance(unittest.TestCase):
def
prepare_lod_data
(
self
):
def
fake_data_generator
():
for
n
in
x
range
(
1
,
self
.
total_ins_num
+
1
):
for
n
in
range
(
1
,
self
.
total_ins_num
+
1
):
d1
=
(
np
.
ones
((
n
,
3
))
*
n
).
astype
(
'float32'
)
d2
=
(
np
.
array
(
n
).
reshape
((
1
,
1
))).
astype
(
'int32'
)
yield
d1
,
d2
...
...
@@ -58,9 +58,9 @@ class TestDataBalance(unittest.TestCase):
(
0
,
1
))
]
lod
=
[
0
]
for
_
in
x
range
(
self
.
batch_size
):
for
_
in
range
(
self
.
batch_size
):
try
:
ins
=
generator
.
next
(
)
ins
=
next
(
generator
)
except
StopIteration
:
eof
=
True
break
...
...
python/paddle/fluid/tests/unittests/test_decayed_adagrad_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
TestDecayedAdagradOp1
(
OpTest
):
...
...
python/paddle/fluid/tests/unittests/test_default_scope_funcs.py
浏览文件 @
35e6abd7
...
...
@@ -39,7 +39,7 @@ class TestDefaultScopeFuncs(unittest.TestCase):
self
.
assertTrue
(
i
.
is_int
())
self
.
assertEqual
(
10
,
i
.
get_int
())
for
_
in
x
range
(
10
):
for
_
in
range
(
10
):
scoped_function
(
__new_scope__
)
...
...
python/paddle/fluid/tests/unittests/test_detection_map_op.py
浏览文件 @
35e6abd7
...
...
@@ -17,7 +17,7 @@ import numpy as np
import
sys
import
collections
import
math
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
TestDetectionMAPOp
(
OpTest
):
...
...
@@ -176,7 +176,7 @@ class TestDetectionMAPOp(OpTest):
true_pos
[
label
].
append
([
score
,
tp
])
false_pos
[
label
].
append
([
score
,
fp
])
for
(
label
,
label_pos_num
)
in
l
abel_count
.
items
(
):
for
(
label
,
label_pos_num
)
in
l
ist
(
label_count
.
items
()
):
if
label_pos_num
==
0
or
label
not
in
true_pos
:
continue
label_true_pos
=
true_pos
[
label
]
label_false_pos
=
false_pos
[
label
]
...
...
python/paddle/fluid/tests/unittests/test_dist_mnist.py
浏览文件 @
35e6abd7
...
...
@@ -25,6 +25,7 @@ import unittest
from
multiprocessing
import
Process
import
os
import
signal
from
functools
import
reduce
SEED
=
1
DTYPE
=
"float32"
...
...
@@ -172,12 +173,12 @@ class TestDistMnist(unittest.TestCase):
exe
.
run
(
fluid
.
default_startup_program
())
feed_var_list
=
[
var
for
var
in
trainer_prog
.
global_block
().
vars
.
iter
values
()
var
for
var
in
trainer_prog
.
global_block
().
vars
.
values
()
if
var
.
is_data
]
feeder
=
fluid
.
DataFeeder
(
feed_var_list
,
place
)
for
pass_id
in
x
range
(
10
):
for
pass_id
in
range
(
10
):
for
batch_id
,
data
in
enumerate
(
train_reader
()):
exe
.
run
(
trainer_prog
,
feed
=
feeder
.
feed
(
data
))
...
...
python/paddle/fluid/tests/unittests/test_dist_transpiler.py
浏览文件 @
35e6abd7
...
...
@@ -151,7 +151,7 @@ class TestBasicModelWithLargeBlockSize(TranspilerTest):
[
"fill_constant"
,
"fill_constant"
,
"fill_constant"
])
# the variable #fc_w will be split into two blocks
fc_w_var
=
startup2
.
global_block
().
var
(
"fc_w"
)
self
.
assertEqual
(
fc_w_var
.
shape
,
(
1000
L
,
1000L
))
self
.
assertEqual
(
fc_w_var
.
shape
,
(
1000
,
1000
))
# all parameters should be optimized on pserver
pserver_params
=
[]
...
...
@@ -184,9 +184,9 @@ class TestNoSliceVar(TranspilerTest):
_
,
startup
=
self
.
get_pserver
(
self
.
pserver1_ep
,
config
)
_
,
startup2
=
self
.
get_pserver
(
self
.
pserver2_ep
,
config
)
if
startup
.
global_block
().
vars
.
has_key
(
"fc_w"
)
:
if
"fc_w"
in
startup
.
global_block
().
vars
:
fc_w_var
=
startup
.
global_block
().
vars
[
"fc_w"
]
elif
startup2
.
global_block
().
vars
.
has_key
(
"fc_w"
)
:
elif
"fc_w"
in
startup2
.
global_block
().
vars
:
fc_w_var
=
startup2
.
global_block
().
vars
[
"fc_w"
]
self
.
assertEqual
(
fc_w_var
.
shape
,
(
1000
,
1000
))
...
...
python/paddle/fluid/tests/unittests/test_dist_word2vec.py
浏览文件 @
35e6abd7
...
...
@@ -183,12 +183,12 @@ class TestDistMnist(unittest.TestCase):
exec_strategy
=
exec_strategy
)
feed_var_list
=
[
var
for
var
in
trainer_prog
.
global_block
().
vars
.
iter
values
()
var
for
var
in
trainer_prog
.
global_block
().
vars
.
values
()
if
var
.
is_data
]
feeder
=
fluid
.
DataFeeder
(
feed_var_list
,
place
)
for
pass_id
in
x
range
(
10
):
for
pass_id
in
range
(
10
):
for
batch_id
,
data
in
enumerate
(
train_reader
()):
avg_loss_np
=
train_exe
.
run
(
feed
=
feeder
.
feed
(
data
),
fetch_list
=
[
avg_cost
.
name
])
...
...
python/paddle/fluid/tests/unittests/test_dropout_op.py
浏览文件 @
35e6abd7
...
...
@@ -15,7 +15,7 @@
import
unittest
import
numpy
as
np
import
paddle.fluid.core
as
core
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
TestDropoutOp
(
OpTest
):
...
...
python/paddle/fluid/tests/unittests/test_dyn_rnn.py
浏览文件 @
35e6abd7
...
...
@@ -135,7 +135,7 @@ class TestDynRNN(unittest.TestCase):
loss_0
=
exe
.
run
(
main_program
,
feed
=
feeder
.
feed
(
data
),
fetch_list
=
[
loss
])[
0
]
for
_
in
x
range
(
100
):
for
_
in
range
(
100
):
val
=
exe
.
run
(
main_program
,
feed
=
feeder
.
feed
(
data
),
fetch_list
=
[
loss
])[
0
]
...
...
python/paddle/fluid/tests/unittests/test_dynrnn_gradient_check.py
浏览文件 @
35e6abd7
...
...
@@ -17,7 +17,7 @@ import random
import
collections
import
paddle.fluid
as
fluid
import
unittest
from
decorators
import
*
from
.
decorators
import
*
class
Memory
(
object
):
...
...
@@ -30,12 +30,12 @@ class Memory(object):
assert
val
.
dtype
==
self
.
ex
.
dtype
self
.
cur
=
val
def
next
(
self
):
def
__next__
(
self
):
self
.
ex
=
self
.
cur
self
.
cur
=
None
def
__next__
(
self
):
self
.
next
(
)
next
(
self
)
def
reset
(
self
):
self
.
ex
=
numpy
.
zeros
(
shape
=
self
.
ex
.
shape
,
dtype
=
self
.
ex
.
dtype
)
...
...
@@ -61,13 +61,13 @@ class BaseRNN(object):
self
.
num_seq
=
num_seq
self
.
inputs
=
collections
.
defaultdict
(
list
)
for
_
in
x
range
(
num_seq
):
for
_
in
range
(
num_seq
):
seq_len
=
random
.
randint
(
1
,
max_seq_len
-
1
)
for
iname
in
ins
:
ishape
=
ins
[
iname
].
get
(
'shape'
,
None
)
idtype
=
ins
[
iname
].
get
(
'dtype'
,
'float32'
)
lst
=
[]
for
_
in
x
range
(
seq_len
):
for
_
in
range
(
seq_len
):
lst
.
append
(
numpy
.
random
.
random
(
size
=
ishape
).
astype
(
idtype
))
self
.
inputs
[
iname
].
append
(
lst
)
...
...
@@ -96,16 +96,16 @@ class BaseRNN(object):
for
out
in
self
.
outputs
:
retv
[
out
]
=
[]
for
seq_id
in
x
range
(
self
.
num_seq
):
for
seq_id
in
range
(
self
.
num_seq
):
for
mname
in
self
.
mems
:
self
.
mems
[
mname
].
reset
()
for
out
in
self
.
outputs
:
self
.
outputs
[
out
].
next_sequence
()
iname0
=
self
.
inputs
.
keys
(
)[
0
]
iname0
=
list
(
self
.
inputs
.
keys
()
)[
0
]
seq_len
=
len
(
self
.
inputs
[
iname0
][
seq_id
])
for
step_id
in
x
range
(
seq_len
):
for
step_id
in
range
(
seq_len
):
xargs
=
dict
()
for
iname
in
self
.
inputs
:
...
...
@@ -138,7 +138,7 @@ class BaseRNN(object):
for
iname
in
self
.
inputs
:
lod
=
[]
np_flatten
=
[]
for
seq_id
in
x
range
(
len
(
self
.
inputs
[
iname
])):
for
seq_id
in
range
(
len
(
self
.
inputs
[
iname
])):
seq_len
=
len
(
self
.
inputs
[
iname
][
seq_id
])
lod
.
append
(
seq_len
)
np_flatten
.
extend
(
self
.
inputs
[
iname
][
seq_id
])
...
...
@@ -159,8 +159,8 @@ class BaseRNN(object):
" which is not matrix"
)
g
=
numpy
.
zeros
(
shape
=
p
.
shape
,
dtype
=
p
.
dtype
)
for
i
in
x
range
(
p
.
shape
[
0
]):
for
j
in
x
range
(
p
.
shape
[
1
]):
for
i
in
range
(
p
.
shape
[
0
]):
for
j
in
range
(
p
.
shape
[
1
]):
o
=
p
[
i
][
j
]
p
[
i
][
j
]
+=
delta
pos
=
self
.
_exe_mean_out_
()
...
...
@@ -184,7 +184,7 @@ class BaseRNN(object):
if
len
(
item
.
shape
)
!=
1
:
raise
ValueError
(
"Not support"
)
for
i
in
x
range
(
len
(
item
)):
for
i
in
range
(
len
(
item
)):
o
=
item
[
i
]
item
[
i
]
+=
delta
pos
=
self
.
_exe_mean_out_
()
...
...
@@ -198,14 +198,14 @@ class BaseRNN(object):
if
not
return_one_tensor
:
return
grad
for
i
in
x
range
(
len
(
grad
)):
for
i
in
range
(
len
(
grad
)):
grad
[
i
]
=
numpy
.
concatenate
(
grad
[
i
])
grad
=
numpy
.
concatenate
(
grad
)
return
grad
def
_exe_mean_out_
(
self
):
outs
=
self
.
exe
()
return
numpy
.
array
([
o
.
mean
()
for
o
in
outs
.
iter
values
()]).
mean
()
return
numpy
.
array
([
o
.
mean
()
for
o
in
outs
.
values
()]).
mean
()
class
SeedFixedTestCase
(
unittest
.
TestCase
):
...
...
@@ -274,13 +274,14 @@ class TestSimpleMul(SeedFixedTestCase):
cpu
=
fluid
.
CPUPlace
()
exe
=
fluid
.
Executor
(
cpu
)
out
,
w_g
,
i_g
=
map
(
numpy
.
array
,
exe
.
run
(
feed
=
py_rnn
.
to_feed
(
cpu
),
fetch_list
=
[
out
,
self
.
PARAM_NAME
+
"@GRAD"
,
self
.
DATA_NAME
+
"@GRAD"
],
return_numpy
=
False
))
out
,
w_g
,
i_g
=
list
(
map
(
numpy
.
array
,
exe
.
run
(
feed
=
py_rnn
.
to_feed
(
cpu
),
fetch_list
=
[
out
,
self
.
PARAM_NAME
+
"@GRAD"
,
self
.
DATA_NAME
+
"@GRAD"
],
return_numpy
=
False
)))
out_by_python
=
py_rnn
.
exe
()[
self
.
OUT_NAME
]
self
.
assertTrue
(
numpy
.
allclose
(
out
,
out_by_python
))
w_g_num
=
py_rnn
.
get_numeric_gradient_of_param
(
self
.
PARAM_NAME
)
...
...
@@ -351,14 +352,15 @@ class TestSimpleMulWithMemory(SeedFixedTestCase):
cpu
=
fluid
.
CPUPlace
()
exe
=
fluid
.
Executor
(
cpu
)
feed
=
py_rnn
.
to_feed
(
cpu
)
last_np
,
w_g
,
i_g
=
map
(
numpy
.
array
,
exe
.
run
(
feed
=
feed
,
fetch_list
=
[
last
,
self
.
PARAM_NAME
+
"@GRAD"
,
self
.
DATA_NAME
+
"@GRAD"
],
return_numpy
=
False
))
last_by_py
,
=
py_rnn
.
exe
().
values
()
last_np
,
w_g
,
i_g
=
list
(
map
(
numpy
.
array
,
exe
.
run
(
feed
=
feed
,
fetch_list
=
[
last
,
self
.
PARAM_NAME
+
"@GRAD"
,
self
.
DATA_NAME
+
"@GRAD"
],
return_numpy
=
False
)))
last_by_py
,
=
list
(
py_rnn
.
exe
().
values
())
w_g_num
=
py_rnn
.
get_numeric_gradient_of_param
(
self
.
PARAM_NAME
)
self
.
assertTrue
(
numpy
.
allclose
(
last_np
,
last_by_py
))
...
...
python/paddle/fluid/tests/unittests/test_dynrnn_static_input.py
浏览文件 @
35e6abd7
...
...
@@ -67,7 +67,7 @@ class TestDyRnnStaticInput(unittest.TestCase):
def
_lodtensor_to_ndarray
(
self
,
lod_tensor
):
dims
=
lod_tensor
.
shape
()
ndarray
=
np
.
zeros
(
shape
=
dims
).
astype
(
'float32'
)
for
i
in
x
range
(
np
.
product
(
dims
)):
for
i
in
range
(
np
.
product
(
dims
)):
ndarray
.
ravel
()[
i
]
=
lod_tensor
.
_get_float_element
(
i
)
return
ndarray
,
lod_tensor
.
recursive_sequence_lengths
()
...
...
@@ -114,7 +114,7 @@ class TestDyRnnStaticInput(unittest.TestCase):
shape
=
[
1
],
dtype
=
'int64'
,
value
=
0
)
step_idx
.
stop_gradient
=
True
for
i
in
x
range
(
self
.
_max_sequence_len
):
for
i
in
range
(
self
.
_max_sequence_len
):
step_out
=
fluid
.
layers
.
array_read
(
static_input_out_array
,
step_idx
)
step_out
.
stop_gradient
=
True
...
...
@@ -140,27 +140,27 @@ class TestDyRnnStaticInput(unittest.TestCase):
static_lod
=
self
.
static_input_tensor
.
recursive_sequence_lengths
()
static_sliced
=
[]
cur_offset
=
0
for
i
in
x
range
(
len
(
static_lod
[
0
])):
for
i
in
range
(
len
(
static_lod
[
0
])):
static_sliced
.
append
(
self
.
static_input_data
[
cur_offset
:(
cur_offset
+
static_lod
[
0
][
i
])])
cur_offset
+=
static_lod
[
0
][
i
]
static_seq_len
=
static_lod
[
0
]
static_reordered
=
[]
for
i
in
x
range
(
len
(
x_sorted_indices
)):
for
i
in
range
(
len
(
x_sorted_indices
)):
static_reordered
.
extend
(
static_sliced
[
x_sorted_indices
[
i
]].
tolist
())
static_seq_len_reordered
=
[
static_seq_len
[
x_sorted_indices
[
i
]]
for
i
in
x
range
(
len
(
x_sorted_indices
))
for
i
in
range
(
len
(
x_sorted_indices
))
]
static_step_outs
=
[]
static_step_lods
=
[]
for
i
in
x
range
(
self
.
_max_sequence_len
):
for
i
in
range
(
self
.
_max_sequence_len
):
end
=
len
(
x_seq_len
)
-
bisect
.
bisect_left
(
x_seq_len_sorted
,
i
+
1
)
lod
=
[]
total_len
=
0
for
i
in
x
range
(
end
):
for
i
in
range
(
end
):
lod
.
append
(
static_seq_len_reordered
[
i
])
total_len
+=
lod
[
-
1
]
static_step_lods
.
append
([
lod
])
...
...
@@ -174,7 +174,7 @@ class TestDyRnnStaticInput(unittest.TestCase):
static_step_outs
=
self
.
build_graph
(
only_forward
=
True
)
self
.
exe
.
run
(
framework
.
default_startup_program
())
expected_outs
,
expected_lods
=
self
.
get_expected_static_step_outs
()
for
i
in
x
range
(
self
.
_max_sequence_len
):
for
i
in
range
(
self
.
_max_sequence_len
):
step_out
,
lod
=
self
.
fetch_value
(
static_step_outs
[
i
])
self
.
assertTrue
(
np
.
allclose
(
step_out
,
expected_outs
[
i
]))
self
.
assertTrue
(
np
.
allclose
(
lod
,
expected_lods
[
i
]))
...
...
@@ -189,7 +189,7 @@ class TestDyRnnStaticInput(unittest.TestCase):
numeric_gradients
=
np
.
zeros
(
shape
=
static_input_shape
).
astype
(
'float32'
)
# calculate numeric gradients
tensor_size
=
np
.
product
(
static_input_shape
)
for
i
in
x
range
(
tensor_size
):
for
i
in
range
(
tensor_size
):
origin
=
self
.
static_input_tensor
.
_get_float_element
(
i
)
x_pos
=
origin
+
self
.
_delta
self
.
static_input_tensor
.
_set_float_element
(
i
,
x_pos
)
...
...
python/paddle/fluid/tests/unittests/test_edit_distance_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
def
Levenshtein
(
hyp
,
ref
):
...
...
python/paddle/fluid/tests/unittests/test_elementwise_add_mkldnn_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,8 +14,8 @@
import
unittest
import
numpy
as
np
import
paddle.fluid.core
as
core
from
op_test
import
OpTest
from
test_elementwise_add_op
import
*
from
.
op_test
import
OpTest
from
.
test_elementwise_add_op
import
*
'''
Some tests differ from the tests defined in test_elementwise_add_op.py
because MKLDNN does not support tensors of number of dimensions 3.
...
...
python/paddle/fluid/tests/unittests/test_elementwise_add_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
import
paddle.fluid.core
as
core
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
TestElementwiseAddOp
(
OpTest
):
...
...
python/paddle/fluid/tests/unittests/test_elementwise_div_op.py
浏览文件 @
35e6abd7
...
...
@@ -13,7 +13,7 @@
# limitations under the License.
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
ElementwiseDivOp
(
OpTest
):
...
...
python/paddle/fluid/tests/unittests/test_elementwise_gradient_op.py
浏览文件 @
35e6abd7
...
...
@@ -26,7 +26,7 @@ class TestElementWiseAddOp(unittest.TestCase):
def
test_with_place
(
place
):
out_grad
=
np
.
random
.
random_sample
(
self
.
x
.
shape
).
astype
(
np
.
float32
)
x_grad
=
out_grad
sum_axis
=
range
(
0
,
len
(
self
.
x
.
shape
))
sum_axis
=
list
(
range
(
0
,
len
(
self
.
x
.
shape
)
))
del
sum_axis
[
self
.
axis
]
y_grad
=
np
.
sum
(
out_grad
,
axis
=
tuple
(
sum_axis
))
...
...
python/paddle/fluid/tests/unittests/test_elementwise_max_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
TestElementwiseOp
(
OpTest
):
...
...
python/paddle/fluid/tests/unittests/test_elementwise_min_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
TestElementwiseOp
(
OpTest
):
...
...
python/paddle/fluid/tests/unittests/test_elementwise_mul_op.py
浏览文件 @
35e6abd7
...
...
@@ -13,7 +13,7 @@
# limitations under the License.
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
ElementwiseMulOp
(
OpTest
):
...
...
python/paddle/fluid/tests/unittests/test_elementwise_pow_op.py
浏览文件 @
35e6abd7
...
...
@@ -13,7 +13,7 @@
# limitations under the License.
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
TestElementwisePowOp
(
OpTest
):
...
...
python/paddle/fluid/tests/unittests/test_elementwise_sub_op.py
浏览文件 @
35e6abd7
...
...
@@ -13,7 +13,7 @@
# limitations under the License.
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
TestElementwiseOp
(
OpTest
):
...
...
python/paddle/fluid/tests/unittests/test_expand_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
TestExpandOpRank1
(
OpTest
):
...
...
python/paddle/fluid/tests/unittests/test_fake_dequantize_op.py
浏览文件 @
35e6abd7
...
...
@@ -15,7 +15,7 @@
import
unittest
import
numpy
as
np
import
math
from
op_test
import
OpTest
from
.
op_test
import
OpTest
def
quantize_max_abs
(
x
,
num_bits
):
...
...
python/paddle/fluid/tests/unittests/test_fake_quantize_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
TestFakeQuantizeOp
(
OpTest
):
...
...
python/paddle/fluid/tests/unittests/test_fc_mkldnn_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
def
fully_connected_naive
(
input
,
weights
,
bias_data
=
None
):
...
...
python/paddle/fluid/tests/unittests/test_fetch_var.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
paddle.fluid
as
fluid
import
paddle.fluid.layers
as
layers
import
op_test
from
.
import
op_test
import
numpy
import
unittest
...
...
python/paddle/fluid/tests/unittests/test_fill_constant_batch_size_like_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
TestFillConstantBatchSizeLikeWhenFirstDimIsBatchSize
(
OpTest
):
...
...
python/paddle/fluid/tests/unittests/test_fill_constant_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
TestFillConstantOp1
(
OpTest
):
...
...
python/paddle/fluid/tests/unittests/test_fill_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
import
paddle.fluid.core
as
core
...
...
python/paddle/fluid/tests/unittests/test_fill_zeros_like_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
TestFillZerosLikeOp
(
OpTest
):
...
...
python/paddle/fluid/tests/unittests/test_ftrl_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
TestFTRLOp
(
OpTest
):
...
...
python/paddle/fluid/tests/unittests/test_gather_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
TestGatherOp
(
OpTest
):
...
...
python/paddle/fluid/tests/unittests/test_gaussian_random_batch_size_like_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
TestGaussianRandomBatchSizeLike
(
OpTest
):
...
...
python/paddle/fluid/tests/unittests/test_gaussian_random_mkldnn_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
from
test_gaussian_random_op
import
TestGaussianRandomOp
from
.
test_gaussian_random_op
import
TestGaussianRandomOp
class
TestMKLDNN
(
TestGaussianRandomOp
):
...
...
python/paddle/fluid/tests/unittests/test_get_places_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
paddle.fluid
as
fluid
from
paddle.fluid.layers.device
import
get_places
import
decorators
from
.
import
decorators
import
unittest
...
...
python/paddle/fluid/tests/unittests/test_gru_op.py
浏览文件 @
35e6abd7
...
...
@@ -15,8 +15,8 @@
import
unittest
import
numpy
as
np
import
math
from
op_test
import
OpTest
from
test_lstm_op
import
identity
,
sigmoid
,
tanh
,
relu
from
.
op_test
import
OpTest
from
.
test_lstm_op
import
identity
,
sigmoid
,
tanh
,
relu
class
TestGRUOp
(
OpTest
):
...
...
@@ -38,7 +38,7 @@ class TestGRUOp(OpTest):
for
i
in
range
(
len
(
seq_lens
)):
seq_starts
.
append
(
seq_starts
[
-
1
]
+
seq_lens
[
i
])
sorted_seqs
=
sorted
(
range
(
len
(
seq_lens
)),
lambda
x
,
y
:
seq_lens
[
y
]
-
seq_lens
[
x
])
list
(
range
(
len
(
seq_lens
)
)),
lambda
x
,
y
:
seq_lens
[
y
]
-
seq_lens
[
x
])
num_batch
=
seq_lens
[
sorted_seqs
[
0
]]
for
batch_idx
in
range
(
num_batch
):
idx_in_seq
=
[]
...
...
@@ -74,15 +74,16 @@ class TestGRUOp(OpTest):
def
gru
(
self
):
input
,
lod
=
self
.
inputs
[
'Input'
]
w
=
self
.
inputs
[
'Weight'
]
b
=
self
.
inputs
[
'Bias'
]
if
self
.
inputs
.
has_key
(
'Bias'
)
else
np
.
zeros
(
b
=
self
.
inputs
[
'Bias'
]
if
'Bias'
in
self
.
inputs
else
np
.
zeros
(
(
1
,
self
.
frame_size
*
3
))
batch_gate
=
self
.
outputs
[
'BatchGate'
]
batch_reset_hidden_prev
=
self
.
outputs
[
'BatchResetHiddenPrev'
]
batch_hidden
=
self
.
outputs
[
'BatchHidden'
]
hidden
=
self
.
outputs
[
'Hidden'
]
idx_in_seq_list
=
self
.
idx_in_seq_list
h_p
=
self
.
inputs
[
'H0'
][
self
.
sorted_seqs
]
if
self
.
inputs
.
has_key
(
'H0'
)
else
np
.
zeros
((
len
(
idx_in_seq_list
[
0
]),
self
.
frame_size
))
h_p
=
self
.
inputs
[
'H0'
][
self
.
sorted_seqs
]
if
'H0'
in
self
.
inputs
else
np
.
zeros
(
(
len
(
idx_in_seq_list
[
0
]),
self
.
frame_size
))
num_batch
=
len
(
idx_in_seq_list
)
end_idx
=
0
for
batch_idx
in
range
(
num_batch
):
...
...
python/paddle/fluid/tests/unittests/test_gru_unit_op.py
浏览文件 @
35e6abd7
...
...
@@ -15,7 +15,7 @@
import
math
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
GRUActivationType
(
OpTest
):
...
...
@@ -76,7 +76,7 @@ class TestGRUUnitOp(OpTest):
x
=
self
.
inputs
[
'Input'
]
h_p
=
self
.
inputs
[
'HiddenPrev'
]
w
=
self
.
inputs
[
'Weight'
]
b
=
self
.
inputs
[
'Bias'
]
if
self
.
inputs
.
has_key
(
'Bias'
)
else
np
.
zeros
(
b
=
self
.
inputs
[
'Bias'
]
if
'Bias'
in
self
.
inputs
else
np
.
zeros
(
(
1
,
frame_size
*
3
))
g
=
x
+
np
.
tile
(
b
,
(
batch_size
,
1
))
w_u_r
=
w
.
flatten
()[:
frame_size
*
frame_size
*
2
].
reshape
(
...
...
python/paddle/fluid/tests/unittests/test_hinge_loss_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
TestHingeLossOp
(
OpTest
):
...
...
python/paddle/fluid/tests/unittests/test_hsigmoid_op.py
浏览文件 @
35e6abd7
...
...
@@ -15,7 +15,7 @@
import
unittest
import
numpy
as
np
import
math
from
op_test
import
OpTest
from
.
op_test
import
OpTest
def
find_latest_set
(
num
):
...
...
python/paddle/fluid/tests/unittests/test_huber_loss_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
def
huber_loss_forward
(
val
,
delta
):
...
...
python/paddle/fluid/tests/unittests/test_im2sequence_op.py
浏览文件 @
35e6abd7
...
...
@@ -13,7 +13,7 @@
#limitations under the License.
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
def
get_output_shape
(
attrs
,
in_shape
,
img_real_size
):
...
...
python/paddle/fluid/tests/unittests/test_image_classification_layer.py
浏览文件 @
35e6abd7
...
...
@@ -43,7 +43,7 @@ class TestLayer(unittest.TestCase):
hidden2
=
fluid
.
layers
.
fc
(
input
=
hidden1
,
size
=
128
,
act
=
'relu'
)
fluid
.
layers
.
batch_norm
(
input
=
hidden2
)
print
str
(
main_program
)
print
(
str
(
main_program
)
)
def
test_dropout_layer
(
self
):
main_program
=
Program
()
...
...
@@ -53,7 +53,7 @@ class TestLayer(unittest.TestCase):
name
=
'pixel'
,
shape
=
[
3
,
48
,
48
],
dtype
=
'float32'
)
fluid
.
layers
.
dropout
(
x
=
images
,
dropout_prob
=
0.5
)
print
str
(
main_program
)
print
(
str
(
main_program
)
)
def
test_img_conv_group
(
self
):
main_program
=
Program
()
...
...
@@ -65,7 +65,7 @@ class TestLayer(unittest.TestCase):
conv1
=
conv_block
(
images
,
64
,
2
,
[
0.3
,
0
])
conv_block
(
conv1
,
256
,
3
,
[
0.4
,
0.4
,
0
])
print
str
(
main_program
)
print
(
str
(
main_program
)
)
def
test_elementwise_add_with_act
(
self
):
main_program
=
Program
()
...
...
python/paddle/fluid/tests/unittests/test_inference_model_io.py
浏览文件 @
35e6abd7
...
...
@@ -48,7 +48,7 @@ class TestBook(unittest.TestCase):
exe
.
run
(
init_program
,
feed
=
{},
fetch_list
=
[])
for
i
in
x
range
(
100
):
for
i
in
range
(
100
):
tensor_x
=
np
.
array
(
[[
1
,
1
],
[
1
,
2
],
[
3
,
4
],
[
5
,
2
]]).
astype
(
"float32"
)
tensor_y
=
np
.
array
([[
-
2
],
[
-
3
],
[
-
7
],
[
-
7
]]).
astype
(
"float32"
)
...
...
python/paddle/fluid/tests/unittests/test_iou_similarity_op.py
浏览文件 @
35e6abd7
...
...
@@ -17,7 +17,7 @@ import numpy as np
import
numpy.random
as
random
import
sys
import
math
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
TestIOUSimilarityOp
(
OpTest
):
...
...
python/paddle/fluid/tests/unittests/test_is_empty_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
TestEmpty
(
OpTest
):
...
...
python/paddle/fluid/tests/unittests/test_l1_norm_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
numpy
as
np
import
unittest
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
TestL1NormOp
(
OpTest
):
...
...
python/paddle/fluid/tests/unittests/test_label_smooth_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
TestLabelSmoothOp
(
OpTest
):
...
...
python/paddle/fluid/tests/unittests/test_layer_norm_op.py
浏览文件 @
35e6abd7
...
...
@@ -17,6 +17,7 @@ import numpy as np
from
operator
import
mul
import
paddle.fluid.core
as
core
import
paddle.fluid
as
fluid
from
functools
import
reduce
np
.
random
.
random
(
123
)
...
...
python/paddle/fluid/tests/unittests/test_layers.py
浏览文件 @
35e6abd7
...
...
@@ -20,7 +20,7 @@ from paddle.fluid.layers.device import get_places
import
paddle.fluid.nets
as
nets
from
paddle.fluid.framework
import
Program
,
program_guard
,
default_main_program
from
paddle.fluid.param_attr
import
ParamAttr
import
decorators
from
.
import
decorators
class
TestBook
(
unittest
.
TestCase
):
...
...
@@ -279,7 +279,7 @@ class TestBook(unittest.TestCase):
def
test_nce
(
self
):
window_size
=
5
words
=
[]
for
i
in
x
range
(
window_size
):
for
i
in
range
(
window_size
):
words
.
append
(
layers
.
data
(
name
=
'word_{0}'
.
format
(
i
),
shape
=
[
1
],
dtype
=
'int64'
))
...
...
@@ -288,7 +288,7 @@ class TestBook(unittest.TestCase):
label_word
=
int
(
window_size
/
2
)
+
1
embs
=
[]
for
i
in
x
range
(
window_size
):
for
i
in
range
(
window_size
):
if
i
==
label_word
:
continue
...
...
python/paddle/fluid/tests/unittests/test_linear_chain_crf_op.py
浏览文件 @
35e6abd7
...
...
@@ -16,7 +16,7 @@ import unittest
import
random
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
LinearChainCrfForward
(
object
):
...
...
python/paddle/fluid/tests/unittests/test_listen_and_serv_op.py
浏览文件 @
35e6abd7
...
...
@@ -20,7 +20,7 @@ import subprocess
import
time
import
unittest
from
multiprocessing
import
Process
from
op_test
import
OpTest
from
.
op_test
import
OpTest
def
run_pserver
(
use_cuda
,
sync_mode
,
ip
,
port
,
trainers
,
trainer_id
):
...
...
python/paddle/fluid/tests/unittests/test_lod_rank_table.py
浏览文件 @
35e6abd7
...
...
@@ -36,7 +36,7 @@ class TestLoDRankTable(unittest.TestCase):
exe
.
run
(
scope
=
scope
,
feed
=
{
'x'
:
tensor
})
var
=
scope
.
find_var
(
rank_table
.
name
)
table
=
var
.
get_lod_rank_table
()
self
.
assertEqual
([(
0
,
5
),
(
1
,
1
),
(
2
,
1
)],
table
.
items
(
))
self
.
assertEqual
([(
0
,
5
),
(
1
,
1
),
(
2
,
1
)],
list
(
table
.
items
()
))
if
__name__
==
'__main__'
:
...
...
python/paddle/fluid/tests/unittests/test_lod_reset_op.py
浏览文件 @
35e6abd7
...
...
@@ -14,7 +14,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
.
op_test
import
OpTest
class
TestLodResetOpByAttr
(
OpTest
):
...
...
python/paddle/fluid/tests/unittests/test_lod_tensor_array.py
浏览文件 @
35e6abd7
...
...
@@ -24,7 +24,7 @@ class TestLoDTensorArray(unittest.TestCase):
tensor_array
=
arr
.
get_lod_tensor_array
()
self
.
assertEqual
(
0
,
len
(
tensor_array
))
cpu
=
core
.
CPUPlace
()
for
i
in
x
range
(
10
):
for
i
in
range
(
10
):
t
=
core
.
LoDTensor
()
t
.
set
(
numpy
.
array
([
i
],
dtype
=
'float32'
),
cpu
)
t
.
set_recursive_sequence_lengths
([[
1
]])
...
...
@@ -32,7 +32,7 @@ class TestLoDTensorArray(unittest.TestCase):
self
.
assertEqual
(
10
,
len
(
tensor_array
))
for
i
in
x
range
(
10
):
for
i
in
range
(
10
):
t
=
tensor_array
[
i
]
self
.
assertEqual
(
numpy
.
array
(
t
),
numpy
.
array
([
i
],
dtype
=
'float32'
))
self
.
assertEqual
([[
1
]],
t
.
recursive_sequence_lengths
())
...
...
python/paddle/fluid/tests/unittests/test_lod_tensor_array_ops.py
浏览文件 @
35e6abd7
...
...
@@ -35,8 +35,10 @@ class TestCPULoDTensorArrayOps(unittest.TestCase):
tensor
.
set
(
numpy
.
arange
(
10
).
reshape
(
10
,
1
).
astype
(
'int32'
),
self
.
place
())
tensor
.
set_recursive_sequence_lengths
([[
3
,
6
,
1
]])
expect
=
map
(
lambda
x
:
numpy
.
array
(
x
).
astype
(
'int32'
),
[[
3
,
0
,
9
],
[
4
,
1
],
[
5
,
2
],
[
6
],
[
7
],
[
8
]])
expect
=
[
numpy
.
array
(
x
).
astype
(
'int32'
)
for
x
in
[[
3
,
0
,
9
],
[
4
,
1
],
[
5
,
2
],
[
6
],
[
7
],
[
8
]]
]
self
.
main
(
tensor
=
tensor
,
expect_array
=
expect
,
...
...
@@ -48,8 +50,10 @@ class TestCPULoDTensorArrayOps(unittest.TestCase):
tensor
.
set
(
numpy
.
arange
(
10
).
reshape
(
10
,
1
).
astype
(
'int32'
),
self
.
place
())
tensor
.
set_recursive_sequence_lengths
([[
3
,
6
,
0
,
1
]])
expect
=
map
(
lambda
x
:
numpy
.
array
(
x
).
astype
(
'int32'
),
[[
3
,
0
,
9
],
[
4
,
1
],
[
5
,
2
],
[
6
],
[
7
],
[
8
]])
expect
=
[
numpy
.
array
(
x
).
astype
(
'int32'
)
for
x
in
[[
3
,
0
,
9
],
[
4
,
1
],
[
5
,
2
],
[
6
],
[
7
],
[
8
]]
]
self
.
main
(
tensor
=
tensor
,
expect_array
=
expect
,
...
...
@@ -111,8 +115,8 @@ class TestCPULoDTensorArrayOps(unittest.TestCase):
expect
=
[
numpy
.
array
(
item
,
dtype
=
'int32'
)
for
item
in
[[
21
,
0
,
1
,
2
,
3
,
4
,
5
,
6
,
46
,
47
,
48
,
49
],
range
(
22
,
39
)
+
range
(
7
,
21
),
range
(
39
,
46
)]
for
item
in
[[
21
,
0
,
1
,
2
,
3
,
4
,
5
,
6
,
46
,
47
,
48
,
49
],
list
(
range
(
22
,
39
))
+
list
(
range
(
7
,
21
)),
list
(
range
(
39
,
46
)
)]
]
lod
=
[[[
1
,
2
,
1
],
[
1
,
3
,
4
,
4
]],
[[
4
,
3
],
[
1
,
4
,
4
,
8
,
4
,
6
,
4
]],
[[
2
],
[
6
,
1
]]]
...
...
python/paddle/fluid/tests/unittests/test_log_loss_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_logical_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_lookup_sparse_table_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_lookup_table_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_lrn_mkldnn_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_lrn_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_lstm_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_lstm_unit_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_lstmp_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_margin_rank_loss_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_math_op_patch.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_matmul_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_maxout_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_mean_iou.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_mean_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_merge_ids_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_mine_hard_examples_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_minus_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_modified_huber_loss_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_momentum_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_mul_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_multiclass_nms_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_multiplex_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_nce.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_norm_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_one_hot_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_pad_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_parallel_executor_crf.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_parallel_executor_fetch_feed.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_parallel_executor_mnist.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_parallel_executor_seresnext.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_parallel_executor_test_while_train.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_parallel_executor_transformer.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_parallel_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_polygon_box_transform.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_pool2d_mkldnn_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_pool2d_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_pool3d_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_pool_max_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_positive_negative_pair_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_precision_recall_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_prelu_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_prior_box_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_protobuf_descs.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_proximal_adagrad_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_proximal_gd_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_random_crop_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_rank_loss_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_reader_reset.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_recurrent_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_reduce_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_registry.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_reshape_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_reverse_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_rmsprop_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_roi_pool_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_row_conv_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_rpn_target_assign_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_scale_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_scatter_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_seq_concat_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_seq_conv.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_seq_pool.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_sequence_erase_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_sequence_expand.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_sequence_reshape.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_sequence_slice_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_sequence_softmax_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_sgd_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_shape_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_shrink_rnn_memory.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_sigmoid_cross_entropy_with_logits_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_sign_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_slice_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_smooth_l1_loss_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_softmax_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_softmax_with_cross_entropy_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_split_ids_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_split_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_split_selected_rows_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_spp_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_squared_l2_distance_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_squared_l2_norm_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_squeeze_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_sum_mkldnn_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_sum_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_target_assign_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_top_k_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_transpose_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_uniform_random_batch_size_like_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_uniform_random_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_unpool_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_unsqueeze_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_warpctc_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_while_op.py
浏览文件 @
35e6abd7
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录