import tensorflow as tf
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn import datasets
import requests
#iris = datasets.load_iris()
#print(len(iris.data))
#print(len(iris.target))
birthdata_url = 'https://www.umass.edu/statdata/statdata/data/lowbwt.dat'
birthfile = requests.get(birthdata_url)
birth_data = birthfile.text.split('\'r\n') [5:]
zero = tf.zeros([5,5])
filled_tsr = tf.fill([5,5],100)
constant_tsr = tf.constant(10.0,tf.float32,shape= [5,5,5])
M = tf.zeros_like(constant_tsr)
my_val = tf.Variable(tf.zeros([2,3]))
"""
tf.linspace(start=0 , stop = 1 , step = 3) include the stop value return [0 0.5 1]
while tf.range(start = 0 , stop = 9 ,step = 3) don't include the stop value return [0 3 6]
"""
'''
tf.random_uniform([row_dim , col_dim], minval, maxval) make a uniform randomization
tf.random_normal([row_dim , col_dim], mean , stddev ) make a Guassian randomization
tf.truncated_normal([row_dim , col_dim], mean , stddev ) make a Guassian randomization that all of the value are in the
range of [mean-stddev , mean + stddev]
tf.random_crop(input_tensor, output_size)
tf.random_shuffle(input_tensor)
my_var = tf.Variable(tf.zeros([row_dim , col_dim]))
tf.convert_to_tensor() can used to transfer a numpy array to list or a constant value to a tensor
'''
'''
with tf.Session() as sess:
initialize_op = tf.global_variables_initializer()
sess.run(initialize_op)
print(sess.run(zero))
x = tf.placeholder(tf.float32, shape= [2,2])
y = tf.identity(x)
x_val = np.random.rand(2,2)
t = sess.run(y ,feed_dict={x:x_val})
print(type(t))
'''
"""
initialize_op = tf.global_variables_initializer()
sess.run(initialize_op)
the upper program can be used to make all the variable before it initialized
t = sess.run(y ,feed_dict={x:x_val})
in this part t is a <class 'numpy.ndarray'>
tf.matmul(A,B) make a matrix mutiplication
tf.transpose(A) make a A.T
tf.matrix_determinat(A) make a det of A (also present as |A| )
tf.matrix_inverse(A) make a inverse of A
tf.cholesky(A)
tf.self_adjoint_eig(A) make a
"""
with tf.Session() as sess:
A = np.array((-2,3,9))
B = tf.constant([-2,3,8])
C = tf.placeholder(tf.float32 , shape=B.shape)
print(sess.run(tf.nn.relu6(C),feed_dict={C:A}))
"""
The Activation Functions:
tf.nn.softsign() return to the x/(abs(x)+1)
tf.nn.softplus() return to the log(exp(x)+1)
tf.nn.elu() return to the exp(x)+1 if x<0 else x (Exponential Linear Unit)
"""