小编Jin*_*les的帖子

Adam 优化器在 PyTorch 上进行预热

在论文《Attention is all you need》中,第 5.3 节中,作者建议线性增加学习率,然后按步长平方根倒数按比例减少。

纸质不锈钢

我们如何使用Adam优化器在 PyTorch 中实现这一点?最好没有额外的包。

python machine-learning pytorch

21
推荐指数
3
解决办法
4万
查看次数

INSERT 到表中并返回记录的 id Supabase JS

根据文档,插入新记录

const { error } = await supabase
  .from('countries')
  .insert({ name: 'Denmark' })
Run Code Online (Sandbox Code Playgroud)

回报

{
  "status": 201,
  "statusText": "Created"
}
Run Code Online (Sandbox Code Playgroud)

对于 的列Is Identity,它会自动为该列分配一个连续的唯一编号。

如何使用 JavaScript 客户端获取 Supabase 上新插入记录的 ID?

supabase supabase-database

14
推荐指数
1
解决办法
1万
查看次数

获取 numpy 数组中项目的索引,其中值在列表中

是否有一种 numpy 方法(并且没有 for 循环)来提取 numpy 数组中的所有索引list_of_numbers,其中值位于列表中values_of_interest

这是我当前的解决方案:

list_of_numbers = np.array([11,0,37,0,8,1,39,38,1,0,1,0])
values_of_interest = [0,1,38]

indices = []
for value in values_of_interest:
    this_indices = np.where(list_of_numbers == value)[0]
    indices = np.concatenate((indices, this_indices))

print(indices) # this shows [ 1.  3.  9. 11.  5.  8. 10.  7.]
Run Code Online (Sandbox Code Playgroud)

python numpy

6
推荐指数
1
解决办法
6645
查看次数

在 Pytorch 中实现 SeparableConv2D

主要目标

PyTorch 等效于 SeparableConv2D padding = 'same'

from tensorflow.keras.layers import SeparableConv2D
x = SeparableConv2D(64, (1, 16), use_bias = False, padding = 'same')(x)
Run Code Online (Sandbox Code Playgroud)

SeparableConv2D 的 PyTorch 等效项是什么?

消息来源说:

如果 groups = nInputPlane,kernel=(K, 1),(之前是一个 Conv2d 层,groups=1 且 kernel=(1, K)),那么它是可分离的。

虽然该消息来源说:

其核心思想是将一个完整的卷积酸分解为两步计算,即Depthwise Convolution和Pointwise。

这是我的尝试:

class SeparableConv2d(nn.Module):
    def __init__(self, in_channels, out_channels, depth, kernel_size, bias=False):
        super(SeparableConv2d, self).__init__()
        self.depthwise = nn.Conv2d(in_channels, out_channels*depth, kernel_size=kernel_size, groups=in_channels, bias=bias)
        self.pointwise = nn.Conv2d(out_channels*depth, out_channels, kernel_size=1, bias=bias)

    def forward(self, x):
        out = self.depthwise(x)
        out = self.pointwise(out)
        return …
Run Code Online (Sandbox Code Playgroud)

python convolution conv-neural-network tensorflow pytorch

5
推荐指数
1
解决办法
7576
查看次数

Firebase数据库安全规则,检查resource.data中的auth.email

错误 [firebase.firestore] FirebaseError:权限缺失或不足。

我有一个允许一些用户更新的对象。管理员将设置他们的电子邮件,并且使用这些电子邮件登录的用户将被允许更新。

这些是我尝试过的规则:

allow update: if request.resource.data.managerEmails.val().contains(request.auth.email) && request.resource.data.id == resource.data.id;

allow update: if request.resource.data.managerEmails.contains(request.auth.email) && request.resource.data.id == resource.data.id;

allow update: if request.resource.data.managerEmails.includes(request.auth.email) && request.resource.data.id == resource.data.id;
Run Code Online (Sandbox Code Playgroud)

要更新的资源:

{
  id: "someid",
  ...fields,
  managerEmails: "abcde@email.com,anothermanager@email.com",
}
Run Code Online (Sandbox Code Playgroud)

正在更新的用户身份验证:

{
  uid: "rSTLnYD9aisyZJHQPC6sg7mlsZh1",
  email: "abcde@email.com",
  ...
}
Run Code Online (Sandbox Code Playgroud)

更新:使用request.auth.uid在其他规则中一直有效,但在这种情况下,我必须使用电子邮件,因为用户可能还没有注册。

使用规则游乐场,我得到Property email is undefined on object.也许使用request.auth.email是不可能的?

firebase firebase-security google-cloud-firestore

3
推荐指数
1
解决办法
2001
查看次数