Skip to content

Instantly share code, notes, and snippets.

@YasuThompson
Created February 18, 2021 10:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YasuThompson/37cff418031b63bd970643c3a932ffd0 to your computer and use it in GitHub Desktop.
Save YasuThompson/37cff418031b63bd970643c3a932ffd0 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"tf.Tensor(\n",
"[[[ 1 2 3 ... 510 511 512]\n",
" [ 513 514 515 ... 1022 1023 1024]\n",
" [1025 1026 1027 ... 1534 1535 1536]\n",
" ...\n",
" [3073 3074 3075 ... 3582 3583 3584]\n",
" [3585 3586 3587 ... 4094 4095 4096]\n",
" [4097 4098 4099 ... 4606 4607 4608]]], shape=(1, 9, 512), dtype=int64)\n"
]
}
],
"source": [
"# Let's take a sample sentence as an example. \n",
"# As you can see in the output below, 'sample_sentence' is virutally a (9, 64) sized \n",
"# matirix, whose elements are simple sequential integers. \n",
"# *The first axis denotes the index of bathes. In this example the batch size is 1.\n",
"\n",
"sample_sentence = np.arange(1*9*512).reshape((1, 9, 512)) + 1\n",
"sample_sentence = tf.convert_to_tensor(sample_sentence)\n",
"print(sample_sentence)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.9"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment