<jupyter_start><jupyter_text>Intro to TF times million<jupyter_code>import numpy as np
np.random.seed(42)
import tensorflow as tf
tf.set_random_seed(42)
import matplotlib.pyplot as plt
import pandas as pd
%matplotlib inline
xs = np.linspace(0.,8.,8000000)
ys = 0.3*xs-0.8+ np.random.normal(scale=0.25,size=len(xs))
fig,ax = plt.subplots()
data_subset = pd.DataFrame(list(zip(xs,ys)),columns=['x','y']).sample(n=1000)
_ = ax.scatter(data_subset.x,data_subset.y)<jupyter_output><empty_output><jupyter_text>Define Variables<jupyter_code>m = tf.Variable(-0.5)
b = tf.Variable(1.0)
batch_size = 8<jupyter_output><empty_output><jupyter_text>Define Placeholder<jupyter_code>xs_placeholder = tf.placeholder(tf.float32,[batch_size])
ys_placeholder = tf.placeholder(tf.float32,[batch_size])<jupyter_output><empty_output><jupyter_text>Define Graph<jupyter_code>ys_model = m*xs_placeholder+b
total_error = tf.reduce_sum((ys_placeholder-ys_model)**2)<jupyter_output><empty_output><jupyter_text>Define Optimizer and Initializer<jupyter_code>optimizer_op = tf.train.GradientDescentOptimizer(learning_rate=0.001).minimize(total_error)
initialzer_op = tf.global_variables_initializer()<jupyter_output><empty_output><jupyter_text>Build sampling into graph<jupyter_code>with tf.Session() as session:
    
    session.run(initialzer_op)
    n_bathces = 1000
    for i in range(n_bathces):
        random_indices = np.random.randint(len(xs),size=batch_size)
        feed = {
            xs_placeholder: xs[random_indices],
            ys_placeholder: ys[random_indices]
        }
        session.run(optimizer_op,feed_dict=feed)
    slope,intercept = session.run([m,b])
slope
intercept<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12632821723730814, 'fraction_numerical': 0.024793388429752067, 'mean_word_length': 6.775229357798165, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '315944', 'license': 'MIT', 'n_tokens_mistral': 665, 'n_tokens_neox': 631, 'n_words': 79, 'path': 'TFLiveLessons/tf_intro_a_million.ipynb', 'repo_name': 'anilkumarpanda/deeplearning', 'size': '1694'}