当前位置: 首页 > news >正文

TensorFlow 1.x学习(系列二 :1):基本概念TensorFlow的基本介绍,图,会话,会话中的run(),placeholder(),常见的报错

目录

      • 1.基本介绍
      • 2.图的结构
      • 3.会话,会话的run方法
      • 4.placeholder
      • 5.返回值异常

写在前边的话:之前发布过一个关于TensorFlow1.x的转载系列,自己将基本的TensorFlow操作敲了一遍,但是仍然有很多地方理解的不够深入。所以重开一个系列,跟着网上找到的教程边听边再敲一遍。最终的目的是实现一个新闻分类的demo,代码已有但是之前没有看懂。再往后应该会出一个pytorch的系列,最后目的是将tensorflow1.x的代码用pytorch再实现一遍。

1.基本介绍

tensorflow1.x 有其独有的语法体系,不同于Python代码的是,自定义的变量和函数无法直接输出结果,必须要在会话中完成该操作。

import tensorflow as tf
C:\Anaconda\envs\tensorflow16\lib\site-packages\tensorflow\python\framework\dtypes.py:517: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'._np_qint8 = np.dtype([("qint8", np.int8, 1)])
C:\Anaconda\envs\tensorflow16\lib\site-packages\tensorflow\python\framework\dtypes.py:518: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'._np_quint8 = np.dtype([("quint8", np.uint8, 1)])
C:\Anaconda\envs\tensorflow16\lib\site-packages\tensorflow\python\framework\dtypes.py:519: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'._np_qint16 = np.dtype([("qint16", np.int16, 1)])
C:\Anaconda\envs\tensorflow16\lib\site-packages\tensorflow\python\framework\dtypes.py:520: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'._np_quint16 = np.dtype([("quint16", np.uint16, 1)])
C:\Anaconda\envs\tensorflow16\lib\site-packages\tensorflow\python\framework\dtypes.py:521: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'._np_qint32 = np.dtype([("qint32", np.int32, 1)])
C:\Anaconda\envs\tensorflow16\lib\site-packages\tensorflow\python\framework\dtypes.py:526: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.np_resource = np.dtype([("resource", np.ubyte, 1)])
# 实现一个加法运算
a = tf.constant(5.0)
b = tf.constant(6.0)
sum1 = tf.add(a,b)# 查看结果
print(a,b)
print(sum1)
Tensor("Const:0", shape=(), dtype=float32) Tensor("Const_1:0", shape=(), dtype=float32)
Tensor("Add:0", shape=(), dtype=float32)
# 在会话中实现
with tf.Session() as sess:print(sess.run(sum1))
11.0

2.图的结构

一些概念:

tensor:张量
operation(op):专门运算的操作节点(注:所有操作都是一个op)
图(graph):你的整个程序的结构
会话(Session):运算程序的图
# 查看默认的图,根据打印的结果可以看到,图的在内存中的位置
graph = tf.get_default_graph()
graph
<tensorflow.python.framework.ops.Graph at 0x1c82a43df60>
# 打印各op的graph属性可以看到,地址都一样,都是该图的一部分
with tf.Session() as sess:print(sess.run(sum1))print(a.graph)print(sum1.graph)print(sess.graph)
11.0
<tensorflow.python.framework.ops.Graph object at 0x000001C82A43DF60>
<tensorflow.python.framework.ops.Graph object at 0x000001C82A43DF60>
<tensorflow.python.framework.ops.Graph object at 0x000001C82A43DF60>
# 一般一个程序里只有一个图,那么如何定义其他图呢
g = tf.Graph()
print(g)
<tensorflow.python.framework.ops.Graph object at 0x000001C82A48E588>
# 可以看到新定义的图和之前的图内存位置并不同
with g.as_default():c = tf.constant(11.0)print(c)print(c.graph)
Tensor("Const:0", shape=(), dtype=float32)
<tensorflow.python.framework.ops.Graph object at 0x000001C82A48E588>

总结:

