Skip to content

Instantly share code, notes, and snippets.

@Kriyszig
Last active April 14, 2019 19:26
Show Gist options
  • Save Kriyszig/1f526570eb11da3ef1e30dd6b3934b93 to your computer and use it in GitHub Desktop.
Save Kriyszig/1f526570eb11da3ef1e30dd6b3934b93 to your computer and use it in GitHub Desktop.
CholeskyDecomposition.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "Untitled3.ipynb",
"version": "0.3.2",
"provenance": [],
"collapsed_sections": [],
"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/Kriyszig/1f526570eb11da3ef1e30dd6b3934b93/untitled3.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"metadata": {
"id": "2RzCFs4p-w1Y",
"colab_type": "code",
"colab": {}
},
"cell_type": "code",
"source": [
"import tensorflow as tf"
],
"execution_count": 0,
"outputs": []
},
{
"metadata": {
"id": "ZpmT6K3L-y9I",
"colab_type": "code",
"outputId": "a3b66a0a-58cc-456f-ea42-686cc931d8dc",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 124
}
},
"cell_type": "code",
"source": [
"sess = tf.InteractiveSession()\n",
"inp = tf.Variable([[4,12,16],[12,37,43],[-16,-43,98]])\n",
"init_op = tf.global_variables_initializer()\n",
"sess.run(init_op)\n",
"j = tf.linalg.cholesky(tf.dtypes.cast(inp, dtype=tf.float32))\n",
"print(j.eval())\n",
"print(tf.linalg.matmul(j,j, transpose_b = True).eval())\n",
"sess.close()"
],
"execution_count": 5,
"outputs": [
{
"output_type": "stream",
"text": [
"[[ 2. 0. 0.]\n",
" [ 6. 1. 0.]\n",
" [-8. 5. 3.]]\n",
"[[ 4. 12. -16.]\n",
" [ 12. 37. -43.]\n",
" [-16. -43. 98.]]\n"
],
"name": "stdout"
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment