TENSOR
luoganttcc
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Python numpy.transpose 详解
矩阵转置的本质是坐标轴的互换 原文链接原创 2020-10-19 21:08:10 · 390 阅读 · 0 评论 -
keras 自定义层 2
本质就是矩阵相乘 Amn *Bnp 这里会提取输入矩阵最后一层的dim 比如说是Amn的n import keras import tensorflow as tf class Linear(keras.layers.Layer): def __init__(self, units=32): super(Linear, self).__init__() self.units = units def build(self, input_shape): .原创 2020-10-16 16:39:46 · 439 阅读 · 1 评论 -
tf.reduce_sum 用法
import tensorflow as tf # x has a shape of (2, 3) (two rows and three columns): x = tf.constant([[1, 1, 1], [1, 1, 1]]) x.numpy() array([[1, 1, 1], [1, 1, 1]], dtype=int32) # sum all the elements # 1 + 1 + 1 + 1 + 1+ 1 = 6 tf.reduce_sum(x).numpy()原创 2020-10-15 20:24:59 · 558 阅读 · 0 评论 -
tf.lookup 说白了就是tf 的字典
tf 1.x import tensorflow as tf keys_tensor = tf.constant([1, 2]) vals_tensor = tf.constant([3, 4]) input_tensor = tf.constant([1, 5]) table = tf.lookup.StaticHashTable( tf.lookup.KeyValueTensorInitializer(keys_tensor, vals_tensor), -1) out = table.loo原创 2020-07-13 21:13:59 · 2098 阅读 · 0 评论 -
tf.nn.embedding_lookup函数的用法
tf.nn.embedding_lookup函数的用法主要是选取一个张量里面索引对应的元素。tf.nn.embedding_lookup(params, ids):params可以是张量也可以是数组等,id就是对应的索引 ids只有一行: p=tf.Variable(tf.random_normal([10,1]))#生成10*1的张量 b = tf.nn.embedding_lookup(p, [1, 3])#查找张量中的序号为1和3的 with tf.Session() as sess: s转载 2020-05-22 16:49:13 · 678 阅读 · 0 评论 -
tf.reshape 和 tf.transpose 用法
import tensorflow as tf x= tf.constant( [[2,3],[4,5],[6,7]], tf.int32) print(x.numpy()) [[2 3] [4 5] [6 7]] x1=tf.reshape(x, shape = (tf.shape(x)[1], tf.shape(x)[0])) print(x1.numpy()) [[2 3 4] [5 6 7]]原创 2020-05-19 16:29:59 · 585 阅读 · 0 评论 -
tensorflow 制定 CPU 或GPU
CPU with tf.Session() as sess: ...: with tf.device("/cpu:0"): ...: m1=tf.constant([[3,3]]) ...: m2=tf.constant([[2],[2]]) ...: product=tf.matmul(m1,m2) ...原创 2018-10-01 10:17:01 · 407 阅读 · 0 评论 -
tf.nn.conv2d 与tf.layers.conv2d的区别
1. tf.nn.conv2d tf.nn.conv2d(input, # 张量输入 filter, # 卷积核参数 strides, # 步长参数 padding, # 卷积方式 use_cudnn_on_gpu=None, # 是否是gpu加速 data_format=None, # 数据格式,与步长参数配合,决定移动方式 ...原创 2019-06-20 14:55:41 · 7510 阅读 · 0 评论 -
tf.layers
添加链接描述原创 2019-06-20 11:29:33 · 596 阅读 · 0 评论 -
tensorflow pooling
import tensorflow as tf temp = [0., 0., 1., 0., 0., 0., 1.5, 2.5] # Reshape the tensor to be 3 dimensions. values = tf.reshape(temp, [1, 8, 1]) # Use an averaging pool on the tensor. p_avg = tf.nn...原创 2018-10-02 08:35:41 · 912 阅读 · 0 评论 -
tensorflow max_pooling
max pooling是CNN当中的最大值池化操作,其实用法和卷积很类似 有些地方可以从卷积去参考【TensorFlow】tf.nn.conv2d是怎样实现卷积的? tf.nn.max_pool(value, ksize, strides, padding, name=None) 参数是四个,和卷积很类似: 第一个参数value:需要池化的输入,一般池化层接在卷积层后面,所以输入通常是featur...原创 2018-10-01 21:31:59 · 1465 阅读 · 0 评论 -
tensorflow padd
链接转载 2018-10-01 20:53:30 · 409 阅读 · 0 评论 -
tensorflow fetch 取回某个值
为了取回操作的输出内容, 可以在使用 Session 对象的 run() 调用 执行图时, 传入一些 tensor, 这些 tensor 会帮助你取回结果. 在之前的例子里, 我们只取回了单个节点 state, 但是你也可以取回多个 tensor: import tensorflow as tf input1 = tf.constant(3.0) input2 = tf.constant(2.0)...原创 2018-10-01 10:45:37 · 766 阅读 · 0 评论 -
tensorflow 入门实例(二)
import tensorflow as tf # 创建一个常量 op, 产生一个 1x2 矩阵. 这个 op 被作为一个节点 # 加到默认图中. # # 构造器的返回值代表该常量 op 的返回值. matrix1 = tf.constant([[3., 3.]]) # 创建另外一个常量 op, 产生一个 2x1 矩阵. matrix2 = tf.constant([[2.],[2.]]) ...原创 2018-10-01 10:34:43 · 517 阅读 · 0 评论 -
TensorFlow 莫烦 手写识别 cross_entry (五)
# -*- coding: utf-8 -*- """ Created on Thu Apr 20 15:40:48 2017 同济大学 土木大楼B406 @author: Administrator """from __future__ import print_function import tensorflow as tffrom tensorflow.examples.tutorials.m转载 2017-04-20 16:59:30 · 1853 阅读 · 0 评论 -
tensorflow 最小二乘拟合详细代码注释
#程序 不是我写的,注释是我做的,转载请注明“lg土木设计” #最小二乘法拟合,用y=ax+b a=weight b=biases from __future__ import print_function import tensorflow as tf import numpy as np # create data 生成100个0-1之间的随机数 np.random.rand(10...原创 2017-02-22 11:18:22 · 1833 阅读 · 0 评论 -
tensorflow 入门经典实例
import tensorflow as tf #发起会话 sess = tf.Session() #两行都可以执行 具体意思见下方注释 A = tf.Variable(tf.truncated_normal([2,3],0,1,dtype=tf.float32,seed=3)) #A = tf.Variable(tf.random_uniform([3,4], 1, 10)) #变量初始化 s...原创 2017-02-21 12:56:34 · 1063 阅读 · 0 评论 -
图像识别 43个模型
43个模型原创 2017-03-31 20:48:59 · 3148 阅读 · 0 评论 -
TensorFlow 莫烦视频学习笔记例子二(一)
注释链接所有代码# -*- coding: utf-8 -*- """ Created on Wed Apr 19 12:30:49 2017@author: lg同济大学B406 """import tensorflow as tf import numpy as npx_data=np.random.rand(100).astype(np.float32) y_data=x_data*0.1+0转载 2017-04-19 13:08:52 · 4398 阅读 · 0 评论 -
tensorflow 莫烦视频学习笔记 变量 (二)
import tensorflow as tfstate=tf.Variable(0,name='counter')one=tf.constant(1)new_value=tf.add(state,one)update=tf.assign(state,new_value)init=tf.initialize_all_variables()with tf.Session() as sess:转载 2017-04-19 13:37:38 · 992 阅读 · 0 评论 -
TensorFlow莫烦 placehoder (三)
placeholder 传入值要用字典 并且tf.mul、tf.sub 和 tf.neg 被弃用,现在使用的是 tf.multiply、tf.subtract 和 tf.negative. import tensorflow as tf input1=tf.placeholder(tf.float32) input2=tf.placeholder(tf.float32) outpu...原创 2017-04-19 14:11:02 · 1124 阅读 · 0 评论 -
TensorFlow 最小二乘法拟合
#程序 不是我写的,注释是我做的,转载请注明“lg土木设计” #最小二乘法拟合,用y=ax+b a=weight b=biases from __future__ import print_function import tensorflow as tf import numpy as np # create data 生成100个0-1之间的随机数 np.random.rand(100) 1原创 2017-04-19 14:13:17 · 3781 阅读 · 0 评论 -
tensorflow 莫烦 二次函数弥拟合(四)
# -*- coding: utf-8 -*- """ Created on Wed Apr 19 22:24:49 2017@author: user """ import tensorflow as tf import numpy as np def add_layer(inputs,in_size,out_size,activation_function=None): Weights=t转载 2017-04-20 08:51:02 · 2383 阅读 · 0 评论 -
tensorflow random的用法
np.random.rand (,) np.random.rand 表示随机数为0-1之间 np.random.rand(100) #1*100的矩阵 # 生成100个0-1之间的随机数 其每个元素为0-1的随机数 #np.random.rand(3,3) 3*3的矩阵,其每个元素为0-1的随机数 np.random.uniform([5], 1, 10)原创 2017-02-22 11:21:53 · 3941 阅读 · 1 评论 -
CNN卷积神经网络的相关文章
这篇关于卷积与池化讲的比较好这篇也不错哦转载 2017-04-21 12:47:20 · 717 阅读 · 0 评论 -
tf.argmax
tf.argmax(input, axis=None, name=None, dimension=None) 此函数是对矩阵按行或列计算最大值 参数 input:输入Tensor axis:0表示按列,1表示按行 name:名称 dimension:和axis功能一样,默认axis取值优先。新加的字段 返回:Tensor 一般是行或列的最大值下标import tensorflow a原创 2017-04-21 14:35:28 · 3117 阅读 · 0 评论 -
tf.reduce_mean
import numpy as np import tensorflow as tfx = np.array([[1.,2.,3.],[4.,5.,6.]]) sess = tf.Session()mean1 = sess.run(tf.reduce_mean(x)) mean2 = sess.run(tf.reduce_mean(x, 0)) mean3 = sess.run(tf.reduce_原创 2017-04-21 14:51:38 · 1827 阅读 · 0 评论 -
tf.cast
cast(x, dtype, name=None) 将x的数据格式转化成dtype.例如,原来x的数据格式是bool, 那么将其转化成float以后,就能够将其转化成0和1的序列。反之也可以 a = tf.Variable([1,0,0,1,1]) b = tf.cast(a,dtype=tf.bool) sess = tf.Session() sess.run(tf.initiali...原创 2017-04-21 15:02:56 · 43144 阅读 · 0 评论 -
tensorflow 的模型保存和调用
我们通常采用tensorflow来训练,训练完之后应当保存模型,即保存模型的记忆(权重和偏置),这样就可以来进行人脸识别或语音识别了。 1.模型的保存# 声明两个变量 v1 = tf.Variable(tf.random_normal([1, 2]), name="v1") v2 = tf.Variable(tf.random_normal([2, 3]), name="v2") init_op原创 2017-04-22 08:30:19 · 5893 阅读 · 0 评论 -
CNN 卷积神经网络TensorFlow简单实现
原文链接 #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Mar 15 21:49:08 2018 @author: luogan """ import tensorflow as tf from sklearn.datasets import load_digits import numpy as np...转载 2018-03-15 23:04:06 · 788 阅读 · 0 评论 -
tf.sesson
import tensorflow as tf #导入tensorflow a=tf.constant([[1,2]]) #定义了一个1×2的矩阵 b=tf.constant([[2], [4]]) #定义了一个2×1的矩阵 c=tf.matmul(a,b) #两者相乘赋给c节点 #两种方式执行session,第一种比较直观,但比较麻烦...转载 2018-06-28 22:59:25 · 218 阅读 · 0 评论
分享