Skip to content

Commit

Permalink
adding notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
BinRoot committed Dec 13, 2016
1 parent 82b039f commit cd97350
Show file tree
Hide file tree
Showing 44 changed files with 5,751 additions and 344 deletions.
@@ -0,0 +1,96 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Import TensorFlow and Numpy"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import tensorflow as tf\n",
"import numpy as np"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"source": [
"Define a 2x2 matrix in different ways"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"m1 = [[1.0, 2.0], [3.0, 4.0]]\n",
"m2 = np.array([[1.0, 2.0], [3.0, 4.0]], dtype=np.float32)\n",
"m3 = tf.constant([[1.0, 2.0], [3.0, 4.0]])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's see what happens when we print them."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<type 'list'>\n",
"<type 'numpy.ndarray'>\n",
"<class 'tensorflow.python.framework.ops.Tensor'>\n"
]
}
],
"source": [
"print(type(m1))\n",
"print(type(m2))\n",
"print(type(m3))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.12"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
@@ -0,0 +1,149 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Concept 02"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Evaluating ops"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Import TensorFlow:"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import tensorflow as tf"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"source": [
"Start with a 1x2 matrix:"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"x = tf.constant([[1, 2]])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's negate it. Define the negation op to be run on the matrix:"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"neg_x = tf.neg(x)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"It's nothing special if you print it out. In fact, it doesn't even perform the negation computation. Check out what happens when you simply print it:"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Tensor(\"Neg_3:0\", shape=(1, 2), dtype=int32)\n"
]
}
],
"source": [
"print(neg_x)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You need to summon a session so you can launch the negation op:"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[-1 -2]]\n"
]
}
],
"source": [
"with tf.Session() as sess:\n",
" result = sess.run(neg_x)\n",
" print(result)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2.0
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.12"
}
},
"nbformat": 4,
"nbformat_minor": 0
}

0 comments on commit cd97350

Please sign in to comment.