Skip to content

Commit ea63390

Browse files
authored
Merge pull request #5091 from helinwang/init
Fix new pserver having random momemtum initial values
2 parents 9a0233d + 238abc4 commit ea63390

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

paddle/optimizer/tensor.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ template <class T>
1515
class TensorT {
1616
public:
1717
TensorT(size_t size) : height_(1), width_(size) {
18-
data_ptr_ = std::shared_ptr<T>(new T[size], std::default_delete<T[]>());
18+
// new T[size]() initializes all element to zero value.
19+
data_ptr_ = std::shared_ptr<T>(new T[size](), std::default_delete<T[]>());
1920
data_ = data_ptr_.get();
2021
}
2122

0 commit comments

Comments
 (0)