小编Sal*_*med的帖子

使用保留关键字FilterExpression NodeJS在DynamoDB中扫描函数

我的扫描功能:

var tableName = 'faasos_orders',
    filterExp = 'status = :delivered OR status = :void OR status = :bad',
    projectionValues = '',
    expressionAttr = {};    
    expressionAttr[":delivered"] = "delivered";
    expressionAttr[":bad"] = "bad";
    expressionAttr[":void"] = "void"; 
    limit = 10;
  dynamoConnector.getItemUsingScan(tableName, filterExp, projectionValues, expressionAttr, function (err, data) {  ...........} 
Run Code Online (Sandbox Code Playgroud)

运行时出错:

    { [ValidationException: Invalid FilterExpression: Attribute name is a reserved keyword; reserved keyword: status]
  message: 'Invalid FilterExpression: Attribute name is a reserved keyword; reserved keyword: status',
  code: 'ValidationException',
  time: Mon Apr 18 2016 21:57:30 GMT+0530 …
Run Code Online (Sandbox Code Playgroud)

javascript amazon-web-services node.js amazon-dynamodb

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

在 Pytorch 中 F.nll_loss() 类型为 torch.LongTensor 的预期对象,但发现类型为 torch.FloatTensor 的参数 #2 'target'

为什么会出现这个错误。

我正在尝试编写一个自定义损失函数,它最终具有负对数可能性。

根据我的理解,NLL 是在两个概率值之间计算的?

>>> loss = F.nll_loss(sigm, trg_, ignore_index=250, weight=None, size_average=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home//lib/python3.5/site-packages/torch/nn/functional.py", line 1332, in nll_loss
    return torch._C._nn.nll_loss(input, target, weight, size_average, ignore_index, reduce)
RuntimeError: Expected object of type torch.LongTensor but found type torch.FloatTensor for argument #2 'target'
Run Code Online (Sandbox Code Playgroud)

这里的输入如下:

>>> sigm.size()
torch.Size([151414, 80])
>>> sigm
tensor([[ 0.3283,  0.6472,  0.8278,  ...,  0.6756,  0.2168,  0.5659],
        [ 0.6603,  0.5957,  0.8375,  ...,  0.2274,  0.4523,  0.4665],
        [ 0.5262,  0.4223,  0.5009,  ...,  0.5734,  0.3151, …
Run Code Online (Sandbox Code Playgroud)

python pytorch loss-function

2
推荐指数
1
解决办法
5068
查看次数