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.

 

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

  1. Time Series data 与 sequential data 的区别

    It is important to note the distinction between time series and sequential data. In both cases, the ...

  2. Open-sourcing LogDevice, a distributed data store for sequential data

    https://logdevice.io/blog/2018/09/12/open-sourcing-announcement.html September 12, 2018   We are exc ...

  3. 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 ,报错 ...

  4. PRML读书会第十三章 Sequential Data(Hidden Markov Models,HMM)

    主讲人 张巍 (新浪微博: @张巍_ISCAS) 软件所-张巍<zh3f@qq.com> 19:01:27 我们开始吧,十三章是关于序列数据,现实中很多数据是有前后关系的,例如语音或者DN ...

  5. 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 ...

  6. LOAD DATA INFILE Syntax--官方

    LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE 'file_name' [REPLACE | IGNORE] INTO TABLE tbl_n ...

  7. redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketException: 断开的管道 (Write failed)

    昨晚,包发到测试环境中,出现redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketException: 断开的 ...

  8. troubleshooting-执行Oozie调度Hive导数脚本抛java.io.IOException: output.properties data exceeds its limit [2048]

    执行Oozie调度Hive导数脚本抛java.io.IOException: output.properties data exceeds its limit [2048] 原因分析 shell脚本中 ...

  9. Analyzing Microarray Data with R

    1) 熟悉CEL file 从 NCBI GEO (http://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE24460)下载GSE24460. 将得到 ...

随机推荐

  1. pyCharm django 中新加app

    1.在manage.py@djangotest中输入命令: 1.startapp   realnameauth   ---新建一个app,名字为realnameauth 2.在 django 项目中的 ...

  2. 1. ReactJS基础(开发环境搭建)

    本文主要介绍通过React官方提供的create-react-app脚手架进行开发环境的搭建. 1.安装node环境(安装过程这里不做介绍,可参考其他博文) 在cmd中输入node -v 如果可以看到 ...

  3. element-ui隐藏组件scrollbar的使用

    话不多说,直接上图 总结:el-scrollbar组件设置高度100%包裹住需要滚动的dom结构即可. 再例如: 至于配置props,参见源码https://github.com/ElemeFE/el ...

  4. 请求转发和URL重定向的原理和区别

    一.请求转发和重定向是在java后台servlet中,由一个servlet跳转到另一个servlet/jsp要使用的技术 使用方法 请求转发  req.getResquestDispatcher(se ...

  5. PHP数据库连接mysql与mysqli的区别与用法

    一.mysql与mysqli的概念相关: 1.mysql与mysqli都是php方面的函数集,与mysql数据库关联不大. 2.在php5版本之前,一般是用php的mysql函数去驱动mysql数据库 ...

  6. Python控制台颜色

    Python控制台颜色 格式:\033[显示方式;前景色;背景色m 说明: 前景色 背景色 颜色 30 40 黑色 31 41 红色 32 42 绿色 33 43 黃色 34 44 蓝色 35 45 ...

  7. 猴子分桃—Python

    def f(): for i in range(3120,4000): flag = 1 k=i for j in range(5): if i%5==1: i=(i//5)*4 else: flag ...

  8. 用汇编语言角度来理解C语言的一些问题

    在汇编的世界里,整数的存在和表示是没有有符号数和无符号数之分的,都是用数的补码表示,有无符号的计算是靠指令来进行确定.如JA/JB是用于无符号数的跳转指令,而JG/JL则是用于有符号数的指令.汇编中的 ...

  9. create-react-app源码解读之为什么不搞个山寨版的create-react-app呢?

    最近把 vue-cli@2.x 和 create-react-app 的源码都看了一遍.由于现在官方推荐使用 vue-cli@3.0 ,改动比较大,所以就不写关于 vue-cli 的了(据说是因为 v ...

  10. activiti 任务监听参数的配置

    public class TaskListenersImp implements TaskListener { private Expression level; private Expression ...