7
$\begingroup$

I'd like to make pipeline for optimizing Gpu and Cpu. Dataset

It's about 10000 datapoint and 4 description variables for the regression problem.

df = pd.read_csv("dataset")
X_train, X_test, y_train, y_test = 
train_test_split(df.iloc[:, :-1].values, df.iloc[:, -1].values)
scaler = MinMaxScaler()
scaler.fit(X_train)
X_train_scaled = scaler.transform(X_train)
batch_size = 64
with tf.Session() as sess:
  dataset = tf.data.Dataset.from_tensor_slices((X_train_scaled, y_train))
  dataset = dataset.cache()
  dataset = dataset.shuffle(len(X_train_scaled))
  dataset = dataset.repeat()
  dataset = dataset.batch(batch_size)
  dataset = dataset.prefetch(batch_size*10)
  iterator = dataset.make_one_shot_iterator()
  print(sess.run(iterator.get_next()[0]),sess.run(iterator.get_next()[1]))
  his = model.fit(dataset, epochs=300, steps_per_epoch=1000, verbose=0)

[[0.54192635 0.36815166 0.37738184 0.13592493] [0.31898017 0.33687204 0.59490225 0.59597855] [0.2733711 0.26047393 0.42761693 0.99986595] [0.77025496 0.98919431 0.45632269 0.66447721] [0.64305949 0.50236967 0.53823311 0.56313673]]
[429.66 460.53 428.49 446.62 456.84]

In the fitting model, the following error

AttributeError: 'PrefetchDataset' object has no attribute 'ndim'

I saw some issues with this problem.

But it didn't work for me.

Software version: Keras:2.2.4 Tensorflow:1.12.0

$\endgroup$
1
  • $\begingroup$ Can you upgrade your tensorflow version? Sometimes there is a version mismatch causing errors like this. Wondering if you can try a different version or not. $\endgroup$
    – Donald S
    Commented Jun 14, 2020 at 5:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.