我正在实现一个损失函数,该函数将使用掩模张量(M)来消除给定预测和地面实况张量0s and 1s的一些损失值。(P)(G)
所以,我有两种可能的方法:
逐元素乘法:
loss = K.sum(M * K.binary_crossentropy(G, P))
条件选择:
bin_ce = K.binary_crossentropy(G, P)
loss = K.sum(tf.where(tf.equal(M, 1), bin_ce, 0))
Run Code Online (Sandbox Code Playgroud)
那么,就运行时间而言,哪个会更高效呢?
我正在尝试阅读这一行中Tensorflow非极大值抑制方法的源代码。它是从gen_image_ops文件导入的,但我在张量流源代码中找不到该文件。
有什么来源可以让我获得这个方法的代码吗?
object-detection non-maximum-suppression tensorflow object-detection-api
我想使用VGG预训练模型提取368x368尺寸图像的特征。根据文档,VGGnet接受224x224尺寸的图像。有没有办法给Keras VGG提供可变大小的输入?
这是我的代码:
# VGG Feature Extraction
x_train = np.random.randint(0, 255, (100, 224, 224, 3))
base_model = VGG19(weights='imagenet')
modelVGG = Model(inputs=base_model.input, outputs=base_model.get_layer('block4_conv2').output)
block4_conv2_features = modelVGG.predict(x_train)
Run Code Online (Sandbox Code Playgroud)
编辑代码(有效!)
# VGG Feature Extraction
x_train = np.random.randint(0, 255, (100, 368, 368, 3))
base_model = VGG19(weights='imagenet', include_top=False)
modelVGG = Model(inputs=base_model.input, outputs=base_model.get_layer('block4_conv2').output)
block4_conv2_features = modelVGG.predict(x_train)
Run Code Online (Sandbox Code Playgroud)