Skip to content

Instantly share code, notes, and snippets.

Venelin Valkov curiousily

Block or report user

Report or block curiousily

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View snn-predict.js
const predProb = model.predict(tf.tensor2d([[0.1, 0.6]])).dataSync();
View snn-model-fit.js
await model.fit(X, y, {
shuffle: true,
epochs: 20,
callbacks: {
onEpochEnd: async (epoch, logs) => {
console.log("Epoch " + epoch);
console.log("Loss: " + logs.loss + " accuracy: " + logs.acc);
}
}
});
View snn-model-compile.js
model.compile({
optimizer: tf.train.adam(0.1),
loss: "binaryCrossentropy",
metrics: ["accuracy"]
});
View snn-model.js
const model = tf.sequential();
model.add(
tf.layers.dense({
inputShape: [2],
units: 3,
activation: "relu"
})
);
View snn-laptop-data.js
const X = tf.tensor2d([
// pink, small
[0.1, 0.1],
[0.3, 0.3],
[0.5, 0.6],
[0.4, 0.8],
[0.9, 0.1],
[0.75, 0.4],
[0.75, 0.9],
[0.6, 0.9],
View snn-leaky-relu.js
const xs = [...Array(20).keys()].map(x => x - 10);
const ys = tf.leakyRelu(xs).dataSync();
renderActivationFunction(xs, ys, "Leaky ReLU", "leaky-relu-cont");
View snn-relu.js
const xs = [...Array(20).keys()].map(x => x - 10);
const ys = tf.relu(xs).dataSync();
renderActivationFunction(xs, ys, "ReLU", "relu-cont");
View snn-sigmoid-perceptron-use.js
sigmoidPerceptron({
x: [0.6, 0.9],
w: [0.5, 0.9],
bias: -0.5
});
View snn-sigmoid-perceptron.js
const sigmoidPerceptron = ({ x, w, bias }) => {
const product = tf.dot(x, w).dataSync()[0];
return tf.sigmoid(product + bias).dataSync()[0];
};
View snn-sigmoid.js
const xs = [...Array(20).keys()].map(x => x - 10);
const ys = tf.sigmoid(xs).dataSync();
renderActivationFunction(xs, ys, "Sigmoid", "sigmoid-cont");
You can’t perform that action at this time.