TensorFlow:如何通过复制一个张量来连接张量?(TensorFlow: How to concatenate tensors by duplicating one of the tensor?)
我想通过复制一个张量来连接两个张量。 例如,我有两个形状的张量[2,2,3]和[2,3]。 结果应该是[2,2,6]的形式。
t1 = [[[ 1, 1, 1], [2, 2, 2]], [[ 3, 3, 3], [4, 4, 4]]] t2 = [[ 5, 5, 5], [6, 6, 6]] """ t3 = # some tf ops t3 should be t3 = [[[ 1, 1, 1, 5, 5, 5], [2, 2, 2, 5, 5, 5]], [[ 3, 3, 3, 6, 6, 6], [4, 4, 4, 6, 6, 6]]] """
所以如果两个张量的形状[10,5,8和10,3],结果应该是形状[10,5,11]。
更新
另一个例子:
t1 = np.reshape(np.arange(3*4*5), [3,4,5]) t2 = np.reshape(np.arange(3*1*2), [3,2]) """" t3 should be [[[ 0., 1., 2., 3., 4., 0., 1.], [ 5., 6., 7., 8., 9., 0., 1.], [ 10., 11., 12., 13., 14., 0., 1.], [ 15., 16., 17., 18., 19., 0., 1.]], [[ 20., 21., 22., 23., 24., 2., 3.], [ 25., 26., 27., 28., 29., 2., 3.], [ 30., 31., 32., 33., 34., 2., 3.], [ 35., 36., 37., 38., 39., 2., 3.]], [[ 40., 41., 42., 43., 44., 4., 5.], [ 45., 46., 47., 48., 49., 4., 5.], [ 50., 51., 52., 53., 54., 4., 5.], [ 55., 56., 57., 58., 59., 4., 5.]]] """
I would like to concatenate two tensors by duplicating one of the tensor. For example, I have two tensors of shape [2, 2, 3] and [2, 3]. The result should be in the shape of [2, 2, 6].
t1 = [[[ 1, 1, 1], [2, 2, 2]], [[ 3, 3, 3], [4, 4, 4]]] t2 = [[ 5, 5, 5], [6, 6, 6]] """ t3 = # some tf ops t3 should be t3 = [[[ 1, 1, 1, 5, 5, 5], [2, 2, 2, 5, 5, 5]], [[ 3, 3, 3, 6, 6, 6], [4, 4, 4, 6, 6, 6]]] """
So If the two tensors are of shape [10, 5, 8] and [10, 3], the result should be of shape [10, 5, 11].
UPDATED
Another example:
t1 = np.reshape(np.arange(3*4*5), [3,4,5]) t2 = np.reshape(np.arange(3*1*2), [3,2]) """" t3 should be [[[ 0., 1., 2., 3., 4., 0., 1.], [ 5., 6., 7., 8., 9., 0., 1.], [ 10., 11., 12., 13., 14., 0., 1.], [ 15., 16., 17., 18., 19., 0., 1.]], [[ 20., 21., 22., 23., 24., 2., 3.], [ 25., 26., 27., 28., 29., 2., 3.], [ 30., 31., 32., 33., 34., 2., 3.], [ 35., 36., 37., 38., 39., 2., 3.]], [[ 40., 41., 42., 43., 44., 4., 5.], [ 45., 46., 47., 48., 49., 4., 5.], [ 50., 51., 52., 53., 54., 4., 5.], [ 55., 56., 57., 58., 59., 4., 5.]]] """
原文:https://stackoverflow.com/questions/41295168
最满意答案
如果你找不到直接从内存中的图片设置背景的方法,那么将图片从Excel复制/粘贴到PPT演示文稿中的幻灯片母版然后将它们发送到后面,这样他们就会坐在后面。 我认为,从用户的角度来看,效果几乎相同。
If you can't find a way to set the background directly from a picture in memory, what about copy/pasting the picture from Excel into the Slide Master(s) in your PPT presentation then sending them to the back so they sit behind everything. The effect would be nearly identical from the user's point of view, I think.
相关问答
更多-
TCP/IP模型是一个________。[2023-10-02]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
如果你找不到直接从内存中的图片设置背景的方法,那么将图片从Excel复制/粘贴到PPT演示文稿中的幻灯片母版然后将它们发送到后面,这样他们就会坐在后面。 我认为,从用户的角度来看,效果几乎相同。 If you can't find a way to set the background directly from a picture in memory, what about copy/pasting the picture from Excel into the Slide Master(s) in yo ...
-
使用预定义模板将表从Excel复制到Powerpoint(Copying Table from Excel into Powerpoint using a predefined template)[2020-10-31]
使用ExecuteMso方法(没有详细记录,但它非常方便地在应用程序之间粘贴数据等),您应该能够这样做: 这是Excel表格: 以下是PowerPoint的输出: 这假设PPT中的表的大小是正确的列数。 如果不是,您可能需要额外的逻辑来有条件地添加/删除列。 这不会保留Excel中的任何格式,因此它依赖于PowerPoint表/模板中指定的表格样式。 Sub copyTableRowsToPPT() Dim tbl As ListObject Dim tblRows As Range ... -
常见问题。 最近粘贴的形状将始终“在顶部”,因此您可以使用类似的东西来获取它: PPPres.Slides(2).Shapes(PPPres.Slides(2).Shapes.Count) 请注意,通过选择形状和幻灯片,您可以打开自己的奇怪错误并将代码减慢一个数量级。 Dim oSh as Shape With PPPres.Slides(2) ' Do the paste, then get a reference to the pasted shape: Set oSh = PPPres.Sl ...
-
经过一些小小的摆弄和朋友的帮助后,我想我已经拥有了! - 干杯 Sub CopyPicToPPt() Dim pptApp As PowerPoint.Application Dim pptPresent As Presentation Dim sldPPT As Slide Dim shpPic As Shape Dim oLayout As CustomLayout Dim x As PowerPoint.Shape ActiveWorkbook.Sheets("Sheet1").Visible ...
-
这是允许我从excel中在powerpoint中放置图片的代码。 以下代码有效, 此链接也很有用 Dim applPP As PowerPoint.Application, prsntPP As PowerPoint.Presentation, TitlePage As PowerPoint.Slide Set applPP = New PowerPoint.Application applPP.Visible = True Set prsntPP = applPP.Present ...
-
以编程方式从PowerPoint演示文稿中提取嵌入文件(Programmatically extract embedded file from PowerPoint presentation)[2023-01-30]
两者都是可能的。 从PPTX中提取WAV :所有嵌入的媒体都在.pptx \ ppt \ media文件夹中(将.pptx重命名为.zip,解压缩并导航到\ ppt \ media)。 它们通常按照添加和/或处理的顺序依次编号。 叙事,AFAIK,总是嵌入式,永远不会联系在一起。 问题在于确定要提取的确切内容 - 在添加到pptx时,可以通过向其添加标记或其他唯一标识符来注意。 提取它的方法是使用Open XML SDK(或直接使用System.IO.Packaging)并打开当前演示文稿的内存副本,在文件 ... -
将图表从Excel复制到PowerPoint的脚本出错(Error in script which copies charts from Excel to PowerPoint)[2022-09-28]
我在最新版本的Office中遇到了很多麻烦。 2003年和之前没有这个问题,2007年和2010年有这个问题,而且2013年和2016年都有这个问题。 当您单步执行代码时,它可以正常工作,但是当您以全速运行时,它会在粘贴上出错。 这就好像副本没有时间完成,所以当你粘贴剪贴板时,它还没有任何东西可以粘贴。 有时这有助于: chrt.CopyPicture Appearance:=xlScreen, Format:=xlBitmap DoEvents curSlide.Shapes.Paste DoEvent ... -
假设您在表单中添加了一个Excel工作簿对象,将其命名为xLObject,并在VBA中添加了对Excel对象库的引用 以下是访问此对象的工作表和更改范围的方法 Dim sheet As Excel.Worksheet Set sheet = xlObject.Object.Sheets(1) sheet.Range("A1") = "Hello World" 同样的逻辑适用于Powerpoint。 Let's say you added an Excel Workbook Object in your F ...