This file contains 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
try: | |
# %tensorflow_version only exists in Colab. | |
%tensorflow_version 2.x | |
except Exception: | |
pass | |
import tensorflow as tf |
This file contains 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
mnist = tf.keras.datasets.fashion_mnist | |
(training_images, training_labels), (test_images, test_labels) = mnist.load_data() |
This file contains 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
class myCallback(tf.keras.callbacks.Callback): | |
def on_epoch_end(self, epoch, logs = {}): | |
if logs.get('loss') < 0.7: | |
print("\n Low loss so cancelling the training") | |
self.model.stop_training = True | |
This file contains 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 train_mnist(): | |
# Please write your code only where you are indicated. | |
# please do not remove # model fitting inline comments. | |
# YOUR CODE SHOULD START HERE | |
class myCallback(tf.keras.callbacks.Callback): | |
def on_epoch_end(self, epoch, logs={}): | |
if(logs.get('acc')>0.99): | |
print("/nReached 99% accuracy so cancelling training!") | |
self.model.stop_training = True |
This file contains 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 train_mnist_conv(): | |
# Please write your code only where you are indicated. | |
# please do not remove model fitting inline comments. | |
# YOUR CODE STARTS HERE | |
class myCallback(tf.keras.callbacks.Callback): | |
def on_epoch_end(self, epoch, logs={}): | |
if(logs.get('acc')>0.998): | |
print("/n Reached 99.8% accuracy so cancelling training!") | |
self.model.stop_training = True |
This file contains 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
public class Monster{ | |
private String name; | |
private final int MAX_HEALTH = 100; | |
private static int curr_health = 100; | |
private double dmg_inf; | |
private double dmg_taken; | |
public String getName() { | |
return name; |
This file contains 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
{ | |
"embeddings": [ | |
{ | |
"tensorName": "My tensor", | |
"tensorShape": [ | |
1000, | |
50 | |
], | |
"tensorPath": "https://raw.githubusercontent.com/.../tensors.tsv", | |
"metadataPath": "https://raw.githubusercontent.com/.../optional.metadata.tsv" |
This file contains 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>TensorFlow.js Tutorial</title> | |
<!-- Import TensorFlow.js --> | |
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@1.0.0/dist/tf.min.js"></script> | |
<!-- Import tfjs-vis --> | |
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-vis@1.0.2/dist/tfjs-vis.umd.min.js"></script> |
This file contains 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
/** | |
* Get the car data reduced to just the variables we are interested | |
* and cleaned of missing data. | |
*/ | |
async function getData() { | |
const carsDataReq = await fetch('https://storage.googleapis.com/tfjs-tutorials/carsData.json'); | |
const carsData = await carsDataReq.json(); | |
const cleaned = carsData.map(car => ({ | |
mpg: car.Miles_per_Gallon, | |
horsepower: car.Horsepower, |
This file contains 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
async function run() { | |
// Load and plot the original input data that we are going to train on. | |
const data = await getData(); | |
const values = data.map(d => ({ | |
x: d.horsepower, | |
y: d.mpg, | |
})); | |
tfvis.render.scatterplot( | |
{name: 'Horsepower v MPG'}, |
OlderNewer