大规模特征编码问题和工程实践
2017-12-14 14:58
846 查看
One-Hot Encoding
方式1:序号编码
根据特征在整个特征集合中的index进行编码。在Spark里的编码逻辑:
1.把样本集合的特征map{feature:value}放到一个Set集合里,然后取集合的index作为一个特征feature:value的编号,map{map{feature:value}:index}。
2.然后将每条样本转成index表示的fea_ids。
2.最后将每条样本表示成SparseVector(feature_zise,fea_ids,1)。
方式2:哈希编码
根据特征值的hash值进行编码output_id = Hash(input_feature_string) % bucket_size
比如在tesorflow中对商品id进行编码:
item_id = tf.contrib.layers.sparse_column_with_hash_bucket("item_id", hash_bucket_size=10000000)
Embedding
用户、商品等id类特征维度合计高达几千万维, 假设在输入层后直接连接 100 个输出神经元的全连接层,那么这个模 型的参数规模将达到上亿规模。直接接入全连接层将导致以下几个问题:
1. 各个域都存在冷门的特征,这些冷门的特征将会被热门的特征淹没,基本不起作用, 跟全连接层的连接边权值会趋向于 0,冷门的商品只会更冷门。
2. 模型的大小 将会非常庞大,超过G,在训练以及预测中都会出现很多工程上的问题。
所以对大规模特征的Embedding需要一些特殊的Trick,目前探索的方法如下:
https://stackoverflow.com/questions/43288147/how-do-i-use-a-very-large-2m-word-embedding-in-tensorflow https://stackoverflow.com/questions/44863493/could-word2vec-algorithm-be-distributed-on-multi-computers-using-tensorflow https://stackoverflow.com/questions/43130893/seq2seq-embedding-size-is-too-large-for-distributed-training https://stackoverflow.com/questions/38427471/why-does-tf-nn-embedding-lookup-use-a-list-of-embeddings https://stackoverflow.com/questions/47523374/feature-columns-embedding-lookup https://stackoverflow.com/questions/34870614/what-does-tf-nn-embedding-lookup-function-do
相关文章推荐
- 干货分享 | 详解特征工程与推荐系统及其实践(附PPT)
- 关于web工程乱码问题-解决方案及编码习惯养成
- java开发编程及工程部署中编码问题
- 用深度学习(CNN RNN Attention)解决大规模文本分类问题 - 综述和实践(转载)
- Hulu机器学习问题与解答系列 | 二十二:特征工程—结构化数据
- Android Studio修改工程、系统编码,修正运行程序乱码问题
- 从文本分类问题中的特征词选择算法追踪如何将数学知识,数学理论迁移到实际工程中去
- 如何修改tomcat服务器默认的编码方式?javaweb工程乱码问题解决。
- winows转linux下的QT工程编码乱码问题
- 解决在aix系统l中weblogic下发布web工程时xml文件GBK编码出错的问题
- 大规模开发团队如何实现DevOps转型? 来自微软全球开发平台工程团队的实践经验
- JAVA工程连接读取Access数据库UTF8编码乱码问题
- maven工程编码警告问题
- android studio导入gbk编码的工程文件导致的乱码问题
- 数据挖掘实践与我的想法之特征工程
- 一项浩大的JAVA编码工程(与unix兼容乱码问题)
- maven构建eclipse工程的编码问题
- 面试问题:专业基础知识,软件工程知识,英语水平,实践能力
- UTF8工程编码问题
- Java工程Properties配置文件注释中文,会自动转换为其他编码方式问题解决