创建一张图包含了一组op和tensor,上下文环境
op:只要使用tensorflow的API定义的函数都是OP
tensor:指代的就是数据

3.会话,会话的run方法

理解:

可以将tensorflow看做两部分:

前端系统:定义程序的图结构后端系统:运算图结构

会话的作用:

1.运行图的结构2.分配资源计算3.掌握资源(变量的资源,队列,线程)

一次只能运行一个图,可以在会话中指定图去运行tf.Session(graph = )

# 一次只能运行一个图,可以在会话中指定图去运行tf.Session(graph = )
with tf.Session() as sess:print(sess.run(c))print(a.graph)print(sum1.graph)print(sess.graph)# 会报错,因为c是别的图的一部分
# ValueError: Fetch argument <tf.Tensor 'Const:0' shape=() dtype=float32> cannot be interpreted as a Tensor. (Tensor Tensor("Const:0", shape=(), dtype=float32) is not an element of this graph.)
---------------------------------------------------------------------------ValueError                                Traceback (most recent call last)C:\Anaconda\envs\tensorflow16\lib\site-packages\tensorflow\python\client\session.py in __init__(self, fetches, contraction_fn)281         self._unique_fetches.append(ops.get_default_graph().as_graph_element(
--> 282             fetch, allow_tensor=True, allow_operation=True))283       except TypeError as e:C:\Anaconda\envs\tensorflow16\lib\site-packages\tensorflow\python\framework\ops.py in as_graph_element(self, obj, allow_tensor, allow_operation)3458     with self._lock:
-> 3459       return self._as_graph_element_locked(obj, allow_tensor, allow_operation)3460 C:\Anaconda\envs\tensorflow16\lib\site-packages\tensorflow\python\framework\ops.py in _as_graph_element_locked(self, obj, allow_tensor, allow_operation)3537       if obj.graph is not self:
-> 3538         raise ValueError("Tensor %s is not an element of this graph." % obj)3539       return objValueError: Tensor Tensor("Const:0", shape=(), dtype=float32) is not an element of this graph.


