You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+34-34Lines changed: 34 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -210,7 +210,7 @@ print(b.name) # prints "b:0"
210
210
TensorFlow introduces two different context managers to alter the name of tensors and variables. The first is tf.name_scope which modifies the name of tensors:
211
211
212
212
```python
213
-
with tf.name_scope('scope'):
213
+
with tf.name_scope("scope"):
214
214
a = tf.get_variable(name="a", shape=[])
215
215
print(a.name) # prints "a:0"
216
216
@@ -221,7 +221,7 @@ with tf.name_scope('scope'):
221
221
The other is tf.variable_scope which modifies the name of both tensors and variables:
222
222
223
223
```python
224
-
with tf.variable_scope('scope'):
224
+
with tf.variable_scope("scope"):
225
225
a = tf.get_variable(name="a", shape=[])
226
226
print(a.name) # prints "scope/a:0"
227
227
@@ -234,16 +234,16 @@ Note that there are two ways to define new variables in TensorFlow, by calling t
234
234
tf.get_variable enables variable sharing which is useful when building neural network models. Calling tf.get_variable with a new name results in creating a new variable, but if a variable with a same name exists it will raise a ValueError exception, telling us that re-declaring a variable is not allowed:
The schedule flag decides which member function of the Experiment object gets called. So, if you for example set schedule to 'train_and_evaluate', experiment.train_and_evaluate() would be called.
1022
+
The schedule flag decides which member function of the Experiment object gets called. So, if you for example set schedule to "train_and_evaluate", experiment.train_and_evaluate() would be called.
1023
1023
1024
1024
Now let's have a look at how we might actually write an input function. One way to do this is through python ops (See [this item](#python_ops) for more information on python ops).
1025
1025
```python
@@ -1044,8 +1044,8 @@ An alternative way is to write your data as TFRecords format and use the multi-t
1044
1044
```python
1045
1045
definput_fn():
1046
1046
features = {
1047
-
'image': tf.FixedLenFeature([], tf.string),
1048
-
'label': tf.FixedLenFeature([], tf.int64),
1047
+
"image": tf.FixedLenFeature([], tf.string),
1048
+
"label": tf.FixedLenFeature([], tf.int64),
1049
1049
}
1050
1050
tensors = tf.contrib.learn.read_batch_features(
1051
1051
file_pattern=...,
@@ -1055,29 +1055,29 @@ def input_fn():
1055
1055
```
1056
1056
See [mnist.py](https://github.com/vahidk/EffectiveTensorFlow/blob/master/code/framework/dataset/mnist.py) for an example of how to convert your data to TFRecords format.
1057
1057
1058
-
The framework also comes with a simple convolutional network classifier in [convnet_classifier.py](https://github.com/vahidk/EffectiveTensorFlow/blob/master/code/framework/model/convnet_classifier.py) that includes an example model and evaluation metric:
1058
+
The framework also comes with a simple convolutional network classifier in [cnn_classifier.py](https://github.com/vahidk/EffectiveTensorFlow/blob/master/code/framework/model/cnn_classifier.py) that includes an example model and evaluation metric:
MetricSpec connects our model to the given metric function (e.g. tf.metrics.accuracy). Since our label and predictions solely include a single tensor, everything automagically works. Although if your label/prediction includes multiple tensors, you need to explicitly specify which tensors you want to pass to the metric function:
1076
1076
```python
1077
1077
tf.contrib.learn.MetricSpec(
1078
1078
tf.metrics.accuracy,
1079
-
label_key='label',
1080
-
prediction_key='predictions')
1079
+
label_key="label",
1080
+
prediction_key="predictions")
1081
1081
```
1082
1082
1083
1083
And that's it! This is all you need to get started with TensorFlow learn API. I recommend to have a look at the [source code](https://github.com/vahidk/EffectiveTensorFlow/tree/master/code/framework) and see the official python API to learn more about the learn API.
0 commit comments