Skip to content

Instantly share code, notes, and snippets.

@kyrcha
Created July 16, 2019 17:02
Show Gist options
  • Select an option

  • Save kyrcha/bb7bbd44d90d4af346b233adf1a16102 to your computer and use it in GitHub Desktop.

Select an option

Save kyrcha/bb7bbd44d90d4af346b233adf1a16102 to your computer and use it in GitHub Desktop.
Converting a pandas dataframe with each row being a vector image to a 4D tensor for CNN use in Keras
# Transforming a 60000x784 dataframe to a 60000x28x28x1 4D tensor for Keras modelling
train_img = X_train.values.reshape(X_train.shape[0], 28, 28, 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment