Last active
October 6, 2019 06:51
-
-
Save srfrnk/1ea0fa0ac30cc91cae69043b09822fd8 to your computer and use it in GitHub Desktop.
csv.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"name": "csv.ipynb", | |
"provenance": [], | |
"collapsed_sections": [], | |
"toc_visible": true, | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/srfrnk/1ea0fa0ac30cc91cae69043b09822fd8/csv.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "hEtPeWfJznuN", | |
"colab_type": "code", | |
"colab": {} | |
}, | |
"source": [ | |
"!pip3 install --user tensorflow==2.0.0-rc1 numpy==1.17.1 gast==0.2.2 matplotlib pandas pathlib" | |
], | |
"execution_count": 0, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "ZjATphMazTAV", | |
"colab_type": "code", | |
"colab": {} | |
}, | |
"source": [ | |
"from __future__ import absolute_import, division, print_function\n", | |
"\n", | |
"import tensorflow as tf\n", | |
"import numpy as np\n", | |
"import pathlib\n", | |
"import matplotlib.pyplot as plt\n", | |
"import pandas as pd\n", | |
"from tensorflow import keras\n", | |
"from tensorflow.keras import layers\n", | |
"import functools\n", | |
"from collections import OrderedDict\n", | |
"\n", | |
"print(tf.version.VERSION)\n", | |
"print(tf.keras.__version__)\n", | |
"print(np.__version__)\n", | |
"\n", | |
"pd.set_option('display.max_rows', 1000)" | |
], | |
"execution_count": 0, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "4m4KZGlNzCXb", | |
"colab_type": "code", | |
"colab": {} | |
}, | |
"source": [ | |
"def foo(f): \n", | |
" print(f)\n", | |
" return f\n", | |
"\n", | |
"print('Load with single epoch:')\n", | |
"ds1 = tf.data.experimental.make_csv_dataset(\n", | |
" './test.csv',\n", | |
" batch_size=1,\n", | |
" select_columns=['PassengerId', 'Pclass', 'Sex', 'Age', 'SibSp', 'Parch', 'Fare', 'Embarked'],\n", | |
" num_epochs=1\n", | |
").map(foo).take(1)\n", | |
"\n", | |
"print('Load with endless epochs:')\n", | |
"ds2 = tf.data.experimental.make_csv_dataset(\n", | |
" './test.csv',\n", | |
" batch_size=1,\n", | |
" select_columns=['PassengerId', 'Pclass', 'Sex', 'Age', 'SibSp', 'Parch', 'Fare', 'Embarked'],\n", | |
" num_epochs=None\n", | |
").map(foo).take(1)\n" | |
], | |
"execution_count": 0, | |
"outputs": [] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment