在TensorFlow Core中,有一个名为tf.math.scalar_mul的操作。
我想在TensorFlow.js中缩放张量。例如,通过尝试a * 0.1,我得到了一条错误消息(至少来自类型记录):The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.ts(2362)。
缩放张量是否适用,而不使它们按数组排列,然后将其按元素比例转换回张量?
假设我有以下张量:
X = np.zeros((3,201, 340))
Y = np.zeros((340, 28))
用numpy成功地制作X,Y的点积,并产生形状(3,201,28)的张量。然而,使用tensorflow时,我得到了以下错误:Shape must be rank 2 but is rank 3 error ...
最小代码示例:
X = np.zeros((3,201, 340))
Y = np.zeros((340, 28))
print(np.dot(X,Y).shape) # successful (3, 201, 28)
tf.matmul(X, Y) # err
我正在重新实现,关键操作是双线性张量积。我几乎不知道这是什么意思,但这篇论文有一个很好的小图形,我理解它。
关键操作是e_1 *W* e_2,我想知道如何在tensorflow中实现它,因为剩下的应该很容易。
基本上,给定3D张量W,将其切片为矩阵,对于第j个切片(矩阵),将其每边乘以e_1和e_2,得到一个标量,这是结果向量(此操作的输出)中的第j个条目。
所以我想计算d维向量e_1,d x d x k张量,W,和另一个d维向量e_2的乘积。这个产品可以像现在一样用TensorFlow简洁地表达吗,或者我必须以某种方式定义我自己的操作?
早先编辑了
为什么这些张量相乘不起作用,有没
我从tensorflow开始,当涉及到张量的级别以及它们如何相互作用时,我有一个很大的问题。
我随身携带了以下代码:
w = tf.Variable(tf.constant([0.2,0.6]))
x = tf.placeholder(tf.float32)
y = w * x
如您所见,这是一个非常简单的设置。
但是,当我执行print w时,输出是Tensor("Variable_13/read:0", shape=(2,), dtype=float32)。
shape(2,)是什么意思?逗号表示什么?
此外,以下是在sess = tf.Session()和初
我正在尝试使用Swift for Tensorflow API,但我找不到一种方法来创建具有随机正常初始化的张量。 目前我正在从numpy获取一个数组来构造一个张量结构: let np = Python.import("numpy")
let w_np = np.random.randn(10, 10).astype(np.float32)
let w = Tensor<Float32>(numpy: w_np)! 有没有Swift for Tensorflow获取随机数组的纯方法?
我想看看下面由keras的输入类给出的tensorflow张量的内容
from keras.layers import Input
sequence_input = Input(shape=(128,), dtype='int32')
# How to see the content of sequence input
sequence_input
import tensorflow.compat.v1 as tf
with tf.Session() as sess:
print(sequence_input.eval())
Exception ignored in:
稀疏张量与自身或稠密张量的乘法在TensorFlow中似乎不起作用。下面的示例
from __future__ import print_function
import tensorflow as tf
x = tf.constant([[1.0,2.0],
[3.0,4.0]])
y = tf.SparseTensor(indices=[[0,0],[1,1]], values=[1.0,1.0], shape=[2,2])
z = tf.matmul(x,y)
sess = tf.Session()
sess.run(tf.initialize_all
我正在设计一个带点云的神经网络模型。对于n点数输入,我使用NN模型来获得每个点数的分数。我使用分数来决定哪些k点需要保留,哪些需要丢弃。因为有了梯度支持,我不能简单地扔掉那些低分的点,我需要使用一个掩模来设置它们相应的位置0。那么,我如何在TensorFlow中定义该掩码呢?
我尝试使用mask = tf.ones((batch_size, num_point))将掩码定义为张量,但无法将其值更改为'Tensor' object does not support item assignment。
这是我的部分代码,
score_index = tf.argsort(score,
我正在学习的tensorflow急切的执行。当我尝试单元格"GPU使用“(参见下面)时,出现了一个错误,即变量没有放在GPU上。
import tensorflow as tf
import tensorflow.contrib.eager as tfe
tf.enable_eager_execution()
A = tf.constant([[2.0, 0.0], [0.0, 3.0]])
if tf.test.is_gpu_available() > 0:
with tf.device(tf.test.gpu_device_name()):
print
我是tensorflow的新手,我想把一个正伽玛函数应用到一个现有的张量上。当我试着这个
from scipy.special import gamma
gamma_t = K.map_fn(lambda x:gamma(1.0 + 1.0 / x) ,b)
其中b是我得到的现有张量。
TypeError: ufunc 'gamma' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casti
当我尝试通过pip install安装张量流1.4.0时 pip install tensorflow==1.4.0 我得到了错误: ERROR: Could not find a version that satisfies the requirement tensorflow==1.4.0 (from
versions: 2.5.0rc0, 2.5.0rc1, 2.5.0rc2, 2.5.0rc3, 2.5.0, 2.6.0rc0)
ERROR: No matching distribution found for tensorflow==1.4.0 如何在mac上安装张量流1.4.0