<jupyter_start><jupyter_text>Multiplying Two Variables<jupyter_code>x1 = tf.constant([1,2,3,4])
x2 = tf.constant([5,6,7,8])

result = tf.multiply(x1,x2)
print(result)#donesn't provide with actual multiplication because we haven't created a session<jupyter_output>Tensor("Mul:0", shape=(4,), dtype=int32)<jupyter_text>Creating Session<jupyter_code>x1 = tf.constant([1,2,3,4])
x2 = tf.constant([5,6,7,8])

result = tf.multiply(x1,x2)
sess = tf.Session()
print(sess.run(result))
sess.close()
x = tf.Variable(0)#variable declaration #Global
model = tf.global_variables_initializer()
#if any variable declared in Session it can not be accessed
with tf.Session() as session:#until anything stays inside it, it can be printed
    #i = tf.Variable(0)#local variable
    session.run(model)
    for i in range(5):
        x = x+i
        print(session.run(x))
#print(session.run(x))#as it is out of scope of Session
from __future__ import absolute_import, division, print_function

# TensorFlow and tf.keras
import tensorflow as tf
from tensorflow import keras

# Helper libraries
import numpy as np
import matplotlib.pyplot as plt

print(tf.__version__)
#import tensorflow as tf
import pandas as pd
COLUMN_NAMES = ['SepalLength',
                'SepalWidth',
                'PetalLength',
                'PetalWidth',
                'Species'
               ]
training_dataset = pd.read_csv('iris.csv',names = COLUMN_NAMES,header = 0)
train_x = training_dataset.iloc[:,0:4]
train_y = training_dataset.iloc[:,4]
print(train_x.head())
train_y.head()
test_dataset = pd.read_csv('iris_test.csv',names = COLUMN_NAMES,header = 0)
test_x = training_dataset.iloc[:,0:4]
test_y = training_dataset.iloc[:,4]
columns_feat = [tf.feature_column.numeric_column(key = 'SepalLength'),
                tf.feature_column.numeric_column(key = 'SepalWidth'),
                tf.feature_column.numeric_column(key = 'PetalLength'),
                tf.feature_column.numeric_column(key = 'PetalWidth')
               ]

#Define Train function
def train_function(inputs, outputs, batch_size):
    dataset = tf.data.Dataset.from_tensor_slices((dict(inputs),outputs))
    dataset = dataset.shuffle(1000).repeat().batch(batch_size)
    return dataset.make_one_shot_iterator().get_next()
# Build Neural Network - Classifier
classifier = tf.estimator.DNNClassifier(
    feature_columns=columns_feat,
    # Two hidden layers of 10 nodes each.
    hidden_units=[10, 10],
    # The model is classifying 3 classes
    n_classes=3)
# Train the Model.
classifier.train(input_fn=lambda:train_function(train_x, train_y, 100),    steps=100)
#Define Evaluation Function
def evaluation_function(attributes, classes, batch_size):
    attributes = dict(attributes)
    if classes is None:
        inputs = attributes
    else:
        inputs = (attributes, classes)
    dataset = tf.data.Dataset.from_tensor_slices(inputs)
    assert batch_size is not None,"batch_size must not be None"
    dataset = dataset.batch(batch_size)
    return dataset.make_one_shot_iterator().get_next()
#Evaluate the model
eval_result = classifier.evaluate(input_fn=lambda:evaluation_function(test_x, test_y, 100))
print(eval_result)<jupyter_output>W0703 22:56:11.875328  7056 deprecation.py:323] From C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\training\saver.py:1276: checkpoint_exists (from tensorflow.python.training.checkpoint_management) is deprecated and will be removed in a future version.
Instructions for updating:
Use standard file APIs to check for files with this prefix.<jupyter_text>SeaBorn MATPLOTLIB<jupyter_code>import matplotlib.pyplot as plt
import seaborn as sns
seaborn?
tips = sns.load_dataset('tips')
sns.violinplot(x = 'tip', data = tips)
plt.show()
seaborn?
import numpy as np
np?<jupyter_output>Object `seaborn` not found.
{'fraction_non_alphanumeric': 0.11002895498815478, 'fraction_numerical': 0.023163990523822058, 'mean_word_length': 4.637982195845697, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '516366', 'license': 'MIT', 'n_tokens_mistral': 1304, 'n_tokens_neox': 1246, 'n_words': 290, 'path': 'TensorFlow.ipynb', 'repo_name': 'vaibhavsingh9/Python_Machine_Learning_2019', 'size': '3799'}