tools.c

来自「C-package of "Long Short-Term Memory" fo」· C语言 代码 · 共 50 行

C
50
字号
/* * Some helper functions *  * $Id: tools.c 1269 2007-05-09 07:49:08Z mhe $ **/#include <stdio.h>#include <stdlib.h>#include "lstm.h"#include "tools.h"int seprand(int k) {  long l;  int f;  l = random();  f = l % k;  return(f);}/* shuffle a dataset of sequences */void shuffle (int *a, int num_prot) {  int i,pick; int *dd,*ss,b[500000];   for (i = 0; i < num_prot; i++) {    b[i] = i; }  for (i = 0; i < num_prot; i++) {        int rand = seprand(num_prot-i);     pick = b[rand];    a[i] = pick;        //    // "shift" routine here eliminates the "picked" base from b:    // dd starts at the picked position: ss is one beyond that:    //    for( dd = b+rand , ss = dd + 1 ; *dd ; *dd++=*ss++ );     }} 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?