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. .net core 使用redis

    参照: .NET 6使用Redis - Lulus - 博客园 (cnblogs.com) 九..net core(.NET 6)添加通用的Redis功能 - WeskyNet - 博客园 (cnbl ...

  2. 通过PHP实现获取访问用户IP

    在php中自带了一个非常的简单的获取IP地址的全局变量,很多初学都获取IP都使用它了,但是对于这些我们一般用法是满足了,但是对于要求高精度这个函数还是不行的. 这个是最简单的方法,对于开了透明代理之类 ...

  3. JAVA安全之JDK8u141版本绕过研究

    基本介绍 从JDK8u141开始JEP290中针对RegistryImpl_Skel#dispatch中bind.unbind.rebind操作增加了checkAccess检查,此项检查只允许来源为本 ...

  4. <HarmonyOS第一课13>给应用添加通知和提醒 #鸿蒙课程##鸿蒙生态#

    课程介绍 <HarmonyOS第一课:给应用添加通知和提醒>将引导开发者如何在HarmonyOS应用中实现通知功能.课程首先介绍如何为您的应用添加基础类型通知,包括普通文本.多行文本和图片 ...

  5. vue3 基础-传送门 teleport

    之前介绍了一波混入 mixin 和 自定义指令 directive 其基本作用就是为了在 vue 中实现代码的复用. 而本篇介绍的是 vue3 的一个新特性叫做传送门. 一听这个名字是不是就感觉特别科 ...

  6. CUDA:页锁定内存(pinned memory)和按页分配内存(pageable memory )

    CUDA架构而言,主机端的内存分为两种,一种是可分页内存(pageable memroy), 一种是页锁定内存(page-lock或 pinned). 可分页内存是由操作系统API malloc()在 ...

  7. pytorch中的剪枝操作

    深度学习技术依赖于过参数化模型,这是不利于部署的,相反,生物神经网络是使用高效的稀疏连接的. 通过减少模型中的参数数量来压缩模型的技术非常重要,为减少内存.电池和硬件的消耗,而牺牲准确性,实现在设备上 ...

  8. Pytorch 看起来好像没占gpu的样子的原因

    今天好哥们儿赞助的3080到手了,欣喜若狂的装上 然后跑了跑MNIST,看着任务管理器CPU跑100%,GPU跑3%,查了半天解决不了,郁闷了好一会儿.. 后来在https://www.bilibil ...

  9. C#程序的内存缓存

    C#程序可以使用IMemoryCache.IMemoryCache是.NET Core中内置的一个轻量级缓存实现,可以用于在内存中缓存数据,以提高应用程序的性能和响应速度.它支持通过键值对的方式缓存数 ...

  10. 如何在AutoCAD Electrical中修改项目描述中的行号

    默认情况下,项目描述对话框中都会以行号+数字的形式显示,如下图所示: 1.打开记事本程序,按照以下格式收入文字: LINE1=设计 LINE2=制图 LINE3=校对 LINE4=审核 LINE5=工 ...