@Rayanfer32/

TensorFlow basics

No description

Files
• main.py
main.py
```1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
```
```import tensorflow as tf

# hello_constant = tf.constant('Hello World!')

# with tf.Session() as sess:
#   output = sess.run(hello_constant)
#   print(output)

################################################

# x = tf.Variable(5)

# init = tf.global_variables_initializer()
# with tf.Session() as sess:
#   sess.run(init)

# tf.truncated_normal() # generate random numbers from normal dist

# import numpy as np

# def softmax(x):
#   """
#   Compute softmax values for each sets of scores in x.
#   """

# logits = [3., 1., 0.2]
# print(softmax(logits))

# tf.reduce_sum([1,2,3,4]) # 10
# tf.log()  # natural log

def normalize_grayscale(image_data):
"""
Normalize the image data with Min-Max scaling to a range of [0.1, 0.9]
:param image_data: The image data to be normalized
:return: Normalized image data
"""
# TODO: Implement Min-Max scaling for grayscale image data
a = 0.1
b = 0.9
grayscale_min = 0
grayscale_max = 255

return a + (( (image_data - grayscale_min) * (b - a)) / (grayscale_max - grayscale_min) )

##### HOW TO START A REPO USING jupyter ######
# Clone the LeNet Lab repo: git clone https://github.com/udacity/CarND-LeNet-Lab.git
# Enter the repo directory: cd CarND-LeNet-Lab
# Activate the new environment: source activate carnd-term1
# Run the notebook: jupyter notebook LeNet-Lab-Solution.ipynb

##### HOW TO SAVE VARIABLES ######

import tensorflow as tf

save_file = "./model.ckpt"

weights = tf.Variable(tf.truncated_normal([2, 3]))
bias = tf.Variable(tf.truncated_normal([3]))

# save your TF model with:
saver = tf.train.Saver()

with tf.Session() as sess:
sess.run(tf.global_variables_initializer())

print('Weights:')
print(sess.run(weights))
print('Bias:')
print(sess.run(bias))

saver.save(sess, save_file)

tf.Variable(tf.truncated_normal([6,1]))

```