tf.nn.embedding_lookup函数的用法主要是选取一个张量里面索引对应的元素。tf.nn.embedding_lookup(tensor, id):tensor就是输入张量,id就是张量对应的索引,其他的参数不介绍。

例如:

import tensorflow as tf;
import numpy as np; c = np.random.random([10,1])
b = tf.nn.embedding_lookup(c, [1, 3]) with tf.Session() as sess:
sess.run(tf.initialize_all_variables())
print sess.run(b)
print c

  输出:

[[ 0.77505197]
 [ 0.20635818]]
[[ 0.23976515]
 [ 0.77505197]
 [ 0.08798201]
 [ 0.20635818]
 [ 0.37183035]
 [ 0.24753178]
 [ 0.17718483]
 [ 0.38533808]
 [ 0.93345168]
 [ 0.02634772]]

分析:输出为张量的第一和第三个元素。

【TensorFlow】tf.nn.embedding_lookup函数的用法的更多相关文章

  1. tf.nn.embedding_lookup函数的用法

    关于np.random.RandomState.np.random.rand.np.random.random.np.random_sample参考https://blog.csdn.net/lanc ...

  2. 对 tensorflow 中 tf.nn.embedding_lookup 函数的解释

    http://stackoverflow.com/questions/34870614/what-does-tf-nn-embedding-lookup-function-do embedding_l ...

  3. tf.nn.embedding_lookup函数

    tf.nn.embedding_lookup(params, ids, partition_strategy='mod', name=None, validate_indices=True, max_ ...

  4. tf.nn.embedding_lookup函数【转载】

    转自:https://www.cnblogs.com/gaofighting/p/9625868.html //里边有两个很好理解的例子. tf.nn.embedding_lookup(params, ...

  5. tf.nn.embedding_lookup()的用法

    函数: tf.nn.embedding_lookup( params, ids, partition_strategy='mod', name=None, validate_indices=True, ...

  6. tf.nn.embedding_lookup TensorFlow embedding_lookup 函数最简单实例

    tf.nn.embedding_lookup TensorFlow embedding_lookup 函数最简单实例 #!/usr/bin/env python # -*- coding: utf-8 ...

  7. tensorflow.nn.bidirectional_dynamic_rnn()函数的用法

    在分析Attention-over-attention源码过程中,对于tensorflow.nn.bidirectional_dynamic_rnn()函数的总结: 首先来看一下,函数: def bi ...

  8. Tensorflow BatchNormalization详解:4_使用tf.nn.batch_normalization函数实现Batch Normalization操作

    使用tf.nn.batch_normalization函数实现Batch Normalization操作 觉得有用的话,欢迎一起讨论相互学习~Follow Me 参考文献 吴恩达deeplearnin ...

  9. 深度学习原理与框架-CNN在文本分类的应用 1.tf.nn.embedding_lookup(根据索引数据从数据中取出数据) 2.saver.restore(加载sess参数)

    1. tf.nn.embedding_lookup(W, X) W的维度为[len(vocabulary_list), 128], X的维度为[?, 8],组合后的维度为[?, 8, 128] 代码说 ...

随机推荐

  1. MATLAB R2018a 输入中文却显示方框问号的问题

    [问题] 安装完成软件后,我把编辑区字体重设为 consolas : 就会出现 输入中文注释却没办法正常显示的问题: [解决办法] 把字体改成 Monospaced (查了一下 说是MATLAB默认字 ...

  2. php.ini 中文版

    作者:金步国 版权声明 本文作者是一位开源理念的坚定支持者,所以本文虽然不是软件,但是遵照开源的精神发布. 无担保:本文作者不保证作品内容准确无误,亦不承担任何由于使用此文档所导致的损失. 自由使用: ...

  3. dataset string dataset

    DataSet ds = new DataSet(); ds.ReadXml(dataFile); Console.WriteLine(data.Length); string dataxml = d ...

  4. Mac Apache Maven 配置

    1.配置准备工作 1)配置 Maven 准备工作 下载相关软件 apache-maven-3.5.3.zip Maven 官网 Maven for Mac 配置软件下载地址,密码:q9u3. Mave ...

  5. eclipse导入class文件

    右键src文件夹->build path->config build path->library->add class folder->create new folder ...

  6. CentOS 7.4 使用源码包编译安装MySQL 5.7.20

    使用yum安装的MySQL一般版本比较旧,但是运行稳定.如果想要尝试最新的功能或者需要指定特殊的功能的话,就需要手工进行编译安装了. 一.下载安装包 (一).先下载MySQL源码,网址为:https: ...

  7. Ubuntu 13.04 VirtualBox在工作区中的切换

    Ubuntu的工作区很方便,可以有好几个工作区,本人自从换了Ubuntu深感Ubuntu在应用软件上的缺失(当然显然这不是Ubuntu的错).为了弥补缺失,我只能安装了Virtualbox虚拟机,里边 ...

  8. Java 8 Stream – Read a file line by line

    In Java 8, you can use Files.lines to read file as Stream. c://lines.txt – A simple text file for te ...

  9. pm2 设置开机启动

    一.官方文档: 官方相关文档:http://pm2.keymetrics.io/docs/usage/startup/#generating-a-startup-script 二.具体操作过程如下: ...

  10. databus编译:Could not resolve all dependencies for configuration ':databus2-relay:databus2-event-producer-mock:compile

    FAILURE: Build failed with an exception. * What went wrong: Could not resolve all dependencies for c ...