Skip to content

Commit

Permalink
First exercise
Browse files Browse the repository at this point in the history
  • Loading branch information
cpenalozag committed Jan 15, 2018
1 parent ff30fa8 commit a9b867a
Show file tree
Hide file tree
Showing 7 changed files with 452 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[ 0.13173302 7.80728589 6.26190867 7.2219721 ]\n",
" [ 4.34703125 7.83297 9.41237969 7.4847714 ]\n",
" [ 1.91750257 9.10735505 1.12573619 7.93226677]]\n"
]
}
],
"source": [
"import numpy as np\n",
"\n",
"A = 10*np.random.rand(3,4)\n",
"print(A)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[ 18.75768804 13.9073695 21.41652281 15.24013189]\n"
]
}
],
"source": [
"cal = A.sum(axis=0)\n",
"print(cal)"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[ 29.81471408 50.34378724 36.86021364 64.43175012]\n",
" [ 26.96686398 38.48118926 33.10381054 11.96405678]\n",
" [ 43.21842194 11.1750235 30.03597582 23.6041931 ]]\n"
]
}
],
"source": [
"percentage = 100*A/(cal.reshape(1,4))\n",
"print(percentage)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(3, 3)\n"
]
}
],
"source": [
"a = np.random.randn(3, 3)\n",
"b = np.random.randn(3, 1)\n",
"c = a*b\n",
"print (c.shape)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.0"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[ 0.60389225]\n",
" [ 0.6429397 ]\n",
" [ 0.35553732]\n",
" [ 0.11588369]\n",
" [ 0.44658051]]\n",
"(5, 1)\n"
]
}
],
"source": [
"import numpy as np\n",
"\n",
"a = np.random.rand(5,1)\n",
"print (a)\n",
"print (a.shape)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[ 0.60389225 0.6429397 0.35553732 0.11588369 0.44658051]]\n"
]
}
],
"source": [
"print (a.T)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[ 0.36468585 0.3882663 0.21470623 0.06998126 0.26968651]\n",
" [ 0.3882663 0.41337146 0.22858906 0.07450623 0.28712434]\n",
" [ 0.21470623 0.22858906 0.12640679 0.04120098 0.15877604]\n",
" [ 0.06998126 0.07450623 0.04120098 0.01342903 0.0517514 ]\n",
" [ 0.26968651 0.28712434 0.15877604 0.0517514 0.19943415]]\n"
]
}
],
"source": [
"print(np.dot(a,a.T))"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import math\n",
"def basic_sigmoid(x):\n",
" \"\"\"\n",
" Compute sigmoid of x.\n",
"\n",
" Arguments:\n",
" x -- A scalar\n",
"\n",
" Return:\n",
" s -- sigmoid(x)\n",
" \"\"\"\n",
" s = 1/(1+math.exp(-x))\n",
"\n",
" \n",
" return s"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"0.9933071490757153"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"basic_sigmoid(5)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.0"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 2,
"metadata": {
"collapsed": false
},
Expand All @@ -11,9 +11,9 @@
"name": "stdout",
"output_type": "stream",
"text": [
"[[ 5.59255106 7.00149651 7.89417606 9.8194837 ]\n",
" [ 5.05836022 5.35172118 7.08968514 1.82333803]\n",
" [ 8.10677676 1.55415181 6.43266161 3.59731016]]\n"
"[[ 0.13173302 7.80728589 6.26190867 7.2219721 ]\n",
" [ 4.34703125 7.83297 9.41237969 7.4847714 ]\n",
" [ 1.91750257 9.10735505 1.12573619 7.93226677]]\n"
]
}
],
Expand Down Expand Up @@ -66,6 +66,28 @@
"print(percentage)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(3, 3)\n"
]
}
],
"source": [
"a = np.random.randn(3, 3)\n",
"b = np.random.randn(3, 1)\n",
"c = a*b\n",
"print (c.shape)"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
Loading

0 comments on commit a9b867a

Please sign in to comment.