Thursday, June 21, 2018

How to install Ubuntu

As seen on Windows 10 (now Ubuntu)


What?

This is the story of the time I installed Linux / Ubuntu (and lost all my pictures and also my Windows Operating System)


Why?

Windows was occupying a lot of space and not letting me do cool stuff. And what exactly is it updating every week?! Also I thought somehow Ubuntu would allow to me train my Deep Learning Models. (Nope, doesn't work, need more CPU power, and a GPU, not just free Hard Disk space or a different OS :) 


How


  1. Save your precious stuff because even if you think you are going to keep Windows, you may end up formatting your other disks!
  2. Get Ubuntu from https://www.ubuntu.com/desktop
  3. Get https://unetbootin.github.io/ to boot 
  4. Save these two things on a USB drive (e.g. pen-drive)
  5. Use unetbootin to extract ubuntu iso on pen-drive or hard disk(if you want to remove windows)
  6. Restart Computer
  7. On my dell, pressing F12 took me to boot up settings.
  8. Select booting from pen-drive
  9. Install Ubuntu or try out first (did both)
  10. During installation it will ask if you want to format your disk. I formatted it, but if you want to keep Windows, too, choose not to format.
Installation takes 30-45 minutes

Oh look! So much free space! 


Wednesday, June 20, 2018

How to change the link to your blog post when you change its title

You can change the link in Permalink -> Custom Permalink



https://www.blogger.com makes links to your blog post with the date of creation(month and year) and title of your blog, automatically.

If you end up changing your title and want it to reflect in the link, use 'Revert to draft' and 'Publish' again.

If you have already shared the link, create a post with the old title and in the content add the new link. Change schedule to the date of the original blog and publish :)



How not to install Ubuntu

Changed and moved to How to install Ubuntu

Saturday, June 16, 2018

Teach your computer XOR function with Tensorflow.js

Disclaimer: I am not qualified to teach you. But while you're here, let's learn something together.


What is XOR?


XOR or exclusive-OR is a logical operation that returns true if only one of the inputs is true. (only considering for two input combination)
https://en.wikipedia.org/wiki/Exclusive_or

Behold my bad handwriting : )


It's difficult to teach a computer XOR because the output cannot be separated by a straight line. However, now that we have the power of Machine Learning, we are going to do exactly that.

Visualize the Neural Network using TensorFlow Playground


I really enjoy trying out different Neural Networks(NN) on https://playground.tensorflow.org
Here is the NN I use for XOR playground.tensorflow.org




Bring out the power of Tensorflow.js


(Find the full code on github )

Here we are building a 2 layer NN, 1 hidden layer with 4 units and an output layer with 1 unit (the output should be between 0 and 1)

Get tensorflow.js
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@0.11.6">

Input :
const train_xs = tf.tensor2d([
[0, 0],
[0, 1],
[1, 0],
[1, 1]
]);

Output:
const train_ys = tf.tensor2d([0, 1, 1, 0], [4, 1]);
These will stay the same :)

We'll use a sequential model - that means the output of one layer is fed into the input for the next layer.
const model = tf.sequential();

Add a fully connected hidden layer. It is mandatory to give the input shape. Our inputs will be two numbers between 0 and 1. (Fully connected- each input unit is mapped to each output unit). I'll probably write about neural networks, activations, weights, and biases soon (or not), till then follow the references.
model.add(
tf.layers.dense({
inputShape: [2],
units: 4,
activation: "sigmoid",
useBias: true })
);
The activation function sigmoid was giving much better results than relu :D

Add a fully connected output layer
model.add(
tf.layers.dense({
units: 1,
activation: "sigmoid" })
);

Our model is ready! Time to compile.
Learning rate should be small, you can experiment with different values. 0.1 worked for me.
const LEARNING_RATE = 0.1;
const optimizer = tf.train.adam(LEARNING_RATE);
model.compile({
optimizer: optimizer,
loss: tf.losses.meanSquaredError,
metrics: ["accuracy"]
});

I was trying to make things work with sgd(stochastic gradient descent) optimizer, but adam worked so much better for XOR. It's a lot about hit and trial.

To fit the training data we train the model on our input multiple times. Ask the fit function to shuffle the input.

You'll notice the loss decreasing and the accuracy increasing after each round. That's it! You're done!

Make predictions


Input can be as simple as
var input = tf.tensor2d([[0, 1]]);

Use the predict function of model to make predictions
var output = model.predict(input);
console.log(output.dataSync());


I am using a canvas to depict my predictions for different inputs.
(I should write a blog on that alone because man, is that difficult!)
Find the full code on github

My canvas looked like this after 20 epochs

Inspiration


I was inspired to build a model for XOR on watching a coding challenge on 'The Coding Train' by Daniel Shiffman (https://twitter.com/shiffman)
While you're on twitter, here's my handle @iShivangiDas


Did not understand everything?


If you want to learn about TensorFlow APIs go to https://js.tensorflow.org/api/0.11.6/
Neural Networks can be learned from Coursera - https://www.coursera.org/learn/neural-networks-deep-learning (I loved these courses and would highly recommend to everyone)



Friday, June 8, 2018

Review: The Hundred-Year-Old Man Who Climbed Out of the Window and Disappeared

The Hundred-Year-Old Man Who Climbed Out of the Window and Disappeared The Hundred-Year-Old Man Who Climbed Out of the Window and Disappeared by Jonas Jonasson
My rating: 5 of 5 stars

It's funny, it's interesting, it's feel-good, it's everything you expect in a novel with a crazy title like that.
Reminded me of the movie 'Forrest Gump' but I liked the book more:)

View all my reviews