<jupyter_start><jupyter_text>Intro to Deep Learning Live Demos<jupyter_code>from tensorflow.python.client import device_lib
device_lib.list_local_devices()
tf.__version__
first_param = tf.constant(2)
second_param = tf.constant(3)
# Old versions
# tf.enable_eager_execution()
first_param
first_param.numpy()
tf.multiply(first_param,second_param)
# def compute(a,b):
#     return tf.pow(tf.add(tf.multiply(2, a), tf.multiply(3, b)),2)

# Operators are overloaded

def compute(a,b):
    return (2 * a + 3 * b) ** 2
compute(first_param,second_param).numpy()
compute(2, 3)
compute(2.0, 3.0)
compute(np.array([2]), np.array([3]))
compute(np.array([2, 42, 18]), np.array([3, -5, 12]))
compute(tf.constant(2), tf.constant(30))
compute(tf.constant([2, 42, 18]), tf.constant([3, -5, 12]))
# Now all is accepted as tensorflow tensors
@tf.function
def compute_dec(a,b):
    return (2 * a + 3 * b) ** 2
compute_dec(first_param,second_param).numpy()
compute_dec(2, 3)
compute_dec(2.0, 3.0)
compute_dec(np.array([2]), np.array([3]))
compute_dec(np.array([2, 42, 18]), np.array([3, -5, 12]))
compute_dec(tf.constant(2), tf.constant(30))
a1, b1 = tf.constant([2, 3, 4]), tf.constant([3, 4, 5])
tf.summary.trace_on(graph=True, profiler=True)
result = compute_dec(a1, b1)
print(result.numpy())
writer = tf.summary.create_file_writer(logdir = "logs")
with writer.as_default():
    tf.summary.trace_export(name = "compute_func", step = 0, profiler_outdir = "logs")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18194161575016973, 'fraction_numerical': 0.048200950441276307, 'mean_word_length': 6.2254901960784315, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '508579', 'license': 'MIT', 'n_tokens_mistral': 611, 'n_tokens_neox': 575, 'n_words': 116, 'path': '1_Introduction_To_Deep_Learning_Basic_Models/01_IntroductionToDeepLearning.ipynb', 'repo_name': 'vladiant/SoftUniDeepLearning2019', 'size': '1473'}