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
# Parallelize the extraction of the stored TFRecords of | |
# the cats_vs_dogs dataset by using the interleave operation with | |
# cycle_length = 4 and the number of parallel calls set to tf.data.experimental.AUTOTUNE. | |
train_dataset = files.interleave(tf.data.TFRecordDataset, | |
cycle_length=4, | |
num_parallel_calls=tf.data.experimental.AUTOTUNE) |
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
file_pattern = f'{getcwd()}/../tmp2/{dataset_name}/{info.version}/{dataset_name}-train.tfrecord*' | |
files = tf.data.Dataset.list_files(file_pattern) |
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
dataset_name = 'cats_vs_dogs' | |
filePath = f"{getcwd()}/../tmp2" | |
dataset, info = tfds.load(name=dataset_name, split=tfds.Split.TRAIN, with_info=True, data_dir=filePath) | |
print(info.version) | |
def preprocess(features): | |
image = features['image'] | |
image = tf.image.resize(image, (224, 224)) | |
image = image / 255.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
def create_model(): | |
input_layer = tf.keras.layers.Input(shape=(224, 224, 3)) | |
base_model = tf.keras.applications.MobileNetV2(input_tensor=input_layer, | |
weights='imagenet', | |
include_top=False) | |
base_model.trainable = False | |
x = tf.keras.layers.GlobalAveragePooling2D()(base_model.output) | |
x = tf.keras.layers.Dense(2, activation='softmax')(x) | |
model = tf.keras.models.Model(inputs=input_layer, outputs=x) |
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 multiprocessing | |
import tensorflow as tf | |
import tensorflow_datasets as tfds | |
from os import getcwd |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Training a model on browser</title> | |
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@latest"></script> | |
<script lang="js"> | |
async function doTraining(model){ | |
const history = | |
await model.fit(xs, ys, |
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
var apn = require("apn"); | |
var Firebase = require("firebase"); | |
var service = new apn.connection({ production: false }); // true for production pipeline | |
// Create a reference to the push notification queue | |
var pushRef = new Firebase("<your-firebase>.firebaseio.com/notificationQueue"); | |
// listen for items added to the queue | |
pushRef.on("child_added", function(snapshot) { |
NewerOlder