小编Jun*_*nge的帖子

如何查询维基数据中的“也称为”

我想知道如何使用别名(“也称为”)查询维基数据

现在我正在尝试

SELECT ?item
WHERE
{
?item rdfs:aliases ?alias.
FILTER(CONTAINS(?alias, "Angela Kasner"@en))
}
LIMIT 5
Run Code Online (Sandbox Code Playgroud)

如果我替换rdfs:aliases为,这只是一个有效的查询rdfs:labels

我正在尝试这个,因为 Help: Aliases 说别名可以像标签一样搜索,但我找不到任何其他资源,也找不到示例。

alias rdfs sparql wikidata sparqlwrapper

9
推荐指数
1
解决办法
2298
查看次数

Keras 总是预测相同的输出

Keras 总是会为我给出的每个输入预测相同的类。目前有四个类别。\n新闻、天气、体育和经济。

\n\n

训练集由许多不同的文本组成,其中类别与其主题相同。分类为新闻和体育的文本比天气和经济的文本多得多。

\n\n
    \n
  • 新闻:12112 条短信
  • \n
  • 天气:1685 条短信
  • \n
  • 体育:13669 条短信
  • \n
  • 经济:1282 条文本
  • \n
\n\n

我本以为该模型会偏向体育和新闻,但它完全偏向天气,每个输入都被分类为天气,置信度至少为 80%。

\n\n

只是为了增加我的困惑:在训练注释器时,准确度分数将达到 95% 到 100%(原文如此!)。我想我在这里做了一些非常愚蠢的事情,但我不知道那是什么。

\n\n

这就是我对分类器的称呼。它在 Windows 电脑上的 python 3 上运行。

\n\n
with open(\'model.json\') as json_data:\nmodel_JSON = json.load(json_data)\n\nmodel_JSON = json.dumps(model_JSON) \nmodel = model_from_json(model_JSON)\n\nmodel.load_weights(\'weights.h5\')\n\ntext = str(text.decode())   \nencoded = one_hot(text, max_words, split=" ")\n\ntokenizer = Tokenizer(num_words=max_words)\nmatrix = tokenizer.sequences_to_matrix([encoded], mode=\'binary\')\n\nresult = model.predict(matrix)\n\nlegende = ["News", "Wetter", "Sport", "Wirtschaft"]\nprint(str(legende))\nprint(str(result))\n\ncat = numpy.argmax(result)  \nreturn str(legende[cat]).encode()\n
Run Code Online (Sandbox Code Playgroud)\n\n

这就是我训练分类器的方法。我省略了从数据库获取数据的部分。这是在 Linux 虚拟机上完成的。\n我已经尝试更改丢失和激活,但没有任何反应。\n此外,我目前正在尝试使用更多纪元,但到目前为止这也没有帮助。

\n\n
max_words = 10000\nbatch_size=32\nepochs=15\n\nrows = cursor.fetchall()\n\nX = …
Run Code Online (Sandbox Code Playgroud)

python machine-learning prediction keras

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

AWS Cloudformation !Ref SecurityGroup 返回无效 ID

我想通过 cloudformation 部署具有 SecurityGroup 入口规则的 SecurityGroup。

我目前在 yaml 文件中使用它:

Security
  Type: AWS::EC2::SecurityGroup
  Properties:
    GroupDescription: Securitygroup with access to itself
SecurityIngress:
  Type: AWS::EC2::SecurityGroupIngress
  Properties:
    GroupId: !Ref Security
    SourceSecurityGroupId: !Ref Security
    IpProtocol: tcp
    FromPort: -1
Run Code Online (Sandbox Code Playgroud)

这会给我一个错误,指出 SucurityGroupId 格式错误。创建 SecurityIngress 时会发生该错误。请注意,我已将堆栈名称更改为“Stackname”。

无效 ID:“Stackname-Security-N12M8127812”(需要“sg-”)

所以我猜 !Ref 不会返回 SecurityGroup 的 ID,而是返回名称。有没有办法获取id?

amazon-web-services aws-cloudformation aws-security-group

4
推荐指数
1
解决办法
5464
查看次数