- WebStorm, Rider
- Partial support, not enough intelli hints
- Toggle on TypeScript language service
- VSCode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' | |
import tensorflow as tf | |
import tensorflow.keras as keras | |
model = keras.models.Sequential([ | |
keras.layers.Dense(10, tf.nn.softmax, input_shape=(784,),kernel_initializer='zeros') | |
]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tensorflowjs_converter --input_format tfjs_layers_model tfjs/model.json here.h5 --output_format keras_saved_model |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tensorflowjs_converter --input_format keras model.h5 tfjs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Code from https://stackoverflow.com/questions/25024179/reading-mnist-dataset-with-javascript-node-js | |
// Author https://stackoverflow.com/users/254532/lilleman | |
// Download files from http://yann.lecun.com/exdb/mnist/ | |
const fs = require('fs') | |
const dataFileBuffer = fs.readFileSync(__dirname + '/train-images-idx3-ubyte') | |
const labelFileBuffer = fs.readFileSync(__dirname + '/train-labels-idx1-ubyte') | |
const load = () => { | |
let pixelValues = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const tf = require('@tensorflow/tfjs-node') | |
const load_model = async () => { | |
const model = await tf.loadLayersModel( | |
'file:///path/to/directory/tfjs/model.json' | |
) | |
model.weights.forEach((w) => { | |
console.log(w.name, w.shape) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const load_data = require('./data_loader') | |
const data = load_data() | |
const X = data.map((elem) => { | |
const key = Object.keys(elem)[0] | |
return elem[key].map((val) => val / 255) | |
}) | |
console.log(X[0]) | |
const arr = Array.apply(null, Array(10)).map(() => 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const run = async (X_tensor,y_tensor,revision) => { | |
const model = await load_model() | |
model.fit(X_tensor, y_tensor, { | |
epochs: 10, | |
batchSize: 32, | |
callbacks: { onBatchEnd }, | |
}) | |
.then((info) => { | |
console.log('Final accuracy', info.history.acc) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cluster = require('cluster') | |
const os = require('os') | |
const numCPUs = os.cpus().length | |
const tf = require('@tensorflow/tfjs-node') | |
if (cluster.isMaster) { | |
console.log(X[0]) | |
console.log(y[0], y[1]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { exec } = require('child_process') | |
const fs = require('fs') | |
model_dirs = fs.readdirSync(`${__dirname}/tfjs-models`) | |
if (!fs.existsSync('keras_models')) fs.mkdirSync('keras_models') | |
model_dirs.forEach((dir) => { | |
exec( | |
`tensorflowjs_converter --input_format tfjs_layers_model tfjs-models/${dir}/model.json keras_models/${dir}.h5 --output_format keras_saved_model` |
OlderNewer