Kernel Crashes while Loading data using tf.data.Dataset.take() from a CSV file

Viewed 363

I wanted to Load a CSV file with a Target column and 25 feature columns.I have loaded it via pd.read_csv() as a pandas.Dataframe:

import pandas as pd
import tensorflow as tf


data = pd.read_csv("./data.csv")
data = data.astype('float64')
data.shape #returns (6500, 26)
y_train = data.pop('target')
y_train.shape #returns (6500,)

Then I used the standard Tensorflow 2.0 procedure to read values from pandas.Dataframe:

dataset = tf.data.Dataset.from_tensor_slices((data.values, y_train.values))

As the Docs said,I have to load features and targets seperately from the TensorflowSliceDataset. But as soon as i run the for loop, it freezes for couple of seconds and suddenly kernel dies without any specific reason.

for feat, targ in dataset.take(1):
  print ('Features: {}, Target: {}'.format(feat, targ))

I have tried to run the code without the for loop but the same thing happens with:

tf.constant(data['feature-1'])

I don't know what is causing this problem. I have also re-installed the pandas as well.

0 Answers
Related