Practical Machine Learning Labs in TensorFlow and PyTorch
Lab 1: Basic TensorFlow Computation Graph
This example demonstrates how to define and execute a simple computation graph in TensorFlow using the @tf.function decorator, which converts a Python function into a high-performance TensorFlow graph.
import tensorflow as tf
# Define a simple computation graph
@tf.function # Converts Python function into a TensorFlow graph
def my_graph(x, y):
return x * y + 5 # Simple equation: (x * y) + 5
# Create TensorFlow constants (nodes)
x = tf.constant(3.0)
y = tf.constant(4.0)
# Run the computation graph
result = my_graph(x, y)
# Print the result
# Convert tensor to a NumPy array to see the value
print(f"Result of (x * y) + 5: {result.numpy()}")Lab 2: Simple Linear Regression with Keras
Here, we build,... Continue reading "Practical Machine Learning Labs in TensorFlow and PyTorch" »
English with a size of 14.76 KB