首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏非典型程序猿

    Linux下如何in-place更改文件

    导言 前几天下班在地铁上,听到身边有两个小伙子在讨论,如何in-place的修改一个文件,路上想了半天没有好的办法。等到了家里一番探究,终于找到可行的方案了。 什么是in-place的更改文件 所谓edit in place,顾名思义,就是当我们更改一份文件时,不可以创建任何的中间/临时文件,或者临时内存等,来完成对一份文件的修改。

    3.4K51发布于 2020-03-15
  • 来自专栏TechFlow

    LeetCode41, 一道题让你明白 in-place是什么?又怎么设计in-place算法?

    有经验的同学可能已经反映过来了,这是in-place的套路。 in-place并不是一个算法,而是一种思想。 如果是in-place的方法,我们则不会另外创建数组,而在原数组上进行修改。 而如果我们需要保证性能,我们则需要设置参数,来执行一个in-place的操作。 这题其实已经暗示得很明显了,我们需要存储数据,但是又不让我们申请空间,于是我们只有in-place一条路可以走了。 我乍看到这种算法的时候还是很惊艳的,后来想到了in-place之后,又觉得非常巧妙, 没想到利用in-place的思想还能出出这么巧妙的题。 同样,如果你事先就了解过in-place的相关处理,一定也可以对这个算法理解得更加透彻。

    1.1K20发布于 2020-03-19
  • 来自专栏软件研发

    解决a leaf Variable that requires grad has been used in an in-place operation

    解决 "a leaf Variable that requires grad has been used in an in-place operation"在使用PyTorch进行深度学习模型训练时,有时会遇到一个错误信息 :"a leaf Variable that requires grad has been used in an in-place operation"。 这个错误通常出现在我们试图对梯度开启的张量进行原地(in-place)操作时。 在PyTorch中,张量(Tensor)有一个​​requires_grad​​属性,用于指示是否需要计算梯度。 查看原始张量的梯度print(x.grad) # 输出: tensor([2.])综上所述,当遇到 "a leaf Variable that requires grad has been used in an in-place 以下是一个解决 "a leaf Variable that requires grad has been used in an in-place operation" 错误的完整示例代码:pythonCopy

    3.4K50编辑于 2023-11-14
  • 来自专栏ShanSan的云原生之路

    (译) Understanding Elixir Macros, Part 6 - In-place Code Generation

    Understanding Elixir Macros, Part 5 - Reshaping the AST [6] (译) Understanding Elixir Macros, Part 6 - In-place 如上一节所述, 在 in-place 模块执行开始之前, 将扩展宏. 对我们来说, 这意味着 deftraceable 被调用之前, for 语境甚至还没有执行.

    53340编辑于 2023-10-21
  • 来自专栏深度学习和计算机视觉

    PyTorch中的In-place操作是什么?为什么要避免使用这种操作?

    在神经网络中使用in-place操作可能有助于避免上述方法的缺点,同时节省一些GPU内存。但是,由于几个原因,不建议使用in-place操作。 在这篇文章中,内容包括: 描述什么是in-place操作,并演示他们如何可能有助于节省GPU内存。 告诉我们为什么要避免in-place操作或非常小心地使用它们。 In-place 操作 “In-place运算是一种直接改变给定线性函数、向量、矩阵(张量)内容而不复制的运算。" 根据定义,in-place操作不会复制输入。 In-place 操作的缺点 in-place操作的主要缺点是,它们可能会覆盖计算梯度所需的值,这意味着破坏模型的训练过程。 限制in-place作业的适用性的主要原因有两个: 1、in-place操作可能会覆盖计算梯度所需的值。 2、每个in-place操作实际上都需要实现重写计算图。

    1.9K30编辑于 2022-12-27
  • 来自专栏计算机视觉理论及其实现

    torch.Tensor

    version of atan2() atan_() → Tensor In-place version of atan() backward(gradient=None, retain_graph= This function modifies the input tensor in-place, and returns the input tensor. () exp_() → Tensor In-place version of exp() expm1() → Tensor See torch.expm1() expm1_() → Tensor In-place To change the size in-place with custom strides, see set_(). () sin_() → Tensor In-place version of sin() sinh() → Tensor See torch.sinh() sinh_() → Tensor In-place

    2.2K30发布于 2019-09-25
  • 来自专栏10km的专栏

    macOS:sed -i报错:sed: 1: “xxxxx“: extra characters at the end of p command

    file.txt”: extra characters at the end of p command 在stackoverflow上找到这个帖子《sed command with -i option (in-place (mscOS) -i .bak,或在linux下 -i.bak 即修改原文件并保存一个后缀为.bak的修改前的备份 如下是Linux下sed -i 参数说明 -i[SUFFIX], --in-place It is not recommended to give a zero-length extension when in-place editing Note that in-place editing with -I still takes place in a single continuous line address That can lead to unexpected results in many cases of in-place editing, where

    1.8K10编辑于 2021-12-07
  • 来自专栏数据处理与编程实践

    Python: 按位或运算符(Bitwise OR)

    |= performs an in-place operation (原地运算符) between pairs of objects. OR operation an in-place OR operation via special method 示例代码: s1 = {"a", "b", "c"} s2 = {"d", "e", + str(s1)) # s1 is unchanged print("s_or: " + str(s_or)) s1 |= s2 # In-place # n1 is unchanged print("n_or: " + str(n_or)) n1 |= n2 # In-place hackmd.io/@kaneyxx/HJdX8DXCr) [3] Options(https://doc.qt.io/qt-6/qfiledialog.html#Option-enum) [4] In-place

    1.2K30编辑于 2022-12-18
  • 来自专栏脑洞前端

    283. 移动零

    思路 如果题目没有要求modify in-place 的话,我们可以先遍历一遍将包含0的和不包含0的存到两个数字, 然后拼接两个数组即可。 但是题目要求modify in-place, 也就是不需要借助额外的存储空间,刚才的方法 空间复杂度是O(n). 那么如果modify in-place呢?空间复杂度降低为1。 Example: * * * Input: [0,1,0,3,12] * Output: [1,3,12,0,0] * * Note: * * * You must do this in-place * */ /** * @param {number[]} nums * @return {void} Do not return anything, modify nums in-place

    52230发布于 2019-09-05
  • 来自专栏idba

    MySQL|什么情况下拓展字段长度会锁表?

    As a result, in-place ALTER TABLE only supports increasing VARCHAR column size from 0 to 255 bytes, or In-place ALTER TABLE does not support increasing the size of a VARCHAR column from less than 256 bytes online ddl in-place 模式(不锁表)只支持字段的字节长度从0到255之间 或者256到更大值之间变化。 另外就是不支持以 in-place 方式缩小字段长度。 Decreasing VARCHAR size using in-place ALTER TABLE is not supported.

    4.7K21发布于 2021-04-23
  • 来自专栏Reck Zhang

    LeetCode 0048 - Rotate Image

    Note: You have to rotate the image in-place, which means you have to modify the input 2D matrix directly Example 1: Given input matrix = [ [1,2,3], [4,5,6], [7,8,9] ], rotate the input matrix in-place = [ [ 5, 1, 9,11], [ 2, 4, 8,10], [13, 3, 6, 7], [15,14,12,16] ], rotate the input matrix in-place

    55920发布于 2021-08-11
  • 来自专栏诡途的python路

    LeetCode 283. 移动零

    moveZeroes(self, nums: List[int]) -> None: """ Do not return anything, modify nums in-place moveZeroes(self, nums: List[int]) -> None: """ Do not return anything, modify nums in-place moveZeroes(self, nums: List[int]) -> None: """ Do not return anything, modify nums in-place moveZeroes(self, nums: List[int]) -> None: """ Do not return anything, modify nums in-place print(nums) print(nums) #函数封装 def moveZeroes(nums): """ Do not return anything, modify nums in-place

    33430编辑于 2022-05-09
  • 来自专栏云云众生s

    使用Kube Startup CPU Boost加速Kubernetes工作负载启动时间

    当应用程序的资源需求发生变化时,在 Kubernetes 1.27 中,通过 in-place 资源调整可以调整 Pod 资源而无需重新启动容器。 由于 in-place resource resize 功能,此操作不会强制 Pod 重新启动。 Kube Startup CPU Boost 是开源的。 由于 in-place 调整功能,这些资源将在短时间内可用于其他应用程序。与运行超配的 Pod 相比,这使得总体开销更小。 使用集群自动缩放器的用户在使用此解决方案时也应谨慎。 新的 Kubernetes in-place POD 调整功能旨在解决这个问题,而 Kube Startup CPU Boost 解决方案演示了如何利用这一新功能。 一旦应用程序启动运行,CPU 资源就会减少,由于 in-place 资源调整,这个操作不会重新启动 Pod。

    41300编辑于 2024-03-28
  • 来自专栏FluentStudy

    leetcode: explore-array-28 移动零

    Example: Input: [0,1,0,3,12] Output: [1,3,12,0,0] Note: You must do this in-place without making a 注意事项: 1、原地修改(注意: in-place 这个单词,经常在题目中会看到),即不能申明其他 list 、dict 类型。 参考答案 在了解完题目意思后,其实题目的主要难点在于 in-place 以及需要维持原来非 0 数字的长度。很自然的一个思考方向就是遍历整个数组,问题在于怎么去移动数据并且使得它保持顺序。 """ :type nums: List[int] :rtype: None Do not return anything, modify nums in-place """ :type nums: List[int] :rtype: None Do not return anything, modify nums in-place

    56640发布于 2020-08-21
  • 来自专栏FluentStudy

    leetcode: explore-strings-32 反转字符串

    Do not allocate extra space for another array, you must do this by modifying the input array in-place ","a","n","n","a","h"] Output: ["h","a","n","n","a","H"] 题意拆解: 1、输入:列表,只包括字符的列表 2、输出:列表顺序反转 3、注意事项:in-place self, s): """ :type s: List[str] :rtype: None Do not return anything, modify s in-place

    39710发布于 2020-08-24
  • 深度干货 | 揭秘YashanDB融合存储引擎

    (In-place Update)和追加式(Append-only)两种列式存储,具备原生HTAP能力和海量数据分析能力。   目前比较主流的实现方式是Append-only行级MVCC和In-place Update 行级MVCC。   In-place Update 行级MVCC,更新记录时对原始数据进行覆盖,优点:解决了Append-only行级MVCC的几个痛点问题。 为追求极致的并发事务性能,YashanDB采用In-place Update块级MVCC,针对In-place Update行级MVCC作了进一步的优化:  • 相较于追加式行存,历史版本记录增量数据, 当前通过三种方式实现混合负载:  • 在TP友好的In-place Update行式存储之上,基于内存行转列以及列式索引实现分析能力。

    16510编辑于 2025-01-17
  • 来自专栏JNing的专栏

    leetcode: 48. Rotate Image

    . # # Note: # You have to rotate the image in-place, # which means you have to modify the input 2D matrix Given input matrix = # [ # [1,2,3], # [4,5,6], # [7,8,9] # ], # # rotate the input matrix in-place 9,11], # [ 2, 4, 8,10], # [13, 3, 6, 7], # [15,14,12,16] # ], # # rotate the input matrix in-place

    47910发布于 2018-09-27
  • 来自专栏皮皮星球

    Array - 48. Rotate Image

    Note: You have to rotate the image in-place, which means you have to modify the input 2D matrix directly Example 1: Given input matrix = [ [1,2,3], [4,5,6], [7,8,9] ], rotate the input matrix **in-place [ [ 5, 1, 9,11], [ 2, 4, 8,10], [13, 3, 6, 7], [15,14,12,16] ], rotate the input matrix **in-place

    45220发布于 2020-09-23
  • 来自专栏YashanDB

    深度干货 | 揭秘YashanDB融合存储引擎

    In-place Update)和追加式(Append-only)两种列式存储,具备原生HTAP能力和海量数据分析能力。 目前比较主流的实现方式是Append-only行级MVCC和In-place Update 行级MVCC。 In-place Update 行级MVCC,更新记录时对原始数据进行覆盖,优点:解决了Append-only行级MVCC的几个痛点问题。 为追求极致的并发事务性能,YashanDB采用In-place Update块级MVCC,针对In-place Update行级MVCC作了进一步的优化:l 相较于追加式行存,历史版本记录增量数据,实现历史版本的独立存储 当前通过三种方式实现混合负载:l 在TP友好的In-place Update行式存储之上,基于内存行转列以及列式索引实现分析能力。

    24510编辑于 2025-01-17
  • 来自专栏小二的折腾日记

    Leetcode-48-Rotate-Image

    Note: You have to rotate the image in-place, which means you have to modify the input 2D matrix directly Example : Given input matrix = [ [1,2,3], [4,5,6], [7,8,9] ], rotate the input matrix in-place = [ [ 5, 1, 9,11], [ 2, 4, 8,10], [13, 3, 6, 7], [15,14,12,16] ], rotate the input matrix in-place

    62620发布于 2018-09-30
领券