-
-
Save kiransair/79708d6db5476c8c301eebd5e3484a71 to your computer and use it in GitHub Desktop.
TF_Forum_11263.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": "TF_Forum_11263.ipynb", | |
"provenance": [], | |
"authorship_tag": "ABX9TyOhR1vTyovd0oE2EyAwaUwx", | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
}, | |
"language_info": { | |
"name": "python" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/kiransair/79708d6db5476c8c301eebd5e3484a71/tf_forum_11263.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"id": "DnZnq9CeeSG6" | |
}, | |
"outputs": [], | |
"source": [ | |
"import tensorflow as tf" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"def split(data):\n", | |
" # split off intervention\n", | |
" splitteded = tf.split(data, [6, 1], axis=0)\n", | |
"\n", | |
" # split into input and target image\n", | |
" splitted = tf.split(splitteded[0], 2, axis=1)\n", | |
" return splitted" | |
], | |
"metadata": { | |
"id": "ZQjAkEVIeZOB" | |
}, | |
"execution_count": 2, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"test_dataset = tf.data.Dataset.range(2,14)" | |
], | |
"metadata": { | |
"id": "l60ajKtZeoeb" | |
}, | |
"execution_count": 3, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"data=tf.ones([7,2])" | |
], | |
"metadata": { | |
"id": "KiVCzewvfcoo" | |
}, | |
"execution_count": 4, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"dataset = test_dataset.map(lambda x: tf.py_function(func=split,inp=[data],Tout=tf.float32))" | |
], | |
"metadata": { | |
"id": "8ymwUBfyejFy" | |
}, | |
"execution_count": 5, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"list(dataset.as_numpy_iterator())" | |
], | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "YVZ8YnBlepln", | |
"outputId": "3384a9c9-52b6-41c8-b557-c05a707ddce5" | |
}, | |
"execution_count": 6, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": [ | |
"[array([[1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.]], dtype=float32), array([[1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.]], dtype=float32), array([[1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.]], dtype=float32), array([[1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.]], dtype=float32), array([[1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.]], dtype=float32), array([[1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.]], dtype=float32), array([[1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.]], dtype=float32), array([[1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.]], dtype=float32), array([[1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.]], dtype=float32), array([[1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.]], dtype=float32), array([[1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.]], dtype=float32), array([[1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.],\n", | |
" [1.]], dtype=float32)]" | |
] | |
}, | |
"metadata": {}, | |
"execution_count": 6 | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"" | |
], | |
"metadata": { | |
"id": "Yih1tq0uewBV" | |
}, | |
"execution_count": 6, | |
"outputs": [] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment