- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个现有的复杂模型。里面有一个张量x
,形状为(None, 128, 128, 3)。第一个轴具有动态形状,当批处理传递到 session.run
中的 feed_dict
时,应该具体化。但是,当我尝试将广播操作定义为 x 的形状时:
y = tf.broadcast_to(z, (x.shape[0], x.shape[1], x.shape[2], 1))
引发异常:
Failed to convert object of type <class 'tuple'> to
Tensor. Contents: (Dimension(None), Dimension(128),
Dimension(128), 1). Consider casting elements to a supported type.
创建模型时发生异常,而不是运行模型时发生异常。将第一个元素转换为数字会有所帮助,但这不是解决方案。
最佳答案
.shape
属性为您提供图形构建时已知的形状,即 tf.TensorShape
结构。如果 x
的形状完全已知,您可以让代码按如下方式工作:
y = tf.broadcast_to(z, (x.shape[0].value, x.shape[1].value, x.shape[2].value, 1))
但是,在您的情况下,x
的第一维未知。为了使用实际的张量形状作为常规tf.Tensor
(只有在运行时才知道值),您可以使用 tf.shape
:
x_shape = tf.shape(x)
y = tf.broadcast_to(z, (x_shape[0], x_shape[1], x_shape[2], 1))
关于python - 为什么 tensorflow 可能想要指定动态维度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55145714/
我想使用批处理从文件夹中读取图像。但是解码后,当我使用tf.train.batch时可能会出现一些问题。这是代码。 def get_batch(image, label, batch_size, ca
我正在使用 tf.unsorted_segment_sum TensorFlow 的方法,当我作为数据给出的张量只有一行时,它工作正常。例如: tf.unsorted_segment_sum(tf.c
我想创建一个正则表达式来检查有效维度JavaScript 中的长度 x 宽度 x 高度。 例如90.49 x 34.93 x 40.64 我打算使用的示例代码: var dimensionRegex
ViewPager 是否必须是 Activity 布局中唯一存在的对象?我正在尝试实现这样的东西: 我应该在什么地方有一个大的寻呼机在顶部滚动(我有)和一个较小的画廊在它下面滚动。这只向我显示寻
据我所知,(维度、维度属性和事实)差异的最佳示例如下所示: 维度 - 产品、帐户、客户 维度属性 - ProductName、ProductNumber、CustomerName、CustomerNu
我是 Numpy 的新手,正在尝试理解什么是维度的基本问题, 我尝试了以下命令并试图理解为什么最后两个数组的 ndim 相同? >>> a= array([1,2,3]) >>> a.ndim 1 >
我对 MDX 比较陌生,正在尝试完成我认为应该很容易的事情,但我还没有找到任何解决方案。 我有一个销售立方体,其中一个衡量标准是利润,它可以是负数也可以是正数。我想得到一个有效的正利润总和的度量,即只
在大多数情况下,维度内层次结构的每个级别代表不同的概念(即国家->地区->城市、年->月->日),这很简单,可以在多维数据集中使用。 我感兴趣的是可变深度层次结构,它往往由相同概念的实例组成,即计算机
我正在尝试创建一个方法来总结潜在的项目并从数组返回该总和。以下是一些预期的示例输入: arraySum(new int[10]); // 10 arraySum(new int[2][5]); //
我正在尝试初始化一个二维数组(我创建的类对象),但我仍然遇到相同的运行时错误: Exception in thread "main" java.lang.NullPoointerException
(我是一名学生,这是我第一次发帖,所以请放轻松。)我想创建一个将二维数组作为参数的函数,并且在该数组中,我想要一个变量,稍后我想在代码中对其进行修改。这是最接近我想要的例子的东西: int size;
我想我可能会问一个虚拟问题,但我对 Android 编程还是个新手,而且我无法(尽管我付出了所有努力)在 Google 上找到我的答案。 问题是,我正在尝试使用 2D 图形开发一个小游戏。我希望我的“
如何使用 Crossfilter 过滤一系列日期?当我知道该时间段之间存在事实记录时,以下内容不起作用。 Var myDimension = CrossFilterObj.dimension(func
我正在启动另一个应用程序并设置其主要 HWND 位置和大小。我正在使用 STARTUPINFO指定窗口尺寸的标志,但看起来只有在新进程使用 CW_USEDEFAULT 时才会遵循这些尺寸在其 Crea
我正在尝试使用 Keras 构建我的第一个神经网络。我的经验为零,我似乎无法弄清楚为什么我的维度不对。我无法从他们的文档中弄清楚这个错误在提示什么,甚至是什么层导致了它。 我的模型接受一个 32 字节
我有一个水平导航栏,我的 a 元素没有扩展到父 li 元素的宽度和高度。 如何修改我的 CSS,使 a 元素与外部/父级 li 元素一样宽和高?
如何只更改需要 Dimension 对象的组件的宽度或高度?目前我是这样做的: jbutton.setPreferredSize(new Dimension(button.getPreferredSi
哪些 OLAP 工具支持动态、动态地创建维度或层次结构? 例如,层次结构将成员定义为:“前 5 名”、“前 6-10 名”、“其他”... 计算成员是通常的答案,我正在寻找不同的东西。计算器的问题。成
我使用 1 个 div 元素为我的网站制作 .background 。它的高度将是 100%。为了实现这一点,我使用 jQuery 尺寸实用程序。 用这个脚本来获取高度 $('.background
MultiArray与使用 std::vector 创建多数组相比,在 boost 中有很多优势。但是,我对 BOOST 中的 MultiArray 感到不舒服的一件事是创建一个可以轻松更改其大小的多
我是一名优秀的程序员,十分优秀!