Consider this numpy array A1, that has a shape 3 by 4 (axis 0 dimensions by axis 1 dimensions):

import numpy as np
A1 = np.arange(12).reshape(3,4)

#array([[ 0,  1,  2,  3],
#       [ 4,  5,  6,  7],

Cross Entropy Cost and Numpy Implementation

Given the Cross Entroy Cost Formula:



  • J is the averaged cross entropy cost
  • m is the number of samples
  • super script [L] corresponds to output layer

Q: how the following two differ, in the computation of prediction accuracy? (note: Y = true label, Y_preduction = predicted label).

(from, programming assignment. Course 1 - deep learning and neural network.)

Option 1 - Logistric Regression (Week 2):

print("Test accuracy: {} %".format(100 - np.mean(np.abs(Y_prediction - Y)) * 100))


Imagine we have n particles in our "universe". These particles have a random initial x, y, and z coordinates to begin with. Defined by Newton's law of universal gravitation, each particle attracts every other particles in this universe using a force that is directly proportional to the product of their masses and inversely proportional to the square of the distance between their centers. As as result, these particles gain (and lose) velocities and change positions over time. The modelling of this physical mechanics is called a N-body simulation.

There currently exists many N-body simulation algorithms. Some are less advanced and highly computational costly (execution time in the order of O(N^2)) - but simple and easy to understand. Some others are more advanced and significantly more efficient (execution in the order of O(n*log(n)) - but not as simple and easy to understand. This articles focuses on the implementation aspect of the less advanced toy algorithm - for the benefit of ease o

View tmux-cheatsheet.markdown

tmux shortcuts & cheatsheet

start new:


start new with session name:

tmux new -s myname
View environment.yml
name: helloworld
- python=2.7
- anaconda

Grr this took hours to figure out. I was trying to install MJPG-streamer and running VLC command lines and all this crap but nothing worked.

First install motion:

~> sudo apt-get install motion

Then create a config file:

~> mkdir ~/.motion
~> nano ~/.motion/motion.conf

Use this page to jot down notes regarding small garden birdwatch project.

Intel Joule

import numpy as np
# sow a fix seed to make trial and error more predictable
# create a 10 x 3 NumPy array
a = np.random.rand(10,3)
# do the fancy indexing: for each row, extract the element that is closest to 0.5
a2 = a[np.arange(a.shape[0]), np.argsort(np.abs(a - 0.5))[:,0]]