Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
tensorflow
GitHub Repository: tensorflow/docs-l10n
Path: blob/master/site/pt-br/addons/tutorials/tqdm_progress_bar.ipynb
25118 views
Kernel: Python 3
#@title Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License.

Callbacks do TensorFlow Addons: barra de progresso TQDM

Visão geral

Este notebook demonstra como usar TQDMCallback no TensorFlow Addons.

Configuração

!pip install -U tensorflow-addons
!pip install -q "tqdm>=4.36.1" import tensorflow as tf import tensorflow_addons as tfa from tensorflow.keras.datasets import mnist from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense, Dropout, Flatten
import tqdm # quietly deep-reload tqdm import sys from IPython.lib import deepreload stdout = sys.stdout sys.stdout = open('junk','w') deepreload.reload(tqdm) sys.stdout = stdout tqdm.__version__

Importe e normalize os dados

# the data, split between train and test sets (x_train, y_train), (x_test, y_test) = mnist.load_data() # normalize data x_train, x_test = x_train / 255.0, x_test / 255.0

Crie um modelo de CNN simples do MNIST

# build the model using the Sequential API model = Sequential() model.add(Flatten(input_shape=(28, 28))) model.add(Dense(128, activation='relu')) model.add(Dropout(0.2)) model.add(Dense(10, activation='softmax')) model.compile(optimizer='adam', loss = 'sparse_categorical_crossentropy', metrics=['accuracy'])

Uso do TQDMCallback padrão

# initialize tqdm callback with default parameters tqdm_callback = tfa.callbacks.TQDMProgressBar() # train the model with tqdm_callback # make sure to set verbose = 0 to disable # the default progress bar. model.fit(x_train, y_train, batch_size=64, epochs=10, verbose=0, callbacks=[tqdm_callback], validation_data=(x_test, y_test))

Confira abaixo a saída esperada ao executar a célula acima Figura da barra de progresso TQDM

# TQDMProgressBar() also works with evaluate() model.evaluate(x_test, y_test, batch_size=64, callbacks=[tqdm_callback], verbose=0)

Confira abaixo a saída esperada ao executar a célula acima Figura da barra de progresso TQDM Evaluate