我正在使用tqdm我在Jupyter笔记本中运行的脚本中打印进度.我通过打印所有消息到控制台tqdm.write().但是,这仍然给我一个偏差的输出,如下所示:
也就是说,每次必须打印新行时,下一行都会打印一个新的进度条.当我通过终端运行脚本时,这不会发生.我怎么解决这个问题?
我正在尝试在TensorFlow代码中使用预先训练的Keras模型,如本节Keras博客文章第II部分:使用带有TensorFlow的Keras模型中所述.
我想使用Keras中提供的预先训练的VGG16网络从图像中提取卷积特征图,并在其上添加我自己的TensorFlow代码.所以我做到了这一点:
import tensorflow as tf
from tensorflow.python.keras.applications.vgg16 import VGG16, preprocess_input
from tensorflow.python.keras import backend as K
# images = a NumPy array containing 8 images
model = VGG16(include_top=False, weights='imagenet')
inputs = tf.placeholder(shape=images.shape, dtype=tf.float32)
inputs = preprocess_input(inputs)
features = model(inputs)
with tf.Session() as sess:
K.set_session(sess)
output = sess.run(features, feed_dict={inputs: images})
print(output.shape)
Run Code Online (Sandbox Code Playgroud)
但是,这给了我一个错误:
FailedPreconditionError: Attempting to use uninitialized value block1_conv1_2/kernel
[[Node: block1_conv1_2/kernel/read = Identity[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:GPU:0"](block1_conv1_2/kernel)]]
[[Node: vgg16_1/block5_pool/MaxPool/_3 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_132_vgg16_1/block5_pool/MaxPool", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]
Run Code Online (Sandbox Code Playgroud)
相反,如果我在运行网络之前运行初始化程序操作:
with …Run Code Online (Sandbox Code Playgroud) 我在 macOS High Sierra 上安装了 Wireshark 2.4.6。由于某种原因,Wireshark 没有捕获我的计算机上的任何HTTP 流量。我已在浏览器上明确打开多个网页并过滤 HTTP 流量,但我看不到任何 HTTP 数据包。
我的电脑上有一个 ubunbtu 虚拟机。当我启动它并在其上打开网页时,我能够在 Wireshark(在我的主机 macOS 本身上运行)上看到相应的 HTTP 流量。
为什么我看不到在 macOS 浏览器上打开的网站的 HTTP 流量?macOS 是否以某种方式以不同的方式对待 HTTP(如果可能的话)?
简而言之,我的问题是,为什么浮点数中的舍入误差仅在计算后显示而不是存储文字?
我的意思是这个 - 我知道由于从十进制转换为二进制和返回时浮点数的舍入错误而产生的问题.
例如,在Java中:
double a = 10.567;
double b = 2.16;
double c = a * b;
Run Code Online (Sandbox Code Playgroud)
c然后存储值22.824720000000003,而不是22.82472.
这是因为结果22.82472无法准确存储在double类型的有限二进制数字中.但是,10.567和2.16(即a和b)都不能.
但是如果我打印a和b的值,它们就会被打印出来,没有任何舍入错误.为什么舍入错误不会显示在这里?
这是否意味着浮点文字的表示与浮点计算结果的表示有某种不同?
我知道在C++中,EOF字符会自动附加到文件末尾,例如filestream.close.我想知道,这是在C中也是默认完成的吗?