Three failed attempts of handling non-sequential data

The Progress of Products Classification

Cause now we are considering to classify the product by two kinds of features, product images, and product title. I tried to handle these two kinds of features individually, on the product title side, I used Keras build a simple RNN model for classifying 10 classes product, and I got a good result, about 98% accuracy. I test the model with some products from our site, except the title is too ambiguous I can get a proper result, the model doesn‘t know how to handle some combined word, e.g. ‘SmartWatch‘. But I found that the product images are very clear, so I wonder if I could combine these two features it wouldn‘t be a big problem. you can see the watch at  , and my model recognized it as a motherboard. 

On the other side, I want to build a model to classify the product images. Different from usual image classification problem, I‘m going to make a classifier working on a set of images, for example, a Lenovo Laptop product would contain an image of Lenovo logo, the laptop‘s front and back photograph, and all images can in any order. So, I‘m just doing a job with a set of non-sequential data.

Three failed attempts

1.Working on a single image and combine the result

I trained a usual classifier that accepts a single image, I wrote the model with Keras Vgg16 like before. Suppose we have 3 images, I pass each image to the model, and I got a probability distribution of all classes, assume we have 4 classes, for each image I would get a probability vector like [0.1,0.8,0.05,0.05]. Then, I use weighted average to merge all probability, and I got a problem, If I have 3 images one image is ambiguous and get a low rank on the right classes, suppose the first class is the right class[0.1,0.4,0.3,0.3], and the other two images I get a high rank in the first class [0.98,0.0001,0.003,0.016], for a human, it‘s very certain this product belongs to the first class, but after weighted average the probability might like[0.68,0.1,0.05,0.03].

I also try to build a simple RNN model which accepts all probability vectors, and it didn‘t work.

2.Combine all images into a single data block

Most product images are RGB image, from a mathematic view, it‘s a 3rd order tensor with shape (3,width,height), and each element in the tensor is an integer from 0 to 255.

First, I convert all images into a grayscale image, now the image‘s shape is (width, height), it‘s a matrix. I limit a max number of images as N, if the number of images is less than N, I would fill some blank images, a matrix with all elements set to zero. Second, I merge these images on the 3rd axis, after that, I got a tensor with shape (N, width, height), Finally, I build a model can accept the tensor. But I failed, I got a different result when I reorder the images.

I think the reason why I failed is after convolution and pooling layers I get a 3rd order tensor, I need to reshape the tensor to a vector and pass it to the final classifier, that‘s the job the Keras Flatten layer did, and it‘s more like a weighted average job. when I change the order of the images, I would get a different vector before the classifier.

3.Add attention mechanism to the model

As I mentioned above, the weighted average caused the problem, I want to do something prevent weighted average before Flatten layer. Attention mechanism is a new technique always be used in RNN, it can make the model learn which part is more important and pay attention to that part. I flowed keras-attention-mechanism to add the attention mechanism to my model. But I failed like before.

Attention mechanism can‘t promise to pass a same tensor to the classifier with a different order of images.

Some thoughts

Like this paper mentioned, I think to deal with non-sequential data, we need to use some statistics feature.

时间: 2024-10-12 12:56:24

Three failed attempts of handling non-sequential data的相关文章

Time Series data 与 sequential data 的区别

It is important to note the distinction between time series and sequential data. In both cases, the data consist of a sequence, or list of values, in which the order is important. Time series is a subclass of sequential data where the longitudinal co

ElasticsearchException: java.io.IOException: failed to read [id:0, file:/data/elasticsearch/nodes/0/_state/global-0.st]

from : https://www.cnblogs.com/hixiaowei/p/11213143.html 1.以前装过elasticsearch,重新安装elastic search ,报错 [2019-07-19T14:32:10,720][ERROR][o.e.g.GatewayMetaState ] [master-node] failed to read local state, exiting... org.elasticsearch.ElasticsearchExceptio

IllegalArgumentException: requirement failed: Corrupt index found

今天突然接到客户反映线上服务器发送消息异常,登录服务器查看是kafka服务出现了问题,想重启一下服务,结果重启出现一下报错 [2017-06-30 19:29:13,708] FATAL Fatal error during KafkaServerStartable startup. Prepare to shutdown (kafka.server.KafkaServerStartable) java.lang.IllegalArgumentException: requirement fai

greenplum初始化错误,Failed to insert port=40000

$ gpinitsystem -c  /usr/local/greenplum-db/gpconfigs /gpinitsystem_config 20150429:15:30:59:023693 gpcreateseg.sh:y153-hadoop-namenode2:gpadmin-[WARN]:-Failed to insert port=40000 in /data/primary/gpseg0/postgresql.conf on y153-hadoop-namenode2.vclou

Flash program memory and data EEPROM

1.简介 STM8S内部的FLASH程序存储器和数据EEPROM是由一组通用寄存器来控制的:所以我们可以通过这些通用寄存器来编程或擦除存储器的内容.设置写保护.或者配置特定的低功耗模式.我们也可以自己对器件的 option byte 进行编程.在这里我们只简单的讲解如何对STM8S内部的数据存储区域(data memory)进行写操作.读操作.擦除操作. 2.存储架构图 STM8S内部存储包括:FLASH程序存储器(FLASH program memory)和数据EEPROM(DATA EEPR

The Swiss Army Knife of Data Structures … in C#

"I worked up a full implementation as well but I decided that it was too complicated to post in the blog. What I was really trying to get across was that immutable data structures were possible and not that hard; a full-on finger tree implementation

Oozie java.io.IOException: output.properties data exceeds its limit [2048]

在使用oozie调用sqoop时,报了下边这个错 Launcher AM execution failed java.io.IOException: output.properties data exceeds its limit [2048] at org.apache.oozie.action.hadoop.LocalFsOperations.getLocalFileContentAsString(LocalFsOperations.java:86) at org.apache.oozie.

JavaScript data types and data structures

JavaScript data types and data structures Programming languages all have built-in data structures, but these often differ from one language to another. This article attempts to list the built-in data structures available in JavaScript and what proper

[转帖]27.2. The Statistics Collector

27.2. The Statistics Collector https://www.postgresql.org/docs/current/monitoring-stats.html 27.2.1. Statistics Collection Configuration 27.2.2. Viewing Statistics 27.2.3. Statistics Functions PostgreSQL's statistics collector is a subsystem that sup