Tool/TensorFlow(6)
-
6. Basic training loops
You have learned about tensors, variables, gradient tape, and modules. In this guide, you will fit these all together to train models. import tensorflow as tf import matplotlib.pyplot as plt Solving machine learning problems Solving a machine learning problem usually consists of the following steps: Obtain training data Define the model Define a loss function Run through the training data, calcu..
2022.03.12 -
5. Introduction to modules, layers, and models
To do machine learning in TensorFlow, you are likely to need to define, save, and restore a model. A model is, abstractly: A function that computes something on tensors (a forward pass) Some variables that can be updated in response to training import tensorflow as tf from datetime import datetime %load_ext tensorboard Defining models and layers in TensorFlow In TensorFlow, most high-level imple..
2022.03.12 -
4. Introduction to graphs and tf.function
This guide goes beneath the surface of TensorFlow and Keras to demonstrate how TensorFlow works. In this guide, you'll learn How TensorFlow allows you to make simple to your code to get graphs How graphs are stored and represented How you can use them to accelerate your models This is a big-picture overview that covers how tf.function allows you to switch from eager execution to graph execution...
2022.03.12 -
3. Introduction to gradients and automatic differentiation
In this guide, you will explore ways to compute gradients with TensorFlow especially in eager execution. import numpy as np import matplotlib.pyplot as plt import tensorflow as tf Computing gradients To differentiate automatically, TensorFlow needs to remember what operations happen in what order during the forward pass. Then, during the backward pass, TensorFlow traverses this list of operation..
2022.03.12 -
2. Introduction to Variables
A TensorFlow variable is the recommanded way to represent shared, persistent state your program manipulates. This guide covers how to create, update, and manage instances of tf.Variable in Tensorflow. Higher level libraries like tf.keras use lf.Variable to store model parameters. import tensorflow as tf Create a variable To create a variable, provide an initial value. The tf.Variable will have t..
2022.03.12 -
1. Introduction to Tensors
import numpy as np import tensorflow as tf Basic Tensors are multi-dimensional arrays with a uniform type (called a dtype). All tensors are immutable like Python numbers and strings: you can never update the contents of a tensor, only create a new one. # Python number num = 123 # Tensorflow Tensor tensor = tf.constant([1, 2]) # Before num address print("Before num address: ", id(num)) # Before t..
2022.03.12