Skip to content

Instantly share code, notes, and snippets.

View Rishit-dagli's full-sized avatar
:octocat:
Making Machines Learn

Rishit Dagli Rishit-dagli

:octocat:
Making Machines Learn
View GitHub Profile
@Rishit-dagli
Rishit-dagli / import_tensorflow2.0.py
Created December 25, 2019 11:00
Import TensorFlow in Colab
try:
# %tensorflow_version only exists in Colab.
%tensorflow_version 2.x
except Exception:
pass
import tensorflow as tf
mnist = tf.keras.datasets.fashion_mnist
(training_images, training_labels), (test_images, test_labels) = mnist.load_data()
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
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
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
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;
@Rishit-dagli
Rishit-dagli / projector_config_imdb.json
Created March 20, 2020 10:43
TF projector for IMDB dataset
{
"embeddings": [
{
"tensorName": "My tensor",
"tensorShape": [
1000,
50
],
"tensorPath": "https://raw.githubusercontent.com/.../tensors.tsv",
"metadataPath": "https://raw.githubusercontent.com/.../optional.metadata.tsv"
@Rishit-dagli
Rishit-dagli / index.html
Created March 31, 2020 12:38
STarter index.html for TF.js
<!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>
@Rishit-dagli
Rishit-dagli / script.js
Created March 31, 2020 13:31
Addon script.js for loading data
/**
* 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,
@Rishit-dagli
Rishit-dagli / script.js
Created March 31, 2020 13:34
Scatterplot of data
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'},