forked from YunYang1994/TensorFlow2.0-Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
YunYang1994
authored and
YunYang1994
committed
Mar 8, 2019
1 parent
faedc0d
commit e3abf2d
Showing
4 changed files
with
259 additions
and
69 deletions.
There are no files selected for viewing
129 changes: 129 additions & 0 deletions
129
1-Introduction/.ipynb_checkpoints/variable-checkpoint.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import tensorflow as tf" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Variables are manipulated via the tf.Variable class.\n", | ||
"# A tf.Variable represents a tensor whose value can be changed by running ops on it.\n", | ||
"# Specific ops allow you to read and modify the values of this tensor.\n", | ||
"\n", | ||
"## Creaging a Variable" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": { | ||
"scrolled": false | ||
}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"tensor: <tf.Variable 'my/Variable:0' shape=() dtype=int32, numpy=1>\n", | ||
"value: 1\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"with tf.name_scope(\"my\"):\n", | ||
" variable = tf.Variable(1)\n", | ||
"print(\"tensor:\", variable)\n", | ||
"print(\"value:\", variable.numpy())" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"## Using Variables\n", | ||
"\n", | ||
"# To use the value of a tf.Variable in a TensorFlow graph, simply treat it like a normal tf.Tensor" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"value: 2\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"variable = variable + 1\n", | ||
"print(\"value:\", variable.numpy())" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"## Using Variables\n", | ||
"\n", | ||
"# To use the value of a tf.Variable in a TensorFlow graph, simply treat it like a normal tf.Tensor" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 7, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"value: 3\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"variable = tf.Variable(2)\n", | ||
"variable.assign_add(1)\n", | ||
"print(\"value:\", variable.numpy())" | ||
] | ||
} | ||
], | ||
"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.5.2" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import tensorflow as tf" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Variables are manipulated via the tf.Variable class.\n", | ||
"# A tf.Variable represents a tensor whose value can be changed by running ops on it.\n", | ||
"# Specific ops allow you to read and modify the values of this tensor.\n", | ||
"\n", | ||
"## Creaging a Variable" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": { | ||
"scrolled": false | ||
}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"tensor: <tf.Variable 'my/Variable:0' shape=() dtype=int32, numpy=1>\n", | ||
"value: 1\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"with tf.name_scope(\"my\"):\n", | ||
" variable = tf.Variable(1)\n", | ||
"print(\"tensor:\", variable)\n", | ||
"print(\"value:\", variable.numpy())" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"## Using Variables\n", | ||
"\n", | ||
"# To use the value of a tf.Variable in a TensorFlow graph, simply treat it like a normal tf.Tensor" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"value: 2\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"variable = variable + 1\n", | ||
"print(\"value:\", variable.numpy())" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"## Using Variables\n", | ||
"\n", | ||
"# To use the value of a tf.Variable in a TensorFlow graph, simply treat it like a normal tf.Tensor" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 7, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"value: 3\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"variable = tf.Variable(2)\n", | ||
"variable.assign_add(1)\n", | ||
"print(\"value:\", variable.numpy())" | ||
] | ||
} | ||
], | ||
"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.5.2" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters