@@ -23,30 +23,6 @@ limitations under the License. */
2323namespace paddle {
2424namespace framework {
2525
26- __device__ double cuda_double_random (unsigned long long seed) {
27- // copy from MurmurHash3
28- seed ^= seed >> 33 ;
29- seed *= 0xff51afd7ed558ccd ;
30- seed ^= seed >> 33 ;
31- seed *= 0xc4ceb9fe1a85ec53 ;
32- seed ^= seed >> 33 ;
33- return ((double )seed / 18446744073709551615.0 );
34- }
35-
36- __device__ float cuda_normal_random (unsigned long long idx) {
37- static double pi = 3.1415926897932384 ;
38- unsigned long long x = clock64 () + idx;
39- double x1, x2, res;
40- while (1 ) {
41- x1 = cuda_double_random (x);
42- x2 = cuda_double_random (x + 33 );
43- res = sqrt (-2.0 * log (x1)) * cos (2.0 * pi * x2);
44- if (-10 < res && res < 10 ) break ;
45- x += 207 ;
46- }
47- return res;
48- }
49-
5026template <typename ValType, typename GradType>
5127class Optimizer {
5228 public:
@@ -95,11 +71,12 @@ class Optimizer {
9571 }
9672 __device__ void update_value (ValType& val, const GradType& grad) {
9773 val.slot = grad.slot ;
98- ;
9974 val.show += grad.show ;
10075 val.clk += grad.clk ;
76+ val.delta_score += optimizer_config::nonclk_coeff * (grad.show - grad.clk ) +
77+ optimizer_config::clk_coeff * grad.clk ;
10178
102- update_lr (val.lr , val.lr_g2sum , grad.lr_g , 1.0 );
79+ update_lr (val.lr , val.lr_g2sum , grad.lr_g , grad. show );
10380
10481 if (val.mf_size == 0 ) {
10582 if (optimizer_config::mf_create_thresholds <=
@@ -116,7 +93,7 @@ class Optimizer {
11693 }
11794 }
11895 } else {
119- update_mf (MF_DIM, &val.mf [1 ], val.mf [0 ], grad.mf_g , 1.0 );
96+ update_mf (MF_DIM, &val.mf [1 ], val.mf [0 ], grad.mf_g , grad. show );
12097 }
12198 }
12299};
0 commit comments