O'Reilly logo

Hands-On Machine Learning with C# by Matt R. Cole

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Writing tests

Creating tests for Kelp.Net is incredibly simple. Each test that you author needs only a single Run function exposed. The rest is your logic as to how you want your network to operate. The general guidelines for your Run function would be:

  • Load data (real or simulated):
Real[][] trainData = new Real[N][];             Real[][] trainLabel = new Real[N][];              for (int i = 0; i < N; i++)             {                 //Prepare Sin wave for one cycle                 Real radian = -Math.PI + Math.PI * 2.0 * i / (N - 1);                 trainData[i] = new[] { radian };                 trainLabel[i] = new Real[] { Math.Sin(radian) };             }
  • Create your function stack:
FunctionStack nn = new FunctionStack(                 new Linear(1, 4, name: "l1 Linear"),                 new Tanh(name: "l1 Tanh"),                 new Linear(4, 1, name: "l2 Linear")             );
  • Select your optimizer: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required