diff --git a/example/basic/.ipynb_checkpoints/gotch_basic-checkpoint.ipynb b/example/basic/.ipynb_checkpoints/gotch_basic-checkpoint.ipynb
new file mode 100644
index 0000000..df4105b
--- /dev/null
+++ b/example/basic/.ipynb_checkpoints/gotch_basic-checkpoint.ipynb
@@ -0,0 +1,266 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 0,
+ "metadata": {
+ "accelerator": "GPU",
+ "colab": {
+ "name": "gotch-basic.ipynb",
+ "provenance": [],
+ "collapsed_sections": [
+ "fsitX3NbLbTB",
+ "l6aOKEMarRNH"
+ ],
+ "toc_visible": true,
+ "include_colab_link": true
+ },
+ "kernelspec": {
+ "display_name": "Go",
+ "name": "gophernotes"
+ }
+ },
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "view-in-github",
+ "colab_type": "text"
+ },
+ "source": [
+ "
"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "dkq9izrfMXPV"
+ },
+ "source": [
+ "# GoTch (Pytorch C++ APIs Go Binding) - Basic Tensor\n",
+ "\n",
+ "This notebook using\n",
+ "\n",
+ "1. [GoTch - Pytorch C++ APIs Go bindind](https://github.com/sugarme/gotch)\n",
+ "2. [GopherNotes - Jupyter Notebook Go kernel](https://github.com/gopherdata/gophernotes)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "fsitX3NbLbTB"
+ },
+ "source": [
+ "## Install Go kernel - GopherNotes\n",
+ "\n",
+ "*NOTE: refresh/reload (browser) after this step.*"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "id": "caT1iMfshw62",
+ "outputId": "7a00b47e-a949-4998-9dc5-bdebaab0cb8d",
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ }
+ },
+ "source": [
+ "# run this cell first time using python runtime\n",
+ "!add-apt-repository ppa:longsleep/golang-backports -y > /dev/null\n",
+ "!apt update > /dev/null \n",
+ "!apt install golang-go > /dev/null\n",
+ "%env GOPATH=/root/go\n",
+ "!go get -u github.com/gopherdata/gophernotes\n",
+ "!cp ~/go/bin/gophernotes /usr/bin/\n",
+ "!mkdir /usr/local/share/jupyter/kernels/gophernotes\n",
+ "!cp ~/go/src/github.com/gopherdata/gophernotes/kernel/* \\\n",
+ " /usr/local/share/jupyter/kernels/gophernotes\n",
+ "# then refresh (browser), it will now use gophernotes. Skip to golang in later cells"
+ ],
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "\n",
+ "WARNING: apt does not have a stable CLI interface. Use with caution in scripts.\n",
+ "\n",
+ "\n",
+ "WARNING: apt does not have a stable CLI interface. Use with caution in scripts.\n",
+ "\n",
+ "env: GOPATH=/root/go\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "l6aOKEMarRNH"
+ },
+ "source": [
+ "## Install Pytorch C++ APIs and Go binding - GoTch\n",
+ "\n",
+ "NOTE: `ldconfig` (GLIBC) current version 2.27 is currently broken when linking Libtorch library\n",
+ "\n",
+ "see issue: https://discuss.pytorch.org/libtorch-c-so-files-truncated-error-when-ldconfig/46404/6\n",
+ "\n",
+ "Google Colab default settings:\n",
+ "```bash\n",
+ "LD_LIBRARY_PATH=/usr/lib64-nvidia\n",
+ "LIBRARY_PATH=/usr/local/cuda/lib64/stubs\n",
+ "```\n",
+ "We copy directly `libtorch/lib` to those paths as a hacky way. "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "id": "0N_jGbVft2Y7",
+ "outputId": "3ba03769-5bb0-4026-f8dc-c1929f4b88f2",
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ }
+ },
+ "source": [
+ "$wget -q --show-progress --progress=bar:force:noscroll -O /tmp/libtorch-cxx11-abi-shared-with-deps-1.7.0%2Bcu101.zip https://download.pytorch.org/libtorch/cu101/libtorch-cxx11-abi-shared-with-deps-1.7.0%2Bcu101.zip\n",
+ "$unzip -qq /tmp/libtorch-cxx11-abi-shared-with-deps-1.7.0%2Bcu101.zip -d /usr/local\n",
+ "$unzip -qq -j /tmp/libtorch-cxx11-abi-shared-with-deps-1.7.0%2Bcu101.zip libtorch/lib/* -d /usr/lib64-nvidia/\n",
+ "$unzip -qq -j /tmp/libtorch-cxx11-abi-shared-with-deps-1.7.0%2Bcu101.zip libtorch/lib/* -d /usr/local/cuda/lib64/stubs/"
+ ],
+ "execution_count": 1,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "/tmp/libtorch-cxx11 99%[==================> ] 758.53M 68.1MB/s eta 0s "
+ ],
+ "name": "stderr"
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "id": "dVo3An-pGzFE"
+ },
+ "source": [
+ "import(\"os\")\n",
+ "os.Setenv(\"CPATH\", \"usr/local/libtorch/lib:/usr/local/libtorch/include:/usr/local/libtorch/include/torch/csrc/api/include\")"
+ ],
+ "execution_count": 2,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "id": "x_9y6CpZGlPJ",
+ "outputId": "465bc1e8-fcbc-44d5-cf5f-0ed8e61bc7b9",
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ }
+ },
+ "source": [
+ "$rm -f -- go.mod\n",
+ "$go mod init github.com/sugarme/playgo\n",
+ "$go get github.com/sugarme/gotch@v0.3.2"
+ ],
+ "execution_count": 3,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "go: creating new go.mod: module github.com/sugarme/playgo\n",
+ "go: downloading github.com/sugarme/gotch v0.3.2\n"
+ ],
+ "name": "stderr"
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "id": "0obqcV4KW013"
+ },
+ "source": [
+ "import(\n",
+ " \"fmt\"\n",
+ "\n",
+ " \"github.com/sugarme/gotch\"\n",
+ " ts \"github.com/sugarme/gotch/tensor\"\n",
+ ") "
+ ],
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "9fL6QTwbT7kX"
+ },
+ "source": [
+ "## Basic Tensor Operations"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "id": "YkLmNrswJHYY",
+ "outputId": "1b4c7ac8-17a3-4f66-b295-e3cd3d8ac669",
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ }
+ },
+ "source": [
+ "device := gotch.NewCuda().CudaIfAvailable()\n",
+ "ts1, err := ts.Rand([]int64{3, 4, 5}, gotch.Double, device)\n",
+ "if err != nil {fmt.Print(err)}\n",
+ "ts2, err := ts.Ones([]int64{5, 3}, gotch.Double, device)\n",
+ "if err != nil { fmt.Print(err)}\n",
+ "\n",
+ "mul, err := ts1.Matmul(ts2, false)\n",
+ "if err != nil { fmt.Print(err)}\n",
+ "fmt.Printf(\"%.3f\", mul)"
+ ],
+ "execution_count": 4,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "(1,.,.) =\n",
+ "1.372 1.372 1.372 \n",
+ "2.774 2.774 2.774 \n",
+ "4.150 4.150 4.150 \n",
+ "2.442 2.442 2.442 \n",
+ "\n",
+ "(2,.,.) =\n",
+ "1.935 1.935 1.935 \n",
+ "2.622 2.622 2.622 \n",
+ "2.797 2.797 2.797 \n",
+ "2.602 2.602 2.602 \n",
+ "\n",
+ "(3,.,.) =\n",
+ "2.419 2.419 2.419 \n",
+ "1.901 1.901 1.901 \n",
+ "2.795 2.795 2.795 \n",
+ "2.387 2.387 2.387 \n",
+ "\n"
+ ],
+ "name": "stdout"
+ },
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "297 "
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 4
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/example/basic/gotch_basic.ipynb b/example/basic/gotch_basic.ipynb
index df4105b..fa5ce93 100644
--- a/example/basic/gotch_basic.ipynb
+++ b/example/basic/gotch_basic.ipynb
@@ -1,266 +1,276 @@
{
- "nbformat": 4,
- "nbformat_minor": 0,
- "metadata": {
- "accelerator": "GPU",
- "colab": {
- "name": "gotch-basic.ipynb",
- "provenance": [],
- "collapsed_sections": [
- "fsitX3NbLbTB",
- "l6aOKEMarRNH"
- ],
- "toc_visible": true,
- "include_colab_link": true
- },
- "kernelspec": {
- "display_name": "Go",
- "name": "gophernotes"
- }
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "colab_type": "text",
+ "id": "view-in-github"
+ },
+ "source": [
+ "
"
+ ]
},
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {
- "id": "view-in-github",
- "colab_type": "text"
- },
- "source": [
- "
"
- ]
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "dkq9izrfMXPV"
+ },
+ "source": [
+ "# GoTch (Pytorch C++ APIs Go Binding) - Basic Tensor\n",
+ "\n",
+ "This notebook using\n",
+ "\n",
+ "1. [GoTch - Pytorch C++ APIs Go bindind](https://github.com/sugarme/gotch)\n",
+ "2. [GopherNotes - Jupyter Notebook Go kernel](https://github.com/gopherdata/gophernotes)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "fsitX3NbLbTB"
+ },
+ "source": [
+ "## Install Go kernel - GopherNotes\n",
+ "\n",
+ "*NOTE: refresh/reload (browser) after this step.*"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
},
+ "id": "caT1iMfshw62",
+ "outputId": "7a00b47e-a949-4998-9dc5-bdebaab0cb8d"
+ },
+ "outputs": [
{
- "cell_type": "markdown",
- "metadata": {
- "id": "dkq9izrfMXPV"
- },
- "source": [
- "# GoTch (Pytorch C++ APIs Go Binding) - Basic Tensor\n",
- "\n",
- "This notebook using\n",
- "\n",
- "1. [GoTch - Pytorch C++ APIs Go bindind](https://github.com/sugarme/gotch)\n",
- "2. [GopherNotes - Jupyter Notebook Go kernel](https://github.com/gopherdata/gophernotes)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "id": "fsitX3NbLbTB"
- },
- "source": [
- "## Install Go kernel - GopherNotes\n",
- "\n",
- "*NOTE: refresh/reload (browser) after this step.*"
- ]
- },
- {
- "cell_type": "code",
- "metadata": {
- "id": "caT1iMfshw62",
- "outputId": "7a00b47e-a949-4998-9dc5-bdebaab0cb8d",
- "colab": {
- "base_uri": "https://localhost:8080/"
- }
- },
- "source": [
- "# run this cell first time using python runtime\n",
- "!add-apt-repository ppa:longsleep/golang-backports -y > /dev/null\n",
- "!apt update > /dev/null \n",
- "!apt install golang-go > /dev/null\n",
- "%env GOPATH=/root/go\n",
- "!go get -u github.com/gopherdata/gophernotes\n",
- "!cp ~/go/bin/gophernotes /usr/bin/\n",
- "!mkdir /usr/local/share/jupyter/kernels/gophernotes\n",
- "!cp ~/go/src/github.com/gopherdata/gophernotes/kernel/* \\\n",
- " /usr/local/share/jupyter/kernels/gophernotes\n",
- "# then refresh (browser), it will now use gophernotes. Skip to golang in later cells"
- ],
- "execution_count": null,
- "outputs": [
- {
- "output_type": "stream",
- "text": [
- "\n",
- "WARNING: apt does not have a stable CLI interface. Use with caution in scripts.\n",
- "\n",
- "\n",
- "WARNING: apt does not have a stable CLI interface. Use with caution in scripts.\n",
- "\n",
- "env: GOPATH=/root/go\n"
- ],
- "name": "stdout"
- }
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "id": "l6aOKEMarRNH"
- },
- "source": [
- "## Install Pytorch C++ APIs and Go binding - GoTch\n",
- "\n",
- "NOTE: `ldconfig` (GLIBC) current version 2.27 is currently broken when linking Libtorch library\n",
- "\n",
- "see issue: https://discuss.pytorch.org/libtorch-c-so-files-truncated-error-when-ldconfig/46404/6\n",
- "\n",
- "Google Colab default settings:\n",
- "```bash\n",
- "LD_LIBRARY_PATH=/usr/lib64-nvidia\n",
- "LIBRARY_PATH=/usr/local/cuda/lib64/stubs\n",
- "```\n",
- "We copy directly `libtorch/lib` to those paths as a hacky way. "
- ]
- },
- {
- "cell_type": "code",
- "metadata": {
- "id": "0N_jGbVft2Y7",
- "outputId": "3ba03769-5bb0-4026-f8dc-c1929f4b88f2",
- "colab": {
- "base_uri": "https://localhost:8080/"
- }
- },
- "source": [
- "$wget -q --show-progress --progress=bar:force:noscroll -O /tmp/libtorch-cxx11-abi-shared-with-deps-1.7.0%2Bcu101.zip https://download.pytorch.org/libtorch/cu101/libtorch-cxx11-abi-shared-with-deps-1.7.0%2Bcu101.zip\n",
- "$unzip -qq /tmp/libtorch-cxx11-abi-shared-with-deps-1.7.0%2Bcu101.zip -d /usr/local\n",
- "$unzip -qq -j /tmp/libtorch-cxx11-abi-shared-with-deps-1.7.0%2Bcu101.zip libtorch/lib/* -d /usr/lib64-nvidia/\n",
- "$unzip -qq -j /tmp/libtorch-cxx11-abi-shared-with-deps-1.7.0%2Bcu101.zip libtorch/lib/* -d /usr/local/cuda/lib64/stubs/"
- ],
- "execution_count": 1,
- "outputs": [
- {
- "output_type": "stream",
- "text": [
- "/tmp/libtorch-cxx11 99%[==================> ] 758.53M 68.1MB/s eta 0s "
- ],
- "name": "stderr"
- }
- ]
- },
- {
- "cell_type": "code",
- "metadata": {
- "id": "dVo3An-pGzFE"
- },
- "source": [
- "import(\"os\")\n",
- "os.Setenv(\"CPATH\", \"usr/local/libtorch/lib:/usr/local/libtorch/include:/usr/local/libtorch/include/torch/csrc/api/include\")"
- ],
- "execution_count": 2,
- "outputs": []
- },
- {
- "cell_type": "code",
- "metadata": {
- "id": "x_9y6CpZGlPJ",
- "outputId": "465bc1e8-fcbc-44d5-cf5f-0ed8e61bc7b9",
- "colab": {
- "base_uri": "https://localhost:8080/"
- }
- },
- "source": [
- "$rm -f -- go.mod\n",
- "$go mod init github.com/sugarme/playgo\n",
- "$go get github.com/sugarme/gotch@v0.3.2"
- ],
- "execution_count": 3,
- "outputs": [
- {
- "output_type": "stream",
- "text": [
- "go: creating new go.mod: module github.com/sugarme/playgo\n",
- "go: downloading github.com/sugarme/gotch v0.3.2\n"
- ],
- "name": "stderr"
- }
- ]
- },
- {
- "cell_type": "code",
- "metadata": {
- "id": "0obqcV4KW013"
- },
- "source": [
- "import(\n",
- " \"fmt\"\n",
- "\n",
- " \"github.com/sugarme/gotch\"\n",
- " ts \"github.com/sugarme/gotch/tensor\"\n",
- ") "
- ],
- "execution_count": null,
- "outputs": []
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "id": "9fL6QTwbT7kX"
- },
- "source": [
- "## Basic Tensor Operations"
- ]
- },
- {
- "cell_type": "code",
- "metadata": {
- "id": "YkLmNrswJHYY",
- "outputId": "1b4c7ac8-17a3-4f66-b295-e3cd3d8ac669",
- "colab": {
- "base_uri": "https://localhost:8080/"
- }
- },
- "source": [
- "device := gotch.NewCuda().CudaIfAvailable()\n",
- "ts1, err := ts.Rand([]int64{3, 4, 5}, gotch.Double, device)\n",
- "if err != nil {fmt.Print(err)}\n",
- "ts2, err := ts.Ones([]int64{5, 3}, gotch.Double, device)\n",
- "if err != nil { fmt.Print(err)}\n",
- "\n",
- "mul, err := ts1.Matmul(ts2, false)\n",
- "if err != nil { fmt.Print(err)}\n",
- "fmt.Printf(\"%.3f\", mul)"
- ],
- "execution_count": 4,
- "outputs": [
- {
- "output_type": "stream",
- "text": [
- "(1,.,.) =\n",
- "1.372 1.372 1.372 \n",
- "2.774 2.774 2.774 \n",
- "4.150 4.150 4.150 \n",
- "2.442 2.442 2.442 \n",
- "\n",
- "(2,.,.) =\n",
- "1.935 1.935 1.935 \n",
- "2.622 2.622 2.622 \n",
- "2.797 2.797 2.797 \n",
- "2.602 2.602 2.602 \n",
- "\n",
- "(3,.,.) =\n",
- "2.419 2.419 2.419 \n",
- "1.901 1.901 1.901 \n",
- "2.795 2.795 2.795 \n",
- "2.387 2.387 2.387 \n",
- "\n"
- ],
- "name": "stdout"
- },
- {
- "output_type": "execute_result",
- "data": {
- "text/plain": [
- "297 "
- ]
- },
- "metadata": {
- "tags": []
- },
- "execution_count": 4
- }
- ]
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n",
+ "WARNING: apt does not have a stable CLI interface. Use with caution in scripts.\n",
+ "\n",
+ "\n",
+ "WARNING: apt does not have a stable CLI interface. Use with caution in scripts.\n",
+ "\n",
+ "env: GOPATH=/root/go\n"
+ ]
}
- ]
-}
\ No newline at end of file
+ ],
+ "source": [
+ "# run this cell first time using python runtime\n",
+ "!add-apt-repository ppa:longsleep/golang-backports -y > /dev/null\n",
+ "!apt update > /dev/null \n",
+ "!apt install golang-go > /dev/null\n",
+ "%env GOPATH=/root/go\n",
+ "!go get -u github.com/gopherdata/gophernotes\n",
+ "!cp ~/go/bin/gophernotes /usr/bin/\n",
+ "!mkdir /usr/local/share/jupyter/kernels/gophernotes\n",
+ "!cp ~/go/src/github.com/gopherdata/gophernotes/kernel/* \\\n",
+ " /usr/local/share/jupyter/kernels/gophernotes\n",
+ "# then refresh (browser), it will now use gophernotes. Skip to golang in later cells"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "l6aOKEMarRNH"
+ },
+ "source": [
+ "## Install Pytorch C++ APIs and Go binding - GoTch\n",
+ "\n",
+ "NOTE: `ldconfig` (GLIBC) current version 2.27 is currently broken when linking Libtorch library\n",
+ "\n",
+ "see issue: https://discuss.pytorch.org/libtorch-c-so-files-truncated-error-when-ldconfig/46404/6\n",
+ "\n",
+ "Google Colab default settings:\n",
+ "```bash\n",
+ "LD_LIBRARY_PATH=/usr/lib64-nvidia\n",
+ "LIBRARY_PATH=/usr/local/cuda/lib64/stubs\n",
+ "```\n",
+ "We copy directly `libtorch/lib` to those paths as a hacky way. "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "0N_jGbVft2Y7",
+ "outputId": "3ba03769-5bb0-4026-f8dc-c1929f4b88f2"
+ },
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "/tmp/libtorch-cxx11 99%[==================> ] 758.53M 68.1MB/s eta 0s "
+ ]
+ }
+ ],
+ "source": [
+ "$wget -q --show-progress --progress=bar:force:noscroll -O /tmp/libtorch-cxx11-abi-shared-with-deps-1.7.0%2Bcu101.zip https://download.pytorch.org/libtorch/cu101/libtorch-cxx11-abi-shared-with-deps-1.7.0%2Bcu101.zip\n",
+ "$unzip -qq /tmp/libtorch-cxx11-abi-shared-with-deps-1.7.0%2Bcu101.zip -d /usr/local\n",
+ "$unzip -qq -j /tmp/libtorch-cxx11-abi-shared-with-deps-1.7.0%2Bcu101.zip libtorch/lib/* -d /usr/lib64-nvidia/\n",
+ "$unzip -qq -j /tmp/libtorch-cxx11-abi-shared-with-deps-1.7.0%2Bcu101.zip libtorch/lib/* -d /usr/local/cuda/lib64/stubs/"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "id": "dVo3An-pGzFE"
+ },
+ "outputs": [],
+ "source": [
+ "import(\"os\")\n",
+ "os.Setenv(\"CPATH\", \"usr/local/libtorch/lib:/usr/local/libtorch/include:/usr/local/libtorch/include/torch/csrc/api/include\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "x_9y6CpZGlPJ",
+ "outputId": "465bc1e8-fcbc-44d5-cf5f-0ed8e61bc7b9"
+ },
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "go: creating new go.mod: module github.com/sugarme/playgo\n",
+ "go: downloading github.com/sugarme/gotch v0.3.2\n"
+ ]
+ }
+ ],
+ "source": [
+ "$rm -f -- go.mod\n",
+ "$go mod init github.com/sugarme/playgo\n",
+ "$go get github.com/sugarme/gotch@v0.3.2"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "id": "0obqcV4KW013"
+ },
+ "outputs": [],
+ "source": [
+ "import(\n",
+ " \"fmt\"\n",
+ "\n",
+ " \"github.com/sugarme/gotch\"\n",
+ " ts \"github.com/sugarme/gotch/tensor\"\n",
+ ") "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "9fL6QTwbT7kX"
+ },
+ "source": [
+ "## Basic Tensor Operations"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "YkLmNrswJHYY",
+ "outputId": "1b4c7ac8-17a3-4f66-b295-e3cd3d8ac669"
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "(1,.,.) =\n",
+ "1.372 1.372 1.372 \n",
+ "2.774 2.774 2.774 \n",
+ "4.150 4.150 4.150 \n",
+ "2.442 2.442 2.442 \n",
+ "\n",
+ "(2,.,.) =\n",
+ "1.935 1.935 1.935 \n",
+ "2.622 2.622 2.622 \n",
+ "2.797 2.797 2.797 \n",
+ "2.602 2.602 2.602 \n",
+ "\n",
+ "(3,.,.) =\n",
+ "2.419 2.419 2.419 \n",
+ "1.901 1.901 1.901 \n",
+ "2.795 2.795 2.795 \n",
+ "2.387 2.387 2.387 \n",
+ "\n"
+ ]
+ },
+ {
+ "data": {
+ "text/plain": [
+ "297 "
+ ]
+ },
+ "execution_count": 4,
+ "metadata": {
+ "tags": []
+ },
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "device := gotch.NewCuda().CudaIfAvailable()\n",
+ "ts1, err := ts.Rand([]int64{3, 4, 5}, gotch.Double, device)\n",
+ "if err != nil {fmt.Print(err)}\n",
+ "ts2, err := ts.Ones([]int64{5, 3}, gotch.Double, device)\n",
+ "if err != nil { fmt.Print(err)}\n",
+ "\n",
+ "mul, err := ts1.Matmul(ts2, false)\n",
+ "if err != nil { fmt.Print(err)}\n",
+ "fmt.Printf(\"%.3f\", mul)"
+ ]
+ }
+ ],
+ "metadata": {
+ "accelerator": "GPU",
+ "colab": {
+ "collapsed_sections": [
+ "fsitX3NbLbTB",
+ "l6aOKEMarRNH"
+ ],
+ "include_colab_link": true,
+ "name": "gotch-basic.ipynb",
+ "provenance": [],
+ "toc_visible": true
+ },
+ "kernelspec": {
+ "display_name": "Go",
+ "language": "go",
+ "name": "gophernotes"
+ },
+ "language_info": {
+ "codemirror_mode": "",
+ "file_extension": ".go",
+ "mimetype": "",
+ "name": "go",
+ "nbconvert_exporter": "",
+ "pygments_lexer": "",
+ "version": "go1.14.3"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}
diff --git a/example/yolo/gotch_yolo.ipynb b/example/yolo/.ipynb_checkpoints/gotch_yolo-checkpoint.ipynb
similarity index 100%
rename from example/yolo/gotch_yolo.ipynb
rename to example/yolo/.ipynb_checkpoints/gotch_yolo-checkpoint.ipynb
diff --git a/example/yolo/README.md b/example/yolo/README.md
index be4292d..6d6e9cc 100644
--- a/example/yolo/README.md
+++ b/example/yolo/README.md
@@ -14,3 +14,6 @@ Here is an example of image inference using Yolo v3 model.
![Bondi Beach - Yolo inference](yolo_bondi.jpg "Bondi Beach - YOLO v3")
+
+![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)