合集-python矩阵操作的方法
einops方法
摘要:#### einops方法 该方法可以快速实现矩阵的快速变化。 ``` import torch import torch.nn as nn from einops import rearrange # 快速矩阵变化 class TestAttentionQKV: def __init__(self
阅读全文
einsum方法
摘要:## einsum求矩阵运算 #### einsum是什么 使用chatGPT解读官方的[文档](https://pytorch.org/docs/stable/generated/torch.einsum.html): ``` Einsum允许使用基于Einstein求和约定的简写格式来计算许多常
阅读全文
torch使用bool类型做检索
摘要:一、背景 在使用torch的时候,可以通过bool类型对数组进行检索操作。传统的list或者dict都是使用下标和关键字检索。而在torch中可以使用bool类型进行检索,它的的目标主要是以下功能: 替换torch中的某个值 二、使用 torch在bool检索的情况下就是将为检索位置为True的地方
阅读全文
浙公网安备 33010602011771号