【发布时间】:2019-06-28 02:43:03
【问题描述】:
我正在研究一个深度图像相似性模型,我希望得到一些帮助。
我不断收到此错误,不知道该如何处理或修复它。
Input arrays should have the same number of samples as target arrays. Found 100 input samples and 3 target samples.
我将图像分解为三个文件,然后读取它们。然后我有三个数组(锚、正和负)。我拥有的标签都是相同的 y =[1,1,0] 即 [a,p,n] 这是正确的方法吗?
我正在关注这个博客/代码https://medium.com/@akarshzingade/image-similarity-using-deep-ranking-c1bd83855978
模型和损失函数是一样的,唯一不同的是我加载了什么数据,如何加载以及如何训练模型。
# Alist of images for anchor similar and negative
# Read in all the image paths
anchor = np.load("list/anchor_list.npy")
pos = np.load("list/positvie_list.npy")
neg = np.load("list/negative_list.npy")
def load_img(path):
img = image.load_img(path, target_size=(224, 224))
img = image.img_to_array(img)
img = np.array(img)
return img
a = []
p = []
n = []
# Read in sampple of the images
for i in range(0, 100):
a.append(load_img(os.path.join(data_dir, anchor[i])))
p.append(load_img(os.path.join(data_dir, pos[i])))
n.append(load_img(os.path.join(data_dir, neg[i])))
a = np.array(a)
p = np.array(p)
n = np.array(n)
y = [1, 1, 0]
deep_rank_model.fit([a, p, n], y,
batch_size=batch_size,
epochs=10,
verbose = 1)
【问题讨论】:
标签: python tensorflow keras training-data