Add-Method

Sat 17 May 2025

title: "Add Method" author: "Raja CSP Raman" date: 2019-05-07 description: "-" type: technical_note draft: false


import tensorflow as tf

import os

# Just disables the warning, doesn't enable AVX/FMA
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
a = tf.Variable(0)
b = tf.constant(1)
c = tf.add(a, b)
c
<tf.Tensor 'Add_2:0' shape=() dtype=int32>
# assign the new value to a
update = tf.assign(a, c)
a
<tf.Variable 'Variable_4:0' shape=() dtype=int32_ref>
# You can't change the constant by using assign. 
# Initialize global variables

init_op = tf.global_variables_initializer()
session = tf.Session()
session.run(init_op)
print(session.run(a))
0
session.run(update)
1
session.run(a)
1
for _ in range(4):
    session.run(update)
    print(session.run(a))
2
3
4
5
session.close()


Score: 15

Category: tensorflow-work


Census-Data

Sat 17 May 2025

title: "Census Data and Linear Classifier" author: "Raja CSP Raman" date: 2019-05-07 description: "-" type: technical_note draft: false


import tensorflow as tf

import os

# Just disables the warning, doesn't enable AVX/FMA
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
import numpy as np
import pandas as pd
census = pd.read_csv("/Users/rajacsp/datasets …

Category: tensorflow-work

Read More

Eager Execution In Tensorflow

Sat 17 May 2025

title: "Eager Execution in Tensorflow" author: "Raja CSP Raman" date: 2019-05-07 description: "-" type: technical_note draft: false


import tensorflow as tf

import os

# Just disables the warning, doesn't enable AVX/FMA
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
tf.enable_eager_execution()
a = tf.constant([1.0, 2.0])
a
<tf.Tensor: id=3, shape …

Category: tensorflow-work

Read More

Feed Dictionary

Sat 17 May 2025

title: "Feed Dictionary" author: "Raja CSP Raman" date: 2019-05-07 description: "-" type: technical_note draft: false


import tensorflow as tf
import os

# Just disables the warning, doesn't enable AVX/FMA
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
a = tf.placeholder(tf.float32)
b = tf.placeholder(tf.float32)
c = tf.multiply(a, b)

with tf …

Category: tensorflow-work

Read More

Fetching-Variable-State

Sat 17 May 2025

title: "Template" author: "Raja CSP Raman" date: 2019-05-07 description: "-" type: technical_note draft: false


import tensorflow as tf

import os

# Just disables the warning, doesn't enable AVX/FMA
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
a = tf.constant(2)
b = tf.constant(3)

c = tf.add(a, b)
d = tf.multiply(a, b …

Category: tensorflow-work

Read More

Graph

Sat 17 May 2025

title: "Graph" author: "Raja CSP Raman" date: 2019-05-07 description: "-" type: technical_note draft: false


import tensorflow as tf

import os

# Just disables the warning, doesn't enable AVX/FMA
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
graph = tf.get_default_graph()
graph.get_operations()
[]
a = tf.constant(2, name = "one")
operations = graph.get_operations()

operations

b = tf.constant …

Category: tensorflow-work

Read More

Intialize-Variables

Sat 17 May 2025

title: "Initialize Variables" author: "Raja CSP Raman" date: 2019-05-07 description: "-" type: technical_note draft: false


import tensorflow as tf

import os

# Just disables the warning, doesn't enable AVX/FMA
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
init_op = tf.global_variables_initializer()
session = tf.Session()
# initialize variables
session.run(init_op)

Score: 5

Category: tensorflow-work

Read More

Name Scope

Sat 17 May 2025

title: "Name Scope" author: "Raja CSP Raman" date: 2019-05-07 description: "-" type: technical_note draft: false


import tensorflow as tf

import os

# Just disables the warning, doesn't enable AVX/FMA
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
# to clear the graph before new nodes
tf.reset_default_graph()

with tf.name_scope("march"):
    a = tf.constant(1 …

Category: tensorflow-work

Read More

Numpy-2-Tensor

Sat 17 May 2025

title: "Numpy 2 Tensor" author: "Raja CSP Raman" date: 2019-05-07 description: "-" type: technical_note draft: false


import tensorflow as tf
import numpy as np
import os

# Just disables the warning, doesn't enable AVX/FMA
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
a = np.zeros((3, 3))
ta = tf.convert_to_tensor(a)

with tf.Session …

Category: tensorflow-work

Read More

Numpy Multiplication In Tensorflow

Sat 17 May 2025

title: "Numpy Multplication in Tensorflow" author: "Raja CSP Raman" date: 2019-05-07 description: "-" type: technical_note draft: false


import tensorflow as tf

import os

# Just disables the warning, doesn't enable AVX/FMA
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
matrix1 = tf.constant([[3., 3.0]])
matrix2 = tf.constant([[2.0],[2.0]])
product = tf …

Category: tensorflow-work

Read More
Page 1 of 3

Next »