Turns positive integers(indexes) into dense vectors of fixed size.

e.g. [[4], [20]] -> [[0.25, 0.1], [0.6, -0.2]]

This layer can only be used on positive integer inputs of a fixed range. The tf.keras.layers.TextVectorization, tf.keras.layers.StringLookup, and tf.keras.layers.IntegerLookup preprocessing layers can help prepare inputs for an Embedding layer.

This layer accepts tf.Tensor, tf.RaggedTensor and tf.SparseTensor input.

Inherits From: [Layer](https://tensorflow.google.cn/api_docs/python/tf/keras/layers/Layer), [Module](https://tensorflow.google.cn/api_docs/python/tf/Module)

tf.keras.layers.Embedding(
input_dim,
output_dim,
embeddings_initializer='uniform',
embeddings_regularizer=None,
activity_regularizer=None,
embeddings_constraint=None,
mask_zero=False,
input_length=None,
sparse=False,
**kwargs
)

Used in the notebooks

Example:

model = tf.keras.Sequential()
model.add(tf.keras.layers.Embedding(1000, 64, input_length=10))
# The model will take as input an integer matrix of size (batch,
# input_length), and the largest integer (i.e. word index) in the input
# should be no larger than 999 (vocabulary size).
# Now model.output_shape is (None, 10, 64), where `None` is the batch
# dimension.
input_array = np.random.randint(1000, size=(32, 10))
model.compile('rmsprop', 'mse')
output_array = model.predict(input_array)
print(output_array.shape)

tf.keras.layers.Embedding + tf.keras.layers.TextVectorization + tf.keras.layers.StringLookup + tf.keras.layers.IntegerLookup的更多相关文章

  1. 深度学习原理与框架-Tensorboard可视化展示(代码) 1.tf.reuse_default_graph(进行结构图的重置) 2.tf.summary.FileWriter(writer实例化) 3. write.add_graph(graph的写入) 4. tf.summary.merge_all(将summary进行合并) 5.write.add_summary(将所有summary)

    1. tf.reuse_default_graph() # 对graph结构图进行清除和重置操作 2.tf.summary.FileWriter(path)构造writer实例化,以便进行后续的gra ...

  2. keras的Embedding层

    keras.layers.embeddings.Embedding(input_dim, output_dim, embeddings_initializer='uniform', embedding ...

  3. 深度学习原理与框架-Tfrecord数据集的制作 1.tf.train.Examples(数据转换为二进制) 3.tf.image.encode_jpeg(解码图片加码成jpeg) 4.tf.train.Coordinator(构建多线程通道) 5.threading.Thread(建立单线程) 6.tf.python_io.TFR(TFR读入器)

    1. 配套使用: tf.train.Examples将数据转换为二进制,提升IO效率和方便管理 对于int类型 : tf.train.Examples(features=tf.train.Featur ...

  4. tensorflow 笔记13:了解机器翻译,google NMT,Attention

    一.关于Attention,关于NMT 未完待续... 以google 的 nmt 代码引入 探讨下端到端: 项目地址:https://github.com/tensorflow/nmt 机器翻译算是 ...

  5. tensorflow文本分类实战——卷积神经网络CNN

    首先说明使用的工具和环境:python3.6.8   tensorflow1.14.0   centos7.0(最好用Ubuntu) 关于环境的搭建只做简单说明,我这边是使用pip搭建了python的 ...

  6. Sentiment analysis in nlp

    Sentiment analysis in nlp The goal of the program is to analysis the article title is Sarcasm or not ...

  7. TensorFlow v2.0实现Word2Vec算法

    使用TensorFlow v2.0实现Word2Vec算法计算单词的向量表示,这个例子是使用一小部分维基百科文章来训练的. 更多信息请查看论文: Mikolov, Tomas et al. " ...

  8. Keras(七)Keras.layers各种层介绍

    一.网络层 keras的层主要包括: 常用层(Core).卷积层(Convolutional).池化层(Pooling).局部连接层.递归层(Recurrent).嵌入层( Embedding).高级 ...

  9. tf.keras遇见的坑:Output tensors to a Model must be the output of a TensorFlow `Layer`

    经过网上查找,找到了问题所在:在使用keras编程模式是,中间插入了tf.reshape()方法便遇到此问题. 解决办法:对于遇到相同问题的任何人,可以使用keras的Lambda层来包装张量流操作, ...

  10. Tensorflow1.4 高级接口使用(estimator, data, keras, layers)

    TensorFlow 高级接口使用简介(estimator, keras, data, experiment) TensorFlow 1.4正式添加了keras和data作为其核心代码(从contri ...

随机推荐

  1. jdbc写一个访问数据库的工具类

    操作的工具类 package com.zjw.jdbc2; /** * jdbc操作的工具类 * @author Administrator * */ import java.sql.Connecti ...

  2. 【经验】CiteSpace|Wiley Online Library或除知网以外的其他网站的文献怎么导入CiteSpace 6.1.6?

      如果没安装,请看这篇博客安装,现在新版(6.1.6)的不需要额外下载java了,就很妙~:   最新版citespace软件的安装与配置   结论:导出成RIS然后用它自带的转换成WoS. 文章目 ...

  3. 【BUG】Message = “无法加载一个或多个请求的类型。有关更多信息,请检索 LoaderExceptions 属性。“, StackTrace = “ 在 System.Reflection.

    环境: Visual Studio 2019 C#项目遇到这种情况时,是因为有多个依赖出了问题(也可能是只有一个但被误报成多个),此时点开"查看详细信息",可以快速监视Except ...

  4. P11071 「QMSOI R1」 Distorted Fate题解

    题意: 给定一个序列,给定两种操作: 将一个区间异或上一个给定的值. 给定 \(l,r\) 求 \[{\large (\sum_{i=l}^r\bigcup_{j=l}^i A_j) \bmod 2^ ...

  5. python库使用总结

    python库的使用 1:print(补充) 2:math 2.1:math库包括的4个数学常数 2.2math库中的函数 幂对数函数 三角曲线函数 3:字符串处理函数 补充:sorted(str) ...

  6. Flask之初始

    一.简介 Flask是一个基于Python实现的Web开发'微'框架 官方文档: http://flask.pocoo.org/docs/0.12/中文文档: http://docs.jinkan.o ...

  7. 化学数据分析AI实验室?ChatMoney帮你打造

    本文由 ChatMoney团队出品 AI确实是个好东西,但AI到底是有什么用?其实很多人都没搞明白.AI如果在某个行业用的好,是能带来很大经济价值的.就拿AI在化学应用来说,AI在化工领域上的应用和化 ...

  8. 重剑无锋,大巧不工 —— OceanBase 中的 Nest Loop Join 使用技巧分享

    首先为大家推荐这个 OceanBase 开源负责人老纪的公众号 "老纪的技术唠嗑局",会持续更新和 OceanBase 相关的各种技术内容.欢迎感兴趣的朋友们关注! 玄铁剑一送即收 ...

  9. 历时半年,我将一个大型asp.net的零代码快速开发平台转成了java

    老的博客园朋友应该清楚,我在10年前开发了一个基于asp.net的大型开发平台,其中作为开源项目的SilverLight流程设计器也获得了当年的微软开发大奖.时过境迁,当年的设计器早就在技术的更新换代 ...

  10. 【渗透测试】不怎么水的洞之IP伪造

    漏洞原理 有些应用程序有记录用户IP的功能或者限制IP白名单的功能,如果应用程序从请求头字段获取用户IP,可能会被攻击者伪造,来达到欺骗服务器的目的. 案例一 发现操作日志页面有个记录用户IP功能 插 ...