Goal
I want to mod this tutorial to consume this time series dataset instead of the run-of-the-mill image data.
Approach
I have identified several approaches to get the data into the tf.estimator
API.
The most convenient (because using .from_generator
is guesswork...) was to use tf.data.Dataset.from_tensor_slices(training_data_ndarray)
as follows:
trnX, trnY, tstX, tstY = load_dataset()
trnXl = trnX.tolist()
tstXl = tstX.tolist()
tstYl = tstY.tolist()
trnYl = trnY.tolist()
trndataset = tf.data.Dataset.from_tensor_slices((trnXl, trnYl))
tstdataset = tf.data.Dataset.from_tensor_slices((tstXl, tstYl))
...
def _input_fn(partition):
if partition == "train":
dst = trndataset
elif partition == "predict":
dst = tstdataset
else:
dst = tstdataset
return dst
Error/Issue
TypeError:
input_fn
must be callable, given: DatasetV1Adapter shapes: ((128, 9), (6,)), types: (tf.float32, tf.float32)>
Reproduction
I use paperspace instance. If you have an account you can take a look here.
- If not, get full code in this gist:.
- Dataset from 2.
Setup:
- Tensorflow 1.15
- Python 3.6.8
- Eager execution: off (adanet library won't handle it).
Error appears when calling:
tf.estimator.train_and_evaluate(
estimator,
train_spec=tf.estimator.TrainSpec(
input_fn=_input_fn("train"),
max_steps=TRAIN_STEPS),
eval_spec=tf.estimator.EvalSpec(
input_fn=_input_fn("test"),
steps=None,
start_delay_secs=1,
throttle_secs=1,
))
What now?
I see no path forward using the approach of creating a tf.data.Dataset since it seems the input function ("create an input function that returns a dataset") is incorrect.