AnswerBun.com

Tensorflow v1 Dataset API AttributeError with ndim

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

Data Science Asked by AutomaKen on December 29, 2020

0 Answers

Add your own answers!

Related Questions

IRL with noisy observations?

0  Asked on January 8, 2021 by matheus-silva

 

K-Prototype for anomaly detection

1  Asked on January 7, 2021 by sridhar-iyer

   

Xgboost take k best predictions

2  Asked on January 7, 2021 by ariel-amar

 

Saving and Loading Tensorflow Model Results in Keras Error

2  Asked on January 7, 2021 by aaron-jones

     

MLP conv layers

2  Asked on January 7, 2021

     

NLP SBert (Bert) for answer comparison STS

3  Asked on January 7, 2021 by b_the_builder

     

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved.