
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
hyperparameters
Advanced tools
:warning: Early version subject to changes.
$ npm install hyperparameters
import * as hpjs from 'hyperparameters';
low and high i.e. any value between low and high has an equal probability of being selectedhp.uniform calculated as round(uniform(low, high) / q) * qexp(uniform(low, high)) so the logarithm of the return value is uniformly distributed.round(exp(uniform(low, high)) / q) * qround(normal(mu, sigma) / q) * qexp(normal(mu, sigma))round(exp(normal(mu, sigma)) / q) * qimport { RandomState } from 'hyperparameters';
example:
const rng = new RandomState(12345);
console.log(rng.randrange(0, 5, 0.5));
import { sample } from 'hyperparameters';
example:
import * as hpjs from 'hyperparameters';
const space = {
x: hpjs.normal(0, 2),
y: hpjs.uniform(0, 1),
choice: hpjs.choice([
undefined, hp.uniform('float', 0, 1),
]),
array: [
hpjs.normal(0, 2), hpjs.uniform(0, 3), hpjs.choice([false, true]),
],
obj: {
u: hpjs.uniform(0, 3),
v: hpjs.uniform(0, 3),
w: hpjs.uniform(-3, 0)
}
};
console.log(hpjs.sample.randomSample(space));
import * as hpjs from 'hyperparameters';
const trials = hpjs.fmin(optimizationFunction, space, estimator, max_estimates, options);
example:
import * as hpjs from 'hyperparameters';
const fn = x => ((x ** 2) - (x + 1));
const space = hpjs.uniform(-5, 5);
fmin(fn, space, hpjs.search.randomSearch, 1000, { rng: new hpjs.RandomState(123456) })
.then(trials => console.log(result.argmin));
<script src="https://cdn.jsdelivr.net/npm/hyperparameters@latest/dist/hyperparameters.min.js" />
const space = {
optimizer: hpjs.choice(['sgd', 'adam', 'adagrad', 'rmsprop']),
epochs: hpjs.quniform(50, 250, 50),
};
const trainModel = async ({ optimizer, epochs }, { xs, ys }) => {
// Create a simple model.
const model = tf.sequential();
model.add(tf.layers.dense({ units: 1, inputShape: [1] }));
// Prepare the model for training: Specify the loss and the optimizer.
model.compile({
loss: 'meanSquaredError',
optimizer
});
// Train the model using the data.
const h = await model.fit(xs, ys, { epochs });
return { model, loss: h.history.loss[h.history.loss.length - 1] };
};
const modelOpt = async ({ optimizer, epochs }, { xs, ys }) => {
const { loss } = await trainModel({ optimizer, epochs }, { xs, ys });
return { loss, status: hpjs.STATUS_OK };
};
const trials = await hpjs.fmin(
modelOpt, space, hpjs.search.randomSearch, 10,
{ rng: new hpjs.RandomState(654321), xs, ys }
);
const opt = trials.argmin;
console.log('best optimizer',opt.optimizer);
console.log('best no of epochs', opt.epochs);
$ npm install hyperparameters
import * as tf from '@tensorflow/tfjs';
import * as hpjs from 'hyperparameters';
const space = {
optimizer: hpjs.choice(['sgd', 'adam', 'adagrad', 'rmsprop']),
epochs: hpjs.quniform(50, 250, 50),
};
const trainModel = async ({ optimizer, epochs }, { xs, ys }) => {
// Create a simple model.
const model = tf.sequential();
model.add(tf.layers.dense({ units: 1, inputShape: [1] }));
// Prepare the model for training: Specify the loss and the optimizer.
model.compile({
loss: 'meanSquaredError',
optimizer
});
// Train the model using the data.
const h = await model.fit(xs, ys, { epochs });
return { model, loss: h.history.loss[h.history.loss.length - 1] };
};
const modelOpt = async ({ optimizer, epochs }, { xs, ys }) => {
const { loss } = await trainModel({ optimizer, epochs }, { xs, ys });
return { loss, status: hpjs.STATUS_OK };
};
const trials = await hpjs.fmin(
modelOpt, space, hpjs.search.randomSearch, 10,
{ rng: new hpjs.RandomState(654321), xs, ys }
);
const opt = trials.argmin;
console.log('best optimizer',opt.optimizer);
console.log('best no of epochs', opt.epochs);
MIT © Atanas Stoyanov & Martin Stoyanov
FAQs
javascript hyperparameters search
The npm package hyperparameters receives a total of 133 weekly downloads. As such, hyperparameters popularity was classified as not popular.
We found that hyperparameters demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.