-
-
Save kiransair/bc280bd2030f8f30feaeb733f1084168 to your computer and use it in GitHub Desktop.
Tf_forum_14747.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": { | |
"provenance": [], | |
"authorship_tag": "ABX9TyPr1Kv2L3EkMR1w4zcbePvq", | |
"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/bc280bd2030f8f30feaeb733f1084168/tf_forum_14747.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"import tensorflow as tf" | |
], | |
"metadata": { | |
"id": "N2cNtwQsXm8r" | |
}, | |
"execution_count": 64, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"import tensorflow_probability as tfp\n", | |
"tfd = tfp.distributions" | |
], | |
"metadata": { | |
"id": "QBnfHMVzRisy" | |
}, | |
"execution_count": 13, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"mlp2 = tf.keras.Sequential()\n", | |
"\n", | |
"mlp2.add(tf.keras.Input(shape=(1,)))\n", | |
"\n", | |
"mlp2.add(tf.keras.layers.Dense(20))\n", | |
"\n", | |
"mlp2.add(tf.keras.layers.Dense(20))\n", | |
"\n", | |
"mlp2.add(tf.keras.layers.Dense(1))" | |
], | |
"metadata": { | |
"id": "IgLIU9s5Rcrd" | |
}, | |
"execution_count": 43, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"mlp2.get_weights()[0].shape #1st dense layer" | |
], | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "egEW14aoS8VW", | |
"outputId": "788f7da4-58f7-4f8b-cd0e-3c11ef46ee56" | |
}, | |
"execution_count": 59, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": [ | |
"(1, 20)" | |
] | |
}, | |
"metadata": {}, | |
"execution_count": 59 | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"mlp2.get_weights()[2].shape #2nd dense layer" | |
], | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "jaI7d6MrTTEH", | |
"outputId": "26961c61-4c71-4e4e-b451-91530459cfd6" | |
}, | |
"execution_count": 60, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": [ | |
"(20, 20)" | |
] | |
}, | |
"metadata": {}, | |
"execution_count": 60 | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"mlp2.get_weights()[4].shape #3rd dense layer" | |
], | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "YK8MffxuTZvN", | |
"outputId": "d8e7f9bb-6ce4-43af-c368-706eba66dc10" | |
}, | |
"execution_count": 61, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": [ | |
"(20, 1)" | |
] | |
}, | |
"metadata": {}, | |
"execution_count": 61 | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"import numpy as np\n", | |
"a=np.array([1,])" | |
], | |
"metadata": { | |
"id": "kj72pFE4SWMG" | |
}, | |
"execution_count": 62, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"mlp2(a).ndim" | |
], | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "5ONpd4mWRylK", | |
"outputId": "c2ffea4b-2f60-45ed-da1a-9bdad99bca50" | |
}, | |
"execution_count": 63, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": [ | |
"2" | |
] | |
}, | |
"metadata": {}, | |
"execution_count": 63 | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"b=tf.random.normal((20,1))" | |
], | |
"metadata": { | |
"id": "gGqLyXeeU-D6" | |
}, | |
"execution_count": 65, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"a*b.ndim" | |
], | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "tChzOlnoZEI-", | |
"outputId": "1d3e87cf-a5b4-4556-da50-8d5ad74dba6f" | |
}, | |
"execution_count": 67, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": [ | |
"array([2])" | |
] | |
}, | |
"metadata": {}, | |
"execution_count": 67 | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [], | |
"metadata": { | |
"id": "mv29EtHBZGZJ" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment