Resize image, Keeping Aspect Ratio or not 在 Train model 時,前處理常常會需要將 image resize 成 model input 的 size,如 YOLO 的 416x416, 608x608 等,這邊列舉幾種目前常見的 resize 方法,如下: Original image: Resized without keeping aspect ratio - cv::resize() [Square Inference] Resized with
Progress bar of Tensorflow 2’s custom training loop The collection of the progress bar methods for tf.GradientTape when training model 詳細 code 請看: progress_bar_tqdm.py progress_bar_keras.py progress_bar_click.py 1. tqdm 使用 tqdm 來顯示 model training 進度, loss and accuracy,如下: train_loss = tf.keras.metrics.Mean(name='train_loss') train_accuracy = tf.keras.metrics.SparseCategoricalAccuracy(name='train_accuracy') for epoch in range(NUM_EPOCHS): n_batches = x_train.shape[0] /
Custom Training Loop 在 tf.keras 中已經提供很方便的 training and evaluation loops, fit() 和 evaluate()。 但如果我們想要對 training 或 evaluation 進行更 low-level 的控制的話, 我們需要從頭開始寫自己的 training and evaluation loo
GradientTape 在介紹 tf.GradientTape 前我先來看看什麼是自動微分 (Automatic differentiation, AD) Automatic Differentiation 為了自動微分(Automatic differentiation),TensorFlow 需要: 前
Pytorch Progress bar The collection of the progress bar methods for PyTorch when training model 詳細 code 請看: progress_bar_tqdm.py progress_bar_keras.py progress_bar_click.py 1. tqdm 使用 tqdm 來顯示 model training 進度, loss and accuracy,如下: for epoch in range(NUM_EPOCHS): n_batches = len(train_loader) print(f'Epoch {epoch+1}/{NUM_EPOCHS}') with tqdm(train_loader, total=n_batches, bar_format='{desc:<5.5}{percentage:3.0f}%|{bar:36}{r_bar}') as pbar: for idx, (x, y)