# How to use the numjs.softmax function in numjs

## To help you get started, weâ€™ve selected a few numjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

MindExMachina / smartgeometry / services / sketch-rnn / lib / sketch_rnn.js View on Github
``````function get_pdf(s) {
var h = s[0];
var NOUT = N_mixture;
var z = nj.add(nj.dot(h, dec_output_w), dec_output_b);
var z_pen_logits = z.slice([0, 3]);
var z_pi = z.slice([3 + NOUT * 0, 3 + NOUT * 1]);
var z_mu1 = z.slice([3 + NOUT * 1, 3 + NOUT * 2]);
var z_mu2 = z.slice([3 + NOUT * 2, 3 + NOUT * 3]);
var z_sigma1 = nj.exp(z.slice([3 + NOUT * 3, 3 + NOUT * 4]));
var z_sigma2 = nj.exp(z.slice([3 + NOUT * 4, 3 + NOUT * 5]));
var z_corr = nj.tanh(z.slice([3 + NOUT * 5, 3 + NOUT * 6]));
z_pen_logits = nj.subtract(z_pen_logits, z_pen_logits.max());
var z_pen = nj.softmax(z_pen_logits);
z_pi = nj.subtract(z_pi, z_pi.max());
z_pi = nj.softmax(z_pi);

return [z_pi, z_mu1, z_mu2, z_sigma1, z_sigma2, z_corr, z_pen];
};``````
MindExMachina / smartgeometry / services / sketch-rnn / lib / sketch_rnn.js View on Github
``````function get_pdf(s) {
var h = s[0];
var NOUT = N_mixture;
var z = nj.add(nj.dot(h, dec_output_w), dec_output_b);
var z_pen_logits = z.slice([0, 3]);
var z_pi = z.slice([3 + NOUT * 0, 3 + NOUT * 1]);
var z_mu1 = z.slice([3 + NOUT * 1, 3 + NOUT * 2]);
var z_mu2 = z.slice([3 + NOUT * 2, 3 + NOUT * 3]);
var z_sigma1 = nj.exp(z.slice([3 + NOUT * 3, 3 + NOUT * 4]));
var z_sigma2 = nj.exp(z.slice([3 + NOUT * 4, 3 + NOUT * 5]));
var z_corr = nj.tanh(z.slice([3 + NOUT * 5, 3 + NOUT * 6]));
z_pen_logits = nj.subtract(z_pen_logits, z_pen_logits.max());
var z_pen = nj.softmax(z_pen_logits);
z_pi = nj.subtract(z_pi, z_pi.max());
z_pi = nj.softmax(z_pi);

return [z_pi, z_mu1, z_mu2, z_sigma1, z_sigma2, z_corr, z_pen];
};``````

## numjs

Like NumPy, in JavaScript

MIT