machinelearning

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 19bb5815d434a968cf3bca532b9edaeca64ae50d
parent b98d5a0c98bae5873b5ac1c5c90b78ad1bee6de2
Author: Andrew <andrewlaack1@gmail.com>
Date:   Mon, 24 Jun 2024 21:13:41 -0500

Did diagramming and some stuff

Diffstat:
AdataViz/Diagram1.ipynb | 100+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AdataViz/Diagram2.dot | 6++++++
AdataViz/Diagram3.dot | 6++++++
Atensors/TensorsWithTF.ipynb | 240+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 352 insertions(+), 0 deletions(-)

diff --git a/dataViz/Diagram1.ipynb b/dataViz/Diagram1.ipynb @@ -0,0 +1,100 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n", + "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n", + " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n", + "<!-- Generated by graphviz version 2.43.0 (0)\n", + " -->\n", + "<!-- Title: %3 Pages: 1 -->\n", + "<svg width=\"134pt\" height=\"116pt\"\n", + " viewBox=\"0.00 0.00 134.00 116.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n", + "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 112)\">\n", + "<title>%3</title>\n", + "<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-112 130,-112 130,4 -4,4\"/>\n", + "<!-- A -->\n", + "<g id=\"node1\" class=\"node\">\n", + "<title>A</title>\n", + "<ellipse fill=\"none\" stroke=\"black\" cx=\"63\" cy=\"-90\" rx=\"27\" ry=\"18\"/>\n", + "<text text-anchor=\"middle\" x=\"63\" y=\"-86.3\" font-family=\"Times,serif\" font-size=\"14.00\">A</text>\n", + "</g>\n", + "<!-- B -->\n", + "<g id=\"node2\" class=\"node\">\n", + "<title>B</title>\n", + "<ellipse fill=\"none\" stroke=\"black\" cx=\"27\" cy=\"-18\" rx=\"27\" ry=\"18\"/>\n", + "<text text-anchor=\"middle\" x=\"27\" y=\"-14.3\" font-family=\"Times,serif\" font-size=\"14.00\">B</text>\n", + "</g>\n", + "<!-- A&#45;&gt;B -->\n", + "<g id=\"edge2\" class=\"edge\">\n", + "<title>A&#45;&gt;B</title>\n", + "<path fill=\"none\" stroke=\"black\" d=\"M54.65,-72.76C50.29,-64.28 44.85,-53.71 39.96,-44.2\"/>\n", + "<polygon fill=\"black\" stroke=\"black\" points=\"42.99,-42.44 35.3,-35.15 36.77,-45.64 42.99,-42.44\"/>\n", + "</g>\n", + "<!-- C -->\n", + "<g id=\"node3\" class=\"node\">\n", + "<title>C</title>\n", + "<ellipse fill=\"none\" stroke=\"black\" cx=\"99\" cy=\"-18\" rx=\"27\" ry=\"18\"/>\n", + "<text text-anchor=\"middle\" x=\"99\" y=\"-14.3\" font-family=\"Times,serif\" font-size=\"14.00\">C</text>\n", + "</g>\n", + "<!-- A&#45;&gt;C -->\n", + "<g id=\"edge1\" class=\"edge\">\n", + "<title>A&#45;&gt;C</title>\n", + "<path fill=\"none\" stroke=\"black\" d=\"M71.35,-72.76C75.71,-64.28 81.15,-53.71 86.04,-44.2\"/>\n", + "<polygon fill=\"black\" stroke=\"black\" points=\"89.23,-45.64 90.7,-35.15 83.01,-42.44 89.23,-45.64\"/>\n", + "</g>\n", + "</g>\n", + "</svg>\n" + ], + "text/plain": [ + "<graphviz.graphs.Digraph at 0x7f4bcbd3e450>" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from graphviz import Digraph\n", + "\n", + "dot = Digraph()\n", + "\n", + "dot.node('A')\n", + "dot.node('B')\n", + "dot.node('C')\n", + "dot.edge('A' , 'C')\n", + "dot.edge('A' , 'B')\n", + "\n", + "dot" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".venv", + "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.11.2" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/dataViz/Diagram2.dot b/dataViz/Diagram2.dot @@ -0,0 +1,5 @@ +digraph MyGraph { + Begin [style=filled, fillcolor=yellow] + Begin -> End [dir=both] + +}+ \ No newline at end of file diff --git a/dataViz/Diagram3.dot b/dataViz/Diagram3.dot @@ -0,0 +1,5 @@ +digraph IntegrationGraph{ + "Control M" -> "OS Prod" [label="1 : Request Data"] + "OS Prod" -> "Control M" [label="2 : Return Data"] + "Control M" -> "OS Dev" [label="3: Send Data to Dev"] +}+ \ No newline at end of file diff --git a/tensors/TensorsWithTF.ipynb b/tensors/TensorsWithTF.ipynb @@ -0,0 +1,240 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "<tf.Tensor: shape=(2, 2), dtype=float32, numpy=\n", + "array([[1., 2.],\n", + " [4., 5.]], dtype=float32)>" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import tensorflow as tf\n", + "\n", + "t = tf.constant([[1.,2.], [4.,5]])\n", + "t" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(TensorShape([2, 2]), tf.float32)" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "t.shape, t.dtype" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "<tf.Tensor: shape=(2, 2), dtype=float32, numpy=\n", + "array([[1., 4.],\n", + " [2., 5.]], dtype=float32)>" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "tf.transpose(t)" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "<tf.Tensor: shape=(2, 2), dtype=float32, numpy=\n", + "array([[ 5., 14.],\n", + " [14., 41.]], dtype=float32)>" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "t @ tf.transpose(t)" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "<tf.Tensor: shape=(2, 2), dtype=float32, numpy=\n", + "array([[-1.6666667 , 0.6666667 ],\n", + " [ 1.3333334 , -0.33333334]], dtype=float32)>" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "tf.linalg.inv(t)" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "<tf.Tensor: shape=(), dtype=float32, numpy=12.0>" + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "tf.reduce_sum(t)" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "<tf.Tensor: shape=(2,), dtype=float64, numpy=array([2., 4.])>" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import numpy as np\n", + "a = np.array([2.,4.])\n", + "tf.constant(a)" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[1., 2.],\n", + " [4., 5.]], dtype=float32)" + ] + }, + "execution_count": 29, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "t.numpy()" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "<tf.Tensor: shape=(2,), dtype=float64, numpy=array([ 4., 16.])>" + ] + }, + "execution_count": 30, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "tf.square(a)" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[ 1., 4.],\n", + " [16., 25.]], dtype=float32)" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "np.square(t)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".venv", + "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.11.2" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}