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: get_started/checkpoints.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ This document focuses on checkpoints. For details on SavedModel, see the
16
16
## Sample code
17
17
18
18
This document relies on the same
19
-
[https://github.com/tensorflow/models/blob/master/samples/core/get_started/premade_estimator.py](Iris classification example) detailed in @{$premade_estimators$Getting Started with TensorFlow}.
19
+
[Iris classification example](https://github.com/tensorflow/models/blob/master/samples/core/get_started/premade_estimator.py) detailed in @{$premade_estimators$Getting Started with TensorFlow}.
20
20
To download and access the example, invoke the following two commands:
(for example, `LinearRegressor`) to implement common ML algorithms. Beyond
@@ -199,7 +195,7 @@ following tasks:
199
195
* Call one or more methods on the Estimator object, passing the appropriate
200
196
input function as the source of the data.
201
197
202
-
Let's see how those tasks are implemented in Iris.
198
+
Let's see how those tasks are implemented for Iris classification.
203
199
204
200
## Create input functions
205
201
@@ -209,41 +205,54 @@ evaluating, and prediction.
209
205
An **input function** is a function that returns a @{tf.data.Dataset} object
210
206
which outputs the following two-element tuple:
211
207
212
-
*"features" - A Python dictionary in which:
208
+
*[`features`](https://developers.google.com/machine-learning/glossary/#feature) - A Python dictionary in which:
213
209
* Each key is the name of a feature.
214
210
* Each value is an array containing all of that feature's values.
215
-
*"label" - An array containing the values of the
211
+
*`label` - An array containing the values of the
216
212
[label](https://developers.google.com/machine-learning/glossary/#label) for
217
213
every example.
218
214
219
-
Your input function may generate the "features" dictionary and "label" list any
220
-
way you like. However, we recommend using TensorFlow's @{tf.data.Dataset} API,
221
-
which can deftly parse all sorts of data. At a high-level,
222
-
the @{tf.data.Dataset} API consists of the following classes:
215
+
Just to demonstrate the format of the input function, here's a simple
216
+
implementation:
217
+
218
+
```python
219
+
definput_evaluation_set():
220
+
features = {'SepalLength': np.array([6.4, 5.0]),
221
+
'SepalWidth': np.array([2.8, 2.3]),
222
+
'PetalLength': np.array([5.6, 3.3]),
223
+
'PetalWidth': np.array([2.2, 1.0])}
224
+
labels = np.array([2, 1])
225
+
return features, labels
226
+
```
227
+
228
+
Your input function may generate the `features` dictionary and `label` list any
229
+
way you like. However, we recommend using TensorFlow's Dataset API, which can
230
+
parse all sorts of data. At a high level, the Dataset API consists of the
alt="A diagram showing subclasses of the Dataset class"
227
236
src="../images/dataset_classes.png">
228
237
</div>
229
238
239
+
Where the individual members are:
230
240
231
-
Where:
232
-
233
-
* Dataset: Base class containing methods to create and transform datasets. Also
234
-
allows you to initialize a dataset from data in memory, or from a Python
235
-
generator.
236
-
* TextLineDataset: Reads lines from text files.
237
-
* TFRecordDataset: Reads records from TFRecord files.
238
-
* FixedLengthRecordDataset: Reads fixed size records from binary files.
239
-
* Iterator: Provides a way to access one data set element at a time.
241
+
*`Dataset` - Base class containing methods to create and transform
242
+
datasets. Also allows you to initialize a dataset from data in memory, or from
243
+
a Python generator.
244
+
*`TextLineDataset` - Reads lines from text files.
245
+
*`TFRecordDataset` - Reads records from TFRecord files.
246
+
*`FixedLengthRecordDataset` - Reads fixed size records from binary files.
247
+
*`Iterator` - Provides a way to access one data set element at a time.
240
248
241
249
The Dataset API can handle a lot of common cases for you. For example,
242
250
using the Dataset API, you can easily read in records from a large collection
243
251
of files in parallel and join them into a single stream.
244
252
245
-
To keep things simple in this example we are going to load the data with pandas,
246
-
and build our input pipeline from this in-memory data.
253
+
To keep things simple in this example we are going to load the data with
254
+
[pandas](https://pandas.pydata.org/), and build our input pipeline from this
255
+
in-memory data.
247
256
248
257
Here is the input function used for training in this program, which is available
249
258
in [`iris_data.py`](https://github.com/tensorflow/models/blob/master/samples/core/get_started/iris_data.py):
0 commit comments