I'm trying to run some Python code in RStudio. Part of this code should produce "progress bars" because the code takes a while to run; see 14:42 in this video for an example of what this is supposed to look like.
Below is the code I'm running in Rstudio console. It's pretty much the same code in the video, but condensed a little for the sake of posting here:
### Unimportant preamble -----------------
import tensorflow as tf
import numpy as np
from tensorflow import keras
(train_images, train_labels), (test_images, test_labels) = keras.datasets.fashion_mnist.load_data()
model = tf.keras.Sequential([
keras.layers.Flatten(input_shape = (28, 28)),
keras.layers.Dense(units = 128, activation = tf.nn.relu),
keras.layers.Dense(units = 10, activation = tf.nn.softmax)
])
model.compile(loss = 'sparse_categorical_crossentropy', optimizer = 'adam')
### This is the line of concern ----------------------
model.fit(train_images, train_labels, epochs = 5)
Running this in the RStudio console, it produces an output like this:
>>> model.fit(train_images, train_labels, epochs = 5)
Epoch 1/5
1/1875 [..............................] - ETA: 39:17 - loss: 154.9670
24/1875 [..............................] - ETA: 4s - loss: 65.0053
51/1875 [..............................] - ETA: 3s - loss: 45.2076
79/1875 [>.............................] - ETA: 3s - loss: 34.9823
107/1875 [>.............................] - ETA: 3s - loss: 29.5214
135/1875 [=>............................] - ETA: 3s - loss: 25.6874
150/1875 [=>............................] - ETA: 3s - loss: 24.2370
178/1875 [=>............................] - ETA: 3s - loss: 22.1410
207/1875 [==>...........................] - ETA: 3s - loss: 20.3983
etc. On my laptop, about 500 lines end up getting printed by the time it's finished running, instead of the intended 10.
I'm assuming each line is supposed to overwrite the last. Is it possible to change something to make the same happen in RStudio?