During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)<ipython-input-10-c64ee74128b9> in <module>1 # 一次只能运行一个图2 with tf.Session() as sess:
----> 3     print(sess.run(c))4     print(a.graph)5     print(sum1.graph)C:\Anaconda\envs\tensorflow16\lib\site-packages\tensorflow\python\client\session.py in run(self, fetches, feed_dict, options, run_metadata)903     try:904       result = self._run(None, fetches, feed_dict, options_ptr,
--> 905                          run_metadata_ptr)906       if run_metadata:907         proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)C:\Anaconda\envs\tensorflow16\lib\site-packages\tensorflow\python\client\session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)1120     # Create a fetch handler to take care of the structure of fetches.1121     fetch_handler = _FetchHandler(
-> 1122         self._graph, fetches, feed_dict_tensor, feed_handles=feed_handles)1123 1124     # Run request and get response.C:\Anaconda\envs\tensorflow16\lib\site-packages\tensorflow\python\client\session.py in __init__(self, graph, fetches, feeds, feed_handles)425     """426     with graph.as_default():
--> 427       self._fetch_mapper = _FetchMapper.for_fetch(fetches)428     self._fetches = []429     self._targets = []C:\Anaconda\envs\tensorflow16\lib\site-packages\tensorflow\python\client\session.py in for_fetch(fetch)251         if isinstance(fetch, tensor_type):252           fetches, contraction_fn = fetch_fn(fetch)
--> 253           return _ElementFetchMapper(fetches, contraction_fn)254     # Did not find anything.255     raise TypeError('Fetch argument %r has invalid type %r' % (fetch,C:\Anaconda\envs\tensorflow16\lib\site-packages\tensorflow\python\client\session.py in __init__(self, fetches, contraction_fn)287       except ValueError as e:288         raise ValueError('Fetch argument %r cannot be interpreted as a '
--> 289                          'Tensor. (%s)' % (fetch, str(e)))290       except KeyError as e:291         raise ValueError('Fetch argument %r cannot be interpreted as a 'ValueError: Fetch argument <tf.Tensor 'Const:0' shape=() dtype=float32> cannot be interpreted as a Tensor. (Tensor Tensor("Const:0", shape=(), dtype=float32) is not an element of this graph.)

指定图运行

# 指定图运行
with tf.Session(graph = g) as sess:print(sess.run(c))print(a.graph) # 这个能正常输出是因为在会话外就定义过print(sum1.graph) # 同上print(sess.graph)
11.0
<tensorflow.python.framework.ops.Graph object at 0x000001C82A43DF60>
<tensorflow.python.framework.ops.Graph object at 0x000001C82A43DF60>
<tensorflow.python.framework.ops.Graph object at 0x000001C82A48E588>

关于sess.run(fetches,feed_dict=None,graph = None):

1.作用:运行ops和计算tensor,相当于是启动整个图2.sess.close():与sess.run()相对应,关闭资源。但是在使用上下文管理器的结构中(with tf.Session as sess:...)可以省略

其他:

3.tf.Session() 中还有另外一个参数config (tf.Session(config = tf.ConfigPorto(log_device_placement=True)))作用是显示你的op具体是在那个设备上运行的以及其他详细情况。4.交互式:在命令行里使用,tf.interactiveSession(),方便调试,结合变量.eval()比较方便

例1:一次run多个

# 例1:一次run多个
with tf.Session() as sess:print(sess.run([a,b,sum1]))
[5.0, 6.0, 11.0]

2-1:run只能运行op和tensor

# 例2-1:run只能运行op和tensor
var1 = 2
var2 = 3
sum2 = var1 + var2
with tf.Session() as sess:print(sess.run(sum2))# TypeError: Fetch argument 5 has invalid type <class 'int'>, must be a string or Tensor. (Can not convert a int into a Tensor or Operation.)
---------------------------------------------------------------------------TypeError                                 Traceback (most recent call last)C:\Anaconda\envs\tensorflow16\lib\site-packages\tensorflow\python\client\session.py in __init__(self, fetches, contraction_fn)281         self._unique_fetches.append(ops.get_default_graph().as_graph_element(
--> 282             fetch, allow_tensor=True, allow_operation=True))283       except TypeError as e:C:\Anaconda\envs\tensorflow16\lib\site-packages\tensorflow\python\framework\ops.py in as_graph_element(self, obj, allow_tensor, allow_operation)3458     with self._lock:
-> 3459       return self._as_graph_element_locked(obj, allow_tensor, allow_operation)3460 C:\Anaconda\envs\tensorflow16\lib\site-packages\tensorflow\python\framework\ops.py in _as_graph_element_locked(self, obj, allow_tensor, allow_operation)3547       raise TypeError("Can not convert a %s into a %s." % (type(obj).__name__,
-> 3548                                                            types_str))3549 TypeError: Can not convert a int into a Tensor or Operation.


During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)<ipython-input-13-31c14cd7002b> in <module>4 sum2 = var1 + var25 with tf.Session() as sess:
----> 6     print(sess.run(sum2))C:\Anaconda\envs\tensorflow16\lib\site-packages\tensorflow\python\client\session.py in run(self, fetches, feed_dict, options, run_metadata)903     try:904       result = self._run(None, fetches, feed_dict, options_ptr,
--> 905                          run_metadata_ptr)906       if run_metadata:907         proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)C:\Anaconda\envs\tensorflow16\lib\site-packages\tensorflow\python\client\session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)1120     # Create a fetch handler to take care of the structure of fetches.1121     fetch_handler = _FetchHandler(
-> 1122         self._graph, fetches, feed_dict_tensor, feed_handles=feed_handles)1123 1124     # Run request and get response.C:\Anaconda\envs\tensorflow16\lib\site-packages\tensorflow\python\client\session.py in __init__(self, graph, fetches, feeds, feed_handles)425     """426     with graph.as_default():
--> 427       self._fetch_mapper = _FetchMapper.for_fetch(fetches)428     self._fetches = []429     self._targets = []C:\Anaconda\envs\tensorflow16\lib\site-packages\tensorflow\python\client\session.py in for_fetch(fetch)251         if isinstance(fetch, tensor_type):252           fetches, contraction_fn = fetch_fn(fetch)
--> 253           return _ElementFetchMapper(fetches, contraction_fn)254     # Did not find anything.255     raise TypeError('Fetch argument %r has invalid type %r' % (fetch,C:\Anaconda\envs\tensorflow16\lib\site-packages\tensorflow\python\client\session.py in __init__(self, fetches, contraction_fn)284         raise TypeError('Fetch argument %r has invalid type %r, '285                         'must be a string or Tensor. (%s)' %
--> 286                         (fetch, type(fetch), str(e)))287       except ValueError as e:288         raise ValueError('Fetch argument %r cannot be interpreted as a 'TypeError: Fetch argument 5 has invalid type <class 'int'>, must be a string or Tensor. (Can not convert a int into a Tensor or Operation.)

例2-2 有重载的机制,默认会给运算符重载成op类型

# 例2-2 有重载的机制,默认会给运算符重载成op类型
var1 = 2.0
sum2 = a + var1
with tf.Session() as sess:print(sess.run(sum2))
7.0

4.placeholder

应用场景:训练模型时需要实时提供数据去训练

介绍:

1.placeholder是一个占位符,使用中充当feed_dict字典中的键2.参数:placeholder(dtype,shape = None,name = None)

例1 :placeholder的使用

# 例1 :placeholder的使用
plt = tf.placeholder(tf.float32,[2,3])with tf.Session(config = tf.ConfigProto(log_device_placement = True)) as sess:print(sess.run(plt,feed_dict = {plt:[[1,2,3],[4,5,6]]}))
[[1. 2. 3.][4. 5. 6.]]

例2 :placeholder的使用2(样本行数不固定)

# 例2 :placeholder的使用2(样本行数不固定)
plt = tf.placeholder(tf.float32,[None,3]) # n行3列with tf.Session(config = tf.ConfigProto(log_device_placement = True)) as sess:print(sess.run(plt,feed_dict = {plt:[[1,2,3],[4,5,6],[7,8,9]]}))
[[1. 2. 3.][4. 5. 6.][7. 8. 9.]]

5.返回值异常

RuntimeError: 如果它Session处于无效状态(例如已关闭)。

TypeError:如果fetches或feed_dict键是不合适的类型。

ValueError:如果fetches或feed_dict键无效或引用tensor不存在

相关文章:

TensorFlow 1.x学习(系列二 :1):基本概念TensorFlow的基本介绍,图,会话,会话中的run(),placeholder(),常见的报错

目录1.基本介绍2.图的结构3.会话&#xff0c;会话的run方法4.placeholder5.返回值异常写在前边的话&#xff1a;之前发布过一个关于TensorFlow1.x的转载系列&#xff0c;自己将基本的TensorFlow操作敲了一遍&#xff0c;但是仍然有很多地方理解的不够深入。所以重开一个系列&am…...

javaEE 初阶 — 关于 IPv4、IPv6 协议、NAT(网络地址转换)、动态分配 IP 地址 的介绍

文章目录1. IPv42. IPv63. NAT4. 动态分配 IP 地址1. IPv4 在互联网的世界中只有 0 和1 &#xff0c;所以每个人都有一个由 0 和 1 组成的地址来让别人找到你。 这段由 0 和 1 组成的地址叫 IP 地址&#xff0c;这是互联网的基础资源&#xff0c;可以简单的理解为互联网的土地。…...

《Qt 6 C++开发指南》简介

我们编写的新书《Qt 6 C开发指南》在2月份终于正式发行销售了&#xff0c;这本书是对2018年5月出版的《Qt 5.9 C开发指南》的重磅升级。以下是本书前言的部分内容&#xff0c;算是对《Qt 6 C开发指南》的一个简介。1&#xff0e;编写本书的目的《Qt 5.9C开发指南》是我写的第一…...

CleanMyMac是什么清理软件?及使用教程

你知道CleanMyMac是什么吗&#xff1f;它的字面意思为“清理我的Mac”&#xff0c;作为软件&#xff0c;那就是一款Mac清理工具&#xff0c;Mac OS X 系统下知名系统清理软件&#xff0c;是数以万计的Mac用户的选择。它可以流畅地与系统性能相结合&#xff0c;只需简单的步骤就…...

Linux小黑板(9):共享内存

"My poor lost soul"上章花了不少的篇幅讲了讲基于管道((匿名、命名))技术实现的进程间通信。进程为什么需要通信&#xff1f;目的是为了完成进程间的"协同",提高处理数据的能力、优化业务逻辑的实现等等&#xff0c;在linux中我们已经谈过了一个通信的大类…...

Detr源码解读(mmdetection)

Detr源码解读(mmdetection) 1、原理简要介绍 整体流程&#xff1a; 在给定一张输入图像后&#xff0c;1&#xff09;特征向量提取&#xff1a; 首先经过ResNet提取图像的最后一层特征图F。注意此处仅仅用了一层特征图&#xff0c;是因为后续计算复杂度原因&#xff0c;另外&am…...

一个.Net Core开发的,撑起月6亿PV开源监控解决方案

更多开源项目请查看&#xff1a;一个专注推荐.Net开源项目的榜单 项目发布后&#xff0c;对于我们程序员来说&#xff0c;项目还不是真正的结束&#xff0c;保证项目的稳定运行也是非常重要的&#xff0c;而对于服务器的监控&#xff0c;就是保证稳定运行的手段之一。对数据库、…...

C语言数据结构初阶(2)----顺序表

目录 1. 顺序表的概念及结构 2. 动态顺序表的接口实现 2.1 SLInit(SL* ps) 的实现 2.2 SLDestory(SL* ps) 的实现 2.3 SLPrint(SL* ps) 的实现 2.4 SLCheckCapacity(SL* ps) 的实现 2.5 SLPushBack(SL* ps, SLDataType x) 的实现 2.6 SLPopBack(SL* ps) 的实现 2.7 SLP…...

K8S常用命令速查手册

K8S常用命令速查手册一. K8S日常维护常用命令1.1 查看kubectl版本1.2 启动kubelet1.3 master节点执行查看所有的work-node节点列表1.4 查看所有的pod1.5 检查kubelet运行状态排查问题1.6 诊断某pod故障1.7 诊断kubelet故障方式一1.8 诊断kubelet故障方式二二. 端口策略相关2.1 …...

Linux系统下命令行安装MySQL5.6+详细步骤

1、因为想在腾讯云的服务器上创建自己的数据库&#xff0c;所以我在这里是通过使用Xshell 7来连接腾讯云的远程服务器&#xff1b; 2、Xshell 7与服务器连接好之后&#xff0c;就可以开始进行数据库的安装了&#xff08;如果服务器曾经安装过数据库&#xff0c;得将之前安装的…...

13.STM32超声波模块讲解与实战

目录 1.超声波模块讲解 2.超声波时序图 3.超声波测距步骤 4.项目实战 1.超声波模块讲解 超声波传感器模块上面通常有两个超声波元器件&#xff0c;一个用于发射&#xff0c;一个用于接收。电路板上有4个引脚&#xff1a;VCC GND Trig&#xff08;触发&#xff09;&#xff…...

逆向之Windows PE结构

写在前面 对于Windows PE文件结构&#xff0c;个人认为还是非常有必要掌握和了解的&#xff0c;不管是在做逆向分析、免杀、病毒分析&#xff0c;脱壳加壳都是有着非常重要的技能。但是PE文件的学习又是一个非常枯燥过程&#xff0c;希望本文可以帮你有一个了解。 PE文件结构…...

ACL是什么

目录 一、ACL是什么 二、ACL的使用&#xff1a;setacl与getacl 1&#xff09;针对特定使用者的方式&#xff1a; 1. 创建acl_test1后设置其权限 2. 读取acl_test1的权限 2&#xff09;针对特定群组的方式&#xff1a; 3&#xff09;针对有效权限 mask 的设置方式&#xf…...

操作系统核心知识点整理--内存篇

操作系统核心知识点整理--内存篇按段对内存进行管理内存分区内存分页为什么需要多级页表TLB解决了多级页表什么样的缺陷?TLB缓存命中率高的原理是什么?段页结合: 为什么需要虚拟内存&#xff1f;虚拟地址到物理地址的转换过程段页式管理下程序如何载入内存&#xff1f;页面置…...

从零开始学习iftop流量监控(找出服务器耗费流量最多的ip和端口)

一、iftop是什么iftop是类似于top的实时流量监控工具。作用&#xff1a;监控网卡的实时流量&#xff08;可以指定网段&#xff09;、反向解析IP、显示端口信息等官网&#xff1a;http://www.ex-parrot.com/~pdw/iftop/二、界面说明>代表发送数据&#xff0c;< 代表接收数…...

第一篇博客------自我介绍篇

目录&#x1f506;自我介绍&#x1f506;学习目标&#x1f506;如何学习单片机Part 1 基础理论知识学习Part 2 单片机实践Part 3 单片机硬件设计&#x1f506;希望进入的公司&#x1f506;结束语&#x1f506;自我介绍 Hello!!!我是一名即已经步入大二的计算机小白。 --------…...

No suitable device found for this connection (device lo not available(网络突然出问题)

当执行 ifup ens33 出现错误&#xff1a;[rootlocalhost ~]# ifup ens33Error: Connection activation failed: No suitable device found for this connection (device lo not available because device is strictly unmanaged).1解决办法&#xff1a;[rootlocalhost ~]# chkc…...

【算法设计技巧】分治算法

分治算法 用于设计算法的另一种常用技巧为分治算法(divide and conquer)。分治算法由两部分组成&#xff1a; 分(divide)&#xff1a;递归解决较小的问题(当然&#xff0c;基准情况除外)治(conquer)&#xff1a;然后&#xff0c;从子问题的解构建原问题的解。 传统上&#x…...

已解决kettle新建作业,点击保存抛出异常Invalid state, the Connection object is closed.

已解决kettle新建作业&#xff0c;点击保存进资源数据库抛出异常Invalid state, the Connection object is closed.的解决方法&#xff0c;亲测有效&#xff01;&#xff01;&#xff01; 文章目录报错问题报错翻译报错原因解决方法联系博主免费帮忙解决报错报错问题 一个小伙伴…...

【设计模式】 工厂模式介绍及C代码实现

【设计模式】 工厂模式介绍及C代码实现 背景 在软件系统中&#xff0c;经常面临着创建对象的工作&#xff1b;由于需求的变化&#xff0c;需要创建的对象的具体类型经常变化。 如何应对这种变化&#xff1f;如何绕过常规的对象创建方法(new)&#xff0c;提供一种“封装机制”来…...

Windows 11 + CUDA 12.1 保姆级教程:手把手搞定Detectron2环境搭建(含Git加速与权限避坑)

Windows 11 CUDA 12.1 终极指南&#xff1a;零障碍搭建Detectron2开发环境 RTX 40系显卡用户注意了&#xff01;如果你正在Windows 11上尝试搭建Detectron2开发环境&#xff0c;却苦于找不到针对CUDA 12.1的完整解决方案&#xff0c;这篇指南将为你扫清所有障碍。不同于网上那…...

RobotStudio新手必看:5分钟搞定夹取工件程序(附完整代码)

RobotStudio零基础实战&#xff1a;从夹取工件到高效编程的完整指南 第一次打开RobotStudio时&#xff0c;面对复杂的界面和陌生的术语&#xff0c;很多新手会感到无从下手。但别担心&#xff0c;掌握几个核心概念和操作步骤&#xff0c;你就能快速实现基础的夹取工件功能。本文…...

BVH构建优化:四种分割算法在光线追踪中的性能对比

1. BVH分割算法基础概念 当你在玩3D游戏时&#xff0c;有没有想过为什么场景中的物体能够如此快速地渲染出来&#xff1f;这背后就离不开BVH&#xff08;边界体积层次结构&#xff09;技术的支持。简单来说&#xff0c;BVH就像是一个高效的"物体分类系统"&#xff0c…...

【Java 21记录模式性能优化终极指南】:3个被90%开发者忽略的模式匹配陷阱及提速300%的实战方案

第一章&#xff1a;Java 21记录模式性能优化全景概览Java 21 引入的记录模式&#xff08;Record Patterns&#xff09;不仅提升了模式匹配的表达力&#xff0c;更在JVM层面实现了多项关键性能优化。通过与模式匹配&#xff08;Pattern Matching for instanceof&#xff09;和解…...

[具身智能-189]:ROS2的Node通信机制,为硬件的仿真平台与模型算法的分离以及他们之间标准化的通信提供了保障,在嵌入式系统,特别是具身智能开发中,解决“软硬耦合”这一顽疾。

ROS 2 的节点通信机制&#xff0c;本质上就是为了解决“软硬耦合”这一顽疾而生的。 它通过去中心化的架构和标准化的中间件&#xff08;DDS&#xff09;&#xff0c;让仿真平台&#xff08;如 Gazebo、Isaac Sim&#xff09;和模型算法&#xff08;如导航、感知&#xff09;能…...

告别AI对话失忆症:深入LangChain4j的ChatMemoryProvider与InMemoryChatMemoryStore

深入LangChain4j记忆管理&#xff1a;构建高性能会话隔离系统的实践指南 在构建企业级AI对话系统时&#xff0c;会话记忆管理往往成为决定用户体验的关键因素。想象这样一个场景&#xff1a;当用户询问"我上周提到的项目进展如何&#xff1f;"时&#xff0c;系统能否…...

GEC6818嵌入式Linux智能车库系统开发实战

1. 项目概述这个基于GEC6818嵌入式Linux的智能车库系统&#xff0c;是我去年为一个商业停车场改造项目开发的解决方案。当时客户的主要痛点在于传统人工管理效率低下&#xff0c;经常出现收费纠纷和停车位利用率不高的问题。经过三个月的开发和调试&#xff0c;最终实现了这套集…...

音频驱动面部动画:Audio2Face技术原理与实践指南

音频驱动面部动画&#xff1a;Audio2Face技术原理与实践指南 【免费下载链接】FACEGOOD-Audio2Face http://www.facegood.cc 项目地址: https://gitcode.com/gh_mirrors/fa/FACEGOOD-Audio2Face 在虚拟人技术快速发展的今天&#xff0c;面部动画的自然度成为提升用户体验…...

从单工具到插件集:在Coze IDE里用Python/Node.js打造你的专属工具链

从单工具到插件集&#xff1a;在Coze IDE里用Python/Node.js打造你的专属工具链 在当今快速发展的AI应用开发领域&#xff0c;开发者们不再满足于简单的API调用和单一功能实现。随着业务逻辑的复杂化&#xff0c;如何高效地构建、管理和部署一系列相互关联的工具链&#xff0c;…...

虚拟同步发电机这玩意儿搞并网真心刺激!今天咱们直接拆解一个双机并联的MATLAB/Simulink仿真模型,手把手看它怎么扛住240kW的暴力测试

MATLAB/Simulink虚拟同步发电机&#xff08;vsg) 双机并联 仿真模型&#xff0c;附参考文献。 电压电流双闭环控制&#xff0c;SPWM调制技术&#xff1a;运用正弦波脉宽调制&#xff08;SPWM&#xff09;技术&#xff0c;优化波形输出。 总负荷承载 轻松应对240kW有功功率及10k…...