TensorFlow入门基础知识(四)tf.sparse_to_dense的用法
2018-03-26 20:31
2646 查看
先贴一下别人怎么说的
https://blog.csdn.net/mao_xiao_feng/article/details/53365889
再贴一下自己的实验
实验结果
https://blog.csdn.net/mao_xiao_feng/article/details/53365889
再贴一下自己的实验
import tensorflow as tf import numpy as np v1 = tf.reshape(tf.range(10),[10,1]) v2 = tf.reshape(tf.range(0,10),[10,1]) v3 = tf.concat(1,[v1,v2]) dense_labels = tf.sparse_to_dense(v3, [10, 12], 1.0, 0.0) init_op = tf.global_variables_initializer() with tf.Session() as sess: sess.run(init_op) print(sess.run(v1)) print(sess.run(v2)) print(sess.run(v3)) print(sess.run(dense_labels))
实验结果
[[0] [1] [2] [3] [4] [5] [6] [7] [8] [9]] [[0] [1] [2] [3] [4] [5] [6] [7] [8] [9]] [[0 0] [1 1] [2 2] [3 3] [4 4] [5 5] [6 6] [7 7] [8 8] [9 9]] [[1. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.] [0. 1. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.] [0. 0. 1. 0. 0. 0. 0. 0. 0. 0. 0. 0.] [0. 0. 0. 1. 0. 0. 0. 0. 0. 0. 0. 0.] [0. 0. 0. 0. 1. 0. 0. 0. 0. 0. 0. 0.] [0. 0. 0. 0. 0. 1. 0. 0. 0. 0. 0. 0.] [0. 0. 0. 0. 0. 0. 1. 0. 0. 0. 0. 0.] [0. 0. 0. 0. 0. 0. 0. 1. 0. 0. 0. 0.] [0. 0. 0. 0. 0. 0. 0. 0. 1. 0. 0. 0.] [0. 0. 0. 0. 0. 0. 0. 0. 0. 1. 0. 0.]]
相关文章推荐
- TensorFlow入门基础知识(六)tf.train.ExponentialMovingAverage()的用法
- TensorFlow 官方文档中文版解读之2——tf.sparse_to_dense的用法
- TensorFlow入门基础知识(七)tf.control_dependencies的用法
- TensorFlow入门基础知识(五)tf.add_n()的用法
- TensorFlow入门基础知识(七)tf.train.exponential_decay的用法
- 【TensorFlow】tf.sparse_to_dense的用法
- tf中的tf.sparse_to_dense的用法
- TensorFlow入门基础知识(三)lrn函数详解
- tensorflow——tf.one_hot以及tf.sparse_to_dense函数
- Tensorflow 的tf.one_hot()功能:dense to one hot
- Tensorflow基础知识与神经网络构建--step by step 入门TensorFlow(一)
- TensorFlow入门深度学习–09.tf.contrib.slim用法详解
- 第一阶段-入门详细图文讲解tensorflow1.4 -(三)TensorFlow 编程基础知识
- TensorFlow入门基础知识(二)TensorBoard可视化助手相关函数
- tf.sparse_to_dense()
- TensorFlow基础用法入门教程
- TensorFlow入门深度学习--01.基础知识
- Windows API-GDI入门基础知识详解 来源: PConline.com.cn
- MySQL入门基础知识简介
- 【广告算法工程师入门 15】机制设计-基础知识