Skip to content

Instantly share code, notes, and snippets.

@dsaint31x
Created September 1, 2022 05:00
Show Gist options
  • Save dsaint31x/834f8b24f6fc93b06fc3c78f12f6f6e8 to your computer and use it in GitHub Desktop.
Save dsaint31x/834f8b24f6fc93b06fc3c78f12f6f6e8 to your computer and use it in GitHub Desktop.
LA_Ch01_03_Ex01.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"authorship_tag": "ABX9TyPcHk+F0TNME5hHaJRpydCw",
"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/dsaint31x/834f8b24f6fc93b06fc3c78f12f6f6e8/la_ch01_03_ex01.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\n",
"import numpy as np\n",
"\n",
"u = np.array([1,-2], dtype=float)\n",
"v = np.array([2,-5], dtype=float)\n",
"\n",
"u = tf.constant(u, shape=(2,1))\n",
"v = tf.constant(v, shape=(2,1))\n"
],
"metadata": {
"id": "GbFdaz0pZ3jy"
},
"execution_count": 39,
"outputs": []
},
{
"cell_type": "code",
"source": [
"4*u"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "d5Y2NlxfaXfh",
"outputId": "f3fde1b7-b5a1-4ac9-9d3b-5b038c374799"
},
"execution_count": 40,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"<tf.Tensor: shape=(2, 1), dtype=float64, numpy=\n",
"array([[ 4.],\n",
" [-8.]])>"
]
},
"metadata": {},
"execution_count": 40
}
]
},
{
"cell_type": "code",
"source": [
"-3*v"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "8uKECsAKaYjn",
"outputId": "d1f4a47e-20a2-45cb-f434-4ad99af39401"
},
"execution_count": 41,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"<tf.Tensor: shape=(2, 1), dtype=float64, numpy=\n",
"array([[-6.],\n",
" [15.]])>"
]
},
"metadata": {},
"execution_count": 41
}
]
},
{
"cell_type": "code",
"source": [
"4*u-3*v"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "Nh7Xuh0XaaUv",
"outputId": "9cb3f2b4-d7a3-426d-a7b6-1ab6526f28ac"
},
"execution_count": 42,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"<tf.Tensor: shape=(2, 1), dtype=float64, numpy=\n",
"array([[-2.],\n",
" [ 7.]])>"
]
},
"metadata": {},
"execution_count": 42
}
]
}
]
}
@dsaint31x
Copy link
Author

.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment