Permalink
Browse files

Changed some folder locations

  • Loading branch information...
sachinruk committed Sep 15, 2017
1 parent 7370ddb commit 3cb5eacea650e60d02d6d527c37ce3e0d8702cbf

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -9,14 +9,14 @@
"https://www.youtube.com/watch?v=q5iL3XYFv2M\n",
"\n",
"## Backpropagation on zero hidden layer classification case\n",
"\n",
"Suppose we are required to learn the function that maps $x$ (the inputs) to $y$ (the outputs). In this particular instance we restrict ourselves to the case that $y=\\sigma(Wx)$. The maths behind regression is shown below:\n",
"\\begin{align}\n",
"z_i =& Wx_i\\\\\n",
"a_i =& \\sigma(z_i)\n",
"\\end{align}\n",
"where $\\sigma(z_i) = 1/(1+exp(-z_i))$ is the sigmoid function and the loss function is $$\\mathcal{L} = \\frac{1}{2N}\\sum_i (y_i-a_i)^2$$.\n",
"where $\\sigma(z_i) = 1/(1+exp(-z_i))$ is the sigmoid function. $a_i$ is commonly known as the activation. **The loss function** is $$\\mathcal{L} = \\frac{1}{2N}\\sum_i (y_i-a_i)^2$$. \n",
"\n",
"We need to adjust the $W$ to minimise the loss function. We use the chain rule:\n",
"**We need to adjust the $W$ to minimise the loss function**. We use the chain rule:\n",
"\\begin{align}\n",
"\\frac{d \\mathcal{L}}{dW} =& \\sum_i \\frac{d\\mathcal{L}}{da_i}\\frac{da_i}{dz_i}\\frac{dz_i}{dW}\\\\\n",
"=& \\frac{1}{N}\\sum_i -(y_i-a_i)\\cdot\\frac{\\exp(-z)}{(1+\\exp(-z))^2}\\cdot x_i\\\\\n",
@@ -18,7 +18,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"Using Theano backend.\n"
"Using TensorFlow backend.\n"
]
}
],
@@ -45,6 +45,19 @@
"data": {
"text/html": [
"<div>\n",
"<style>\n",
" .dataframe thead tr:only-child th {\n",
" text-align: right;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: left;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
@@ -153,7 +166,7 @@
}
],
"source": [
"df = pd.read_csv('cmc.data',header=None,names=['Age','Education','H_education',\n",
"df = pd.read_csv('data/cmc.data',header=None,names=['Age','Education','H_education',\n",
" 'num_child','Religion', 'Employ',\n",
" 'H_occupation','living_standard',\n",
" 'Media_exposure','contraceptive'])\n",
@@ -352,7 +365,9 @@
{
"cell_type": "code",
"execution_count": 40,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"train_x = np.hstack([train_x, train_edu, train_liv])\n",
View
@@ -2,10 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"metadata": {
"deletable": true,
"editable": true
},
"metadata": {},
"source": [
"# Word2Vec\n",
"\n",
@@ -16,9 +13,7 @@
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
"collapsed": true
},
"outputs": [],
"source": [
@@ -36,11 +31,7 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"metadata": {},
"outputs": [
{
"name": "stdout",
@@ -58,19 +49,15 @@
" data = tf.compat.as_str(f.read(f.namelist()[0])).split()\n",
" return data\n",
"\n",
"words = read_data('text8.zip')\n",
"words = read_data('data/text8.zip')\n",
"print('Data size %d' % len(words))\n",
"print(words[:10])"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"metadata": {},
"outputs": [
{
"name": "stdout",
@@ -112,11 +99,7 @@
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"metadata": {},
"outputs": [
{
"name": "stdout",
@@ -166,11 +149,7 @@
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"metadata": {},
"outputs": [
{
"name": "stdout",
@@ -187,11 +166,7 @@
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"metadata": {},
"outputs": [
{
"name": "stdout",
@@ -210,10 +185,7 @@
},
{
"cell_type": "markdown",
"metadata": {
"deletable": true,
"editable": true
},
"metadata": {},
"source": [
"Shuffle the data:"
]
@@ -222,9 +194,7 @@
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": true,
"deletable": true,
"editable": true
"collapsed": true
},
"outputs": [],
"source": [
@@ -236,10 +206,7 @@
},
{
"cell_type": "markdown",
"metadata": {
"deletable": true,
"editable": true
},
"metadata": {},
"source": [
"## Tensorflow model: (Continuous Bag of Words - CBoW)"
]
@@ -248,9 +215,7 @@
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
"collapsed": true
},
"outputs": [],
"source": [
@@ -301,11 +266,7 @@
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"metadata": {},
"outputs": [
{
"name": "stdout",
@@ -589,11 +550,7 @@
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"metadata": {},
"outputs": [
{
"data": {
@@ -613,11 +570,7 @@
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"metadata": {},
"outputs": [
{
"data": {
@@ -653,9 +606,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true,
"deletable": true,
"editable": true
"collapsed": true
},
"outputs": [],
"source": []
@@ -677,7 +628,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.0"
"version": "3.6.1"
}
},
"nbformat": 4,
@@ -194,7 +194,7 @@
}
],
"source": [
"rides = pd.read_csv('hour.csv')\n",
"rides = pd.read_csv('data/hour.csv')\n",
"rides['time'] = pd.to_datetime(rides['dteday'])+pd.Series([pd.DateOffset(hours = a ) for a in rides.hr.tolist()])\n",
"rides.drop(['instant','yr','dteday','casual','registered', 'atemp'],1,inplace=True)\n",
"rides['t'] = rides.time.values.astype(float)\n",
@@ -1209,7 +1209,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
"version": "3.6.1"
},
"latex_envs": {
"bibliofile": "biblio.bib",
Oops, something went wrong.

0 comments on commit 3cb5eac

Please sign in to comment.