Skip to content

Fix matcaffe init_key initialization#2562

Closed
ronghanghu wants to merge 1 commit intoBVLC:masterfrom
ronghanghu:fix-matcaffe-initkey
Closed

Fix matcaffe init_key initialization#2562
ronghanghu wants to merge 1 commit intoBVLC:masterfrom
ronghanghu:fix-matcaffe-initkey

Conversation

@ronghanghu
Copy link
Member

Previously in matcaffe (#2505), init_key is initialized with caffe_rng_rand(). However, caffe_rng_rand() relies on static shared_ptr<Caffe> Caffe::singleton_ (in common.hpp), and there is no guarantee in C++ that Caffe::singleton_ will be constructed before init_key is initialized.

Although current implementation work with g++, it may break with other compilers. Instead of generating random init_key at the beginning, use a constant number (-2.) for its first value.

Previously in matcaffe, init_key is initialized with caffe_rng_rand(). However, caffe_rng_rand() relies on shared_ptr<Caffe> Caffe::singleton_ (in common.hpp), and there is no guarantee in C++ that Caffe::singleton_ will be constructed before init_key is initialized. Instead of generating random init_key at the beginning, use a constant number (-2.) for its first value.
@ronghanghu ronghanghu force-pushed the fix-matcaffe-initkey branch from 89e91ee to 6b46e56 Compare June 7, 2015 08:17
woozzu added a commit to woozzu/caffe that referenced this pull request Jul 27, 2015
@ronghanghu ronghanghu closed this Aug 7, 2015
@ronghanghu ronghanghu deleted the fix-matcaffe-initkey branch August 7, 2015 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments