Commit 896e5231 by xiaotong

random number fixes

parent 52a27964
...@@ -59,8 +59,6 @@ int TransformerMain(int argc, const char ** argv) ...@@ -59,8 +59,6 @@ int TransformerMain(int argc, const char ** argv)
LoadParamString(argc, args, "test", testFN, ""); LoadParamString(argc, args, "test", testFN, "");
LoadParamString(argc, args, "output", outputFN, ""); LoadParamString(argc, args, "output", outputFN, "");
srand((unsigned int)time(NULL));
T2TTrainer trainer; T2TTrainer trainer;
trainer.Init(argc, args); trainer.Init(argc, args);
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h>
#include "XDevice.h" #include "XDevice.h"
#include "XGlobal.h" #include "XGlobal.h"
#include "XThread.h" #include "XThread.h"
...@@ -68,6 +69,7 @@ void XDevice::Init(int myDevID) ...@@ -68,6 +69,7 @@ void XDevice::Init(int myDevID)
Clear(); Clear();
devID = myDevID; devID = myDevID;
seed = rand();
/* CPU information */ /* CPU information */
if(devID < 0){ if(devID < 0){
...@@ -270,6 +272,8 @@ XDevManager::~XDevManager() ...@@ -270,6 +272,8 @@ XDevManager::~XDevManager()
/* initialize it and get the CPU and GPU information */ /* initialize it and get the CPU and GPU information */
void XDevManager::Init() void XDevManager::Init()
{ {
srand((unsigned int)time(NULL));
Clear(); Clear();
/* CPUs (we actually do not care about how many CPUs are using) */ /* CPUs (we actually do not care about how many CPUs are using) */
......
...@@ -99,6 +99,9 @@ public: ...@@ -99,6 +99,9 @@ public:
/* default stream for the device */ /* default stream for the device */
XStream * stream; XStream * stream;
/* seed for random number generation */
int seed;
#ifdef USE_CUDA #ifdef USE_CUDA
/* mutex for handle (GPU cublas) */ /* mutex for handle (GPU cublas) */
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论