sigmoid.c
Go to the documentation of this file.
1 /*****************************************************************
2 /* sigmoid function for neural network simulator
3 /* 1989Mar Matsui T., ETL
4 /* 1990Apr sigmoidx is added,
5 /* load with :ld-option "-lm" to link tanh
6 /****************************************************************/
7 
8 #include "eus.h"
9 
10 static pointer SIGMOID(ctx,n,argv)
11 context *ctx;
12 int n;
13 pointer argv[];
14 { float x;
15  double exp();
16  x=fltval(argv[0]);
17  return(makeflt(1.0/(1.0+exp(-x))));}
18 
19 pointer SIGMOIDX(ctx,n,argv)
20 context *ctx;
21 int n;
22 pointer argv[];
23 { double x,u,s,th1,th2;
24  double exp(), tanh();
25  x=ckfltval(argv[0]); u=ckfltval(argv[1]);
26  th1=ckfltval(argv[2]); th2=ckfltval(argv[3]);
27  s=0.5*(1.0+tanh(x/u));
28  if (s<th1) return(makeflt(th1));
29  else if (s>th2) return(makeflt(th2));
30  else return(makeflt(s));}
31 
33 context *ctx;
34 register int n;
35 register pointer argv[];
36 { pointer v=argv[0];
37  float x=ckfltval(argv[1]), *f;
38  ckarg(2);
39  if (!isfltvector(v)) error(E_FLOATVECTOR);
40  f=v->c.fvec.fv;
41  n=vecsize(v);
42  while (--n>=0) f[n]+=x;
43  return(v);}
44 
45 pointer sigmoid(ctx,n,argv)
46 context *ctx;
47 int n;
48 pointer argv[];
49 { pointer mod=argv[0];
50  defun(ctx,"SIGMOID",mod,SIGMOID,NULL);
51  defun(ctx,"SIGMOIDX",mod,SIGMOIDX,NULL);
52  defun(ctx,"OFFSET-VECTOR",mod,OFFSET_VECTOR,NULL);}
53 
f
Definition: eus.h:522
pointer OFFSET_VECTOR(context *ctx, int n, argv)
Definition: sigmoid.c:32
GLfloat n[6][3]
Definition: cube.c:15
defun("ADR_TO_STRING", mod, ADR_TO_STRING)
ckarg(2)
float ckfltval()
pointer sigmoid(context *ctx, int n, argv)
Definition: sigmoid.c:45
union cell::cellunion c
Definition: eus.h:379
short s
Definition: structsize.c:2
pointer error(enum errorcode ec,...) pointer error(va_alist) va_dcl
Definition: eus.c:297
float fltval()
pointer SIGMOIDX(context *ctx, int n, argv)
Definition: sigmoid.c:19
static pointer SIGMOID(context *ctx, int n, argv)
Definition: sigmoid.c:10
#define NULL
Definition: transargv.c:8
GLfloat v[8][3]
Definition: cube.c:21
eusfloat_t fv[1]
Definition: eus.h:307
struct floatvector fvec
Definition: eus.h:413
pointer makeflt()


euslisp
Author(s): Toshihiro Matsui
autogenerated on Fri Feb 21 2020 03:20:54