Posts
Paraboloid_Function_Optimization
#import required packages from IPython.display import Image import numpy as np import plotly.plotly as py import plotly.graph_objs as go url_eqn = 'https://wikimedia.org/api/rest_v1/media/math/render/svg/9fe43b236cfd731febae18c507782b7d33ac33e5' url_img = 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/72/Max_paraboloid.svg/700px-Max_paraboloid.svg.png' Image(url=url_img) $$f(x,y) = -(x^2 + y^2) + 4$$
def paraboloid(x,y): return -(x**2 + y**2) + 4 s = np.linspace(-10,10, 240) t = np.linspace(-10,10, 240) tGrid, sGrid = np.meshgrid(s, t) x = tGrid y = sGrid z = paraboloid(x,y) def plot_3dfunc(x,y,z, filename, title = None): surface = go.
Posts
MNIST using GPU: Tesla K80 on ColabResearch
MNIST using GPU: Tesla K80 on ColabResearch
import required packages
import tensorflow as tf sess = tf.InteractiveSession() from tensorflow.python.client import device_lib Check the devices: using> device_lib.list_local_devices()
NOte: In order to make use of GPU: Runtime> Change runtime type> select GPU in Hardware Accelerator
device_lib.list_local_devices() [name: "/device:CPU:0" device_type: "CPU" memory_limit: 268435456 locality { } incarnation: 10739214734195363675, name: "/device:GPU:0" device_type: "GPU" memory_limit: 358350848 locality { bus_id: 1 } incarnation: 6782277748504694444 physical_device_desc: "device: 0, name: Tesla K80, pci bus id: 0000:00:04.
Posts
Visualizing Tensorflow Graphs
Using a local TensorBoard instance to visualize the graph import tensorflow as tf Using a cloud-hosted TensorBoard instance to do the rendering # TensorFlow Graph visualizer code import numpy as np from IPython.display import clear_output, Image, display, HTML def strip_consts(graph_def, max_const_size=32): """Strip large constant values from graph_def.""" strip_def = tf.GraphDef() for n0 in graph_def.node: n = strip_def.node.add() n.MergeFrom(n0) if n.op == 'Const': tensor = n.attr['value'].tensor size = len(tensor.tensor_content) if size > max_const_size: tensor.
Posts
Get set go with Tensorflow
Pip installation !pip install tensorflow!pip install tensorflow-gpu Anaconda Installation !conda install -c conda-forge tensorflow!conda install -c anaconda tensorflow-gpu Basic Usage 1. Building the graph import tensorflow as tf matrix1 = tf.constant([[3., 3.]]) matrix2 = tf.constant([[2.],[2.]]) print(matrix1, matrix2) product = tf.matmul(matrix2, matrix1) Tensor("Const_4:0", shape=(1, 2), dtype=float32) Tensor("Const_5:0", shape=(2, 1), dtype=float32) 2.Launching the graph in a session Method 1 # Launch the default graph. sess = tf.Session() result = sess.