深度学习-TF函数-layers.concatenate用法
环境: tensorfow 2.*
def concatenate(inputs, axis=-1, **kwargs):
axis=n表示从第n个维度进行拼接,对于一个三维矩阵,axis的取值可以为[-3, -2, -1, 0, 1, 2]。
代码
import numpy as np
import tensorflow as tft1 = tf.Variable(np.array([[[1, 2], [2, 3]], [[4, 4], [5, 3]]]))
t2 = tf.Variable(np.array([[[7, 4], [8, 4]], [[2, 10], [15, 11]]]))d0 = tf.keras.layers.concatenate([t1, t2], axis=0)
d1 = tf.keras.layers.concatenate([t1, t2], axis=1)
d2 = tf.keras.layers.concatenate([t1, t2], axis=2)
d3 = tf.keras.layers.concatenate([t1, t2], axis=-1)print(d0)
print(d1)
print(d2)
print(d3)
结果:
tf.Tensor(
[[[ 1 2][ 2 3]][[ 4 4][ 5 3]][[ 7 4][ 8 4]][[ 2 10][15 11]]], shape=(4, 2, 2), dtype=int32)
tf.Tensor(
[[[ 1 2][ 2 3][ 7 4][ 8 4]][[ 4 4][ 5 3][ 2 10][15 11]]], shape=(2, 4, 2), dtype=int32)
tf.Tensor(
[[[ 1 2 7 4][ 2 3 8 4]][[ 4 4 2 10][ 5 3 15 11]]], shape=(2, 2, 4), dtype=int32)
tf.Tensor(
[[[ 1 2 7 4][ 2 3 8 4]][[ 4 4 2 10][ 5 3 15 11]]], shape=(2, 2, 4), dtype=int32)Process finished with exit code 0
深度学习-TF函数-layers.concatenate用法相关推荐
- 深度学习-TF函数-layers.concatenate用法 numpy数组维度
环境: tensorfow 2.* def concatenate(inputs, axis=-1, **kwargs): axis=n表示从第n个维度进行拼接,对于一个三维矩阵,axis的取值可以为 ...
- 深度学习:tensorflow的简单用法,tensorflow实现SVM
文章目录 tensorflow整体理解 tensorflow框架 tensorflow训练 tensorflow基本操作对象 常量:就是已经确定的对象 可训练变量:就是需要训练的变量对象 不可可训练变 ...
- Matlab 训练深度学习模型函数 trainingOptions
function opts = trainingOptions(solverName, varargin)solverName: 'sgdm' - 带动量的随机梯度下降 'adam' - 自适应力矩估 ...
- 深度学习loss函数理解
机器学习中的范数规则化之L0.L1.L2范数及loss函数 监督机器学习问题无非就是"minimizeyour error while regularizing your parameter ...
- 深度学习——loss函数的学习笔记(legacy)
3 备注 3.1 使用torch.log()前,需要进行clamp 在写作loss函数时,经常会使用torch.log()函数,例如计算交叉熵时: 在PyTorch中,在使用torch.log()前, ...
- Python深度学习 魔法函数2
对于魔法函数__repr__来说,他是可以把一个对象用字符串表达出来,以便于更好的区分,对于__str__来说,它也是返回字符串,只是对于终端用户更友好一些. class Person:def __i ...
- 深度学习softmax函数理解
文章目录 一,引入 二,softmax是什么? 三,为什么 使用exe^xex 实现 总结 一,引入 我们为什么要引入这个函数,我们知道在机器学习当中,一些问题大概可以分为两种,一种是分类问题,一种是 ...
- 深度学习:tensorflow Layers的实现,numpy实现深度学习(二)
文章目录 基类Layer的实现: 激活层的实现: CostLayer的实现: 基类Layer的实现: 前面已经提到过一个layer的包含:shape,激活函数,梯度的处理以及输出层的处理. impor ...
- 李沐深度学习Accumulator函数
class Accumulator: # @save"""在`n`个变量上累加."""def __init__(self, n):self. ...
最新文章
- USB获取图像实时处理
- 查看oracle中path,查看oracle进程启动时的环境变量
- 如何在路由器的局域网下使用IIS发布网页
- Markdown 工具推荐
- 固定频率调用接口方案
- 点击MSFlexGrid数据控件的标题进行数据排序
- 利用RC.EXE和RCDLL.DLL创建VB6资源文件
- Matlab运算之 norm,cross,makehgtform,asin(acos)
- JavaScript学习指南(非常详细)
- 怎么自己制作证件照?如何在线制作证件照电子版?
- 数据库系统原理与应用教程(014)—— 关系数据库练习题(一)
- 硬盘坏道数据如何恢复?如何知道硬盘是否坏道?
- [办公自动化]目录修改以及插入分页符后行间距自动变宽
- 1KB文件夹快捷方式病毒清除(转)
- vba中FreezePanes(冻结窗格)用法
- 云账户合法吗_云支付合法吗?
- typhon自带base64函数
- BIOS怎么开启UEFI模式|电脑设置UEFI启动的方法
- Nginx的 allow / deny 理解
- 解决winform自定义窗体在扩展显示器最大化不能充满屏幕
热门文章
- Linux命令之crontab命令
- Jeecg-Boot导入附件异常解决
- 解决Ssh/Scp报错:Someone Could Be Eavesdropping On You Right Now (Man-In-The-Middle Attack)!
- How to Install and Configure OpenSSH Server In Linux
- Fedora安装Mariadb数据库
- BGP——AS—PATH正则表达式(实列讲解+配置)
- Redis简单命令(部分示例代码)
- 微信小程序入门二:底部导航tabBar
- 【Java】计算1+1/2!+1/3!+1/4!....前20项
- C#LeetCode刷题-二分查找​​​​​​​