diff options
| author | Gertjan van den Burg <gertjanvandenburg@gmail.com> | 2017-02-23 22:03:00 -0500 |
|---|---|---|
| committer | Gertjan van den Burg <gertjanvandenburg@gmail.com> | 2017-02-23 22:04:54 -0500 |
| commit | 7acce74e8eeb6a8fcd99af61030977e0fb498f88 (patch) | |
| tree | d3e3d73f334ee700041d29e4433760206aa8a82e /src/gensvm_train.c | |
| parent | add additional gcc checks (diff) | |
| download | gensvm-7acce74e8eeb6a8fcd99af61030977e0fb498f88.tar.gz gensvm-7acce74e8eeb6a8fcd99af61030977e0fb498f88.zip | |
Allow setting of the random seed in the model
Diffstat (limited to 'src/gensvm_train.c')
| -rw-r--r-- | src/gensvm_train.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/gensvm_train.c b/src/gensvm_train.c index bc1dad7..5c668e0 100644 --- a/src/gensvm_train.c +++ b/src/gensvm_train.c @@ -44,6 +44,8 @@ void gensvm_train(struct GenModel *model, struct GenData *data, struct GenModel *seed_model) { + long real_seed; + // copy dataset parameters to model model->n = data->n; model->m = data->m; @@ -52,6 +54,10 @@ void gensvm_train(struct GenModel *model, struct GenData *data, // allocate model gensvm_allocate_model(model); + // set the random seed + real_seed = (model->seed == -1) ? time(NULL) : model->seed; + srand(real_seed); + // initialize the V matrix (potentially with a seed model) gensvm_init_V(seed_model, model, data); |
