<jupyter_start><jupyter_text>First TensorFlow Neurons  Load dependencies<jupyter_code>import numpy as np
np.random.seed(42)
import tensorflow as tf
tf.set_random_seed(42)
import matplotlib.pyplot as plt
%matplotlib inline<jupyter_output><empty_output><jupyter_text>Set number of neurons<jupyter_code>n_input = 784
n_dense = 128<jupyter_output><empty_output><jupyter_text>Define placeholder Tensor for simulated MNIST digits<jupyter_code>x = tf.placeholder(tf.float32, [None, n_input])<jupyter_output><empty_output><jupyter_text>Create Variable Tensors for neuron biases `b` and weight matrix `W`<jupyter_code>b = tf.Variable(tf.zeros([n_dense]))
# W = tf.Variable(tf.random_uniform([n_input, n_dense])) # 1.
# W = tf.Variable(tf.random_normal([n_input, n_dense])) # 2.
W = tf.get_variable('W', [n_input, n_dense], 
                    initializer=tf.contrib.layers.xavier_initializer())<jupyter_output><empty_output><jupyter_text>Design the computational graph<jupyter_code>z = tf.add(tf.matmul(x, W), b)
a = tf.nn.relu(z) # first with tf.sigmoid(), then stick with tf.tanh() or tf.nn.relu()<jupyter_output><empty_output><jupyter_text>Create op for variable initialization<jupyter_code>initializer_op = tf.global_variables_initializer()<jupyter_output><empty_output><jupyter_text>Execute the graph in a session<jupyter_code>with tf.Session() as session:
    session.run(initializer_op)
    
    layer_output = session.run(a, {x: np.random.random([1, n_input])})
layer_output
_ = plt.hist(np.transpose(layer_output))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12491909385113269, 'fraction_numerical': 0.009708737864077669, 'mean_word_length': 7.4021739130434785, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '324925', 'license': 'MIT', 'n_tokens_mistral': 591, 'n_tokens_neox': 566, 'n_words': 97, 'path': 'notebooks/first_tensorflow_neurons.ipynb', 'repo_name': 'nirupam1sharma/my-course', 'size': '1545'}