小编ZCD*_*DEV的帖子

TensorFlow中具有稀疏标签的多标签图像分类?

我想对n个类执行多标签图像分类任务。我已经为每个图像提供了稀疏的标签向量,并且每个标签向量的每个维度目前都以这种方式进行编码:

1.0->标签为真/图片属于此类

-1.0->标签为false /此类不包含图像。

0.0->缺失值/标签

例如:V = {1.0,-1.0,1.0,0.0}

对于此示例V,模型应了解,应将相应图像分类为第一类和第三类。

我的问题是当前如何处理缺少的值/标签。我已经搜索了所有问题并找到了这个问题:在这里找到了 tensorflow / skflow#113

因此可以使用以下方法进行多重图像分类:tf.nn.sigmoid_cross_entropy_with_logits(logits,target,name = None)

但是TensorFlow具有针对稀疏softmax的此错误函数,该函数用于专有分类:tf.nn.sparse_softmax_cross_entropy_with_logits(登录,标签,名称=无)

那么,是否存在稀疏的S型交叉熵呢?(找不到任何内容)或任何建议,如何处理稀疏标签的多标签分类问题。

deep-learning conv-neural-network tensorflow

5
推荐指数
1
解决办法
2366
查看次数

用图像和多标签编写tfrecord以进行分类

我想使用TensorFlow执行多标签分类。我有大约95000张图像,每个图像都有一个对应的标签向量。每个图像有7个标签。这7个标签用大小为7的张量表示。每个图像的形状为(299,299,3)。

现在如何将带有相应标签矢量/张量的图像写入.tfrecords文件

我当前的代码/方法:

def get_decode_and_resize_image(image_id):
    image_queue = tf.train.string_input_producer(['../../original-data/'+image_id+".jpg"])
    image_reader = tf.WholeFileReader()
    image_key, image_value = image_reader.read(image_queue)
    image = tf.image.decode_jpeg(image_value,channels=3)
    resized_image= tf.image.resize_images(image, 299, 299, align_corners=False)
    return resized_image



init_op = tf.initialize_all_variables()
with tf.Session() as sess:
 # Start populating the filename queue.

 sess.run(init_op)
 coord = tf.train.Coordinator()
 threads = tf.train.start_queue_runners(coord=coord)

 # get all labels and image ids
 csv= pd.read_csv('../../filteredLabelsToPhotos.csv')

 #create a writer for writing to the .tfrecords file
 writer = tf.python_io.TFRecordWriter("tfrecords/data.tfrecords")

 for index,row in csv.iterrows():

     # the labels
     image_id = row['photo_id']
     lunch = tf.to_float(row["lunch"])
     dinner= …
Run Code Online (Sandbox Code Playgroud)

deep-learning tensorflow

5
推荐指数
1
解决办法
1199
查看次数