diff --git a/paddle/fluid/operators/reader/ctr_reader.cc b/paddle/fluid/operators/reader/ctr_reader.cc index 10ad67ac8774c7f00c227bc7f2a15fcf55d22b5e..4edc15a2635ef84a889a7e9267de311a7297fea6 100644 --- a/paddle/fluid/operators/reader/ctr_reader.cc +++ b/paddle/fluid/operators/reader/ctr_reader.cc @@ -52,9 +52,9 @@ static inline void parse_line( std::unordered_map>* slot_to_data) { std::vector ret; string_split(line, ' ', &ret); - *label = std::stoi(ret[2]) > 0; + *label = std::stoi(ret[0]) > 0; - for (size_t i = 3; i < ret.size(); ++i) { + for (size_t i = 1; i < ret.size(); ++i) { const std::string& item = ret[i]; std::vector feasign_and_slot; string_split(item, ':', &feasign_and_slot); diff --git a/paddle/fluid/operators/reader/ctr_reader_test.cc b/paddle/fluid/operators/reader/ctr_reader_test.cc index 6410439816d8ae4a9d1df507819071ce76b5308e..b64c8400439885e0327f612994d1736f3385b5bd 100644 --- a/paddle/fluid/operators/reader/ctr_reader_test.cc +++ b/paddle/fluid/operators/reader/ctr_reader_test.cc @@ -91,16 +91,16 @@ static inline void check_all_data( TEST(CTR_READER, read_data) { const std::vector ctr_data = { - "aaaa 1 0 0:6002 1:6003 2:6004 3:6005 4:6006 -1\n", - "bbbb 1 0 5:6003 6:6003 7:6003 8:6004 9:6004 -1\n", - "cccc 1 1 10:6002 11:6002 12:6002 13:6002 14:6002 -2\n", - "dddd 1 0 15:6003 16:6003 17:6003 18:6003 19:6004 -3\n", - "1111 1 1 20:6001 21:6001 22:6001 23:6001 24:6001 12\n", - "2222 1 1 25:6004 26:6004 27:6004 28:6005 29:6005 aa\n", - "3333 1 0 30:6002 31:6003 32:6004 33:6004 34:6005 er\n", - "eeee 1 1 35:6003 36:6003 37:6005 38:6005 39:6005 dd\n", - "ffff 1 1 40:6002 41:6003 42:6004 43:6004 44:6005 66\n", - "gggg 1 1 46:6006 45:6006 47:6003 48:6003 49:6003 ba\n", + "0 0:6002 1:6003 2:6004 3:6005 4:6006 \n", + "0 5:6003 6:6003 7:6003 8:6004 9:6004 \n", + "1 10:6002 11:6002 12:6002 13:6002 14:6002 \n", + "0 15:6003 16:6003 17:6003 18:6003 19:6004 \n", + "1 20:6001 21:6001 22:6001 23:6001 24:6001 \n", + "1 25:6004 26:6004 27:6004 28:6005 29:6005 \n", + "0 30:6002 31:6003 32:6004 33:6004 34:6005 \n", + "1 35:6003 36:6003 37:6005 38:6005 39:6005 \n", + "1 40:6002 41:6003 42:6004 43:6004 44:6005 \n", + "1 46:6006 45:6006 47:6003 48:6003 49:6003 \n", }; std::string gz_file_name = "test_ctr_reader_data.gz"; generatedata(ctr_data, gz_file_name);