我正在尝试实现一种可以按记录名称而不是 ID 进行搜索的查询类型。这是它在 中的定义query_type.rb。
# Get game by name
field :game_by_name, Types::GameType, null: false do
argument :name, String, required: true
end
def game_by_name(name:)
Game.where(name: name) //find a game using the name attribute
end
Run Code Online (Sandbox Code Playgroud)
但是当我跑步时:
query {
gameByName(name: "League of Legends") {
id
name
}
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误。
Failed to implement Game.id, tried:\n\n
- `Types::GameType#id`, which did not exist\n
- `Game::ActiveRecord_Relation#id`, which did not exist\n
- Looking up hash key `:id` or `\"id\"` on `#<Game::ActiveRecord_Relation:0x00007f5644442888>`, but it wasn't a Hash\n\n …Run Code Online (Sandbox Code Playgroud) 我最近一直在与 numba 作斗争。直接从 numba 文档复制此代码片段,它工作正常:
@guvectorize([(int64[:], int64, int64[:])], '(n),()->(n)')
def g(x, y, res):
for i in range(x.shape[0]):
res[i] = x[i] + y
a = np.arange(5)
g(a,2)
Run Code Online (Sandbox Code Playgroud)
给 y 一个数组会产生一个网格。对 2 个数组求和是我经常做的事情,所以这是我通过修改代码片段得出的代码。
@guvectorize([(int64[:], int64[:], int64[:])], '(n),(n)->(n)')
def add_arr(x, y, res):
for i in range(x.shape[0]):
res[i] = x[i] + y[i]
p = np.ones(1000000)
q = np.ones(1000000)
r = np.zeros(1000000)
add_arr(p,q)
Run Code Online (Sandbox Code Playgroud)
这给了我错误:
TypeError Traceback (most recent call last)
<ipython-input-75-074c0fd345aa> in <module>()
----> 1 add_arr(p,q)
TypeError: ufunc 'add_arr' not supported for the input types, …Run Code Online (Sandbox Code Playgroud) 当不使用 KL 散度项时,VAE 几乎完美地重建了 mnist 图像,但在提供随机噪声时无法正确生成新图像。
当使用 KL 散度项时,VAE 在重建和生成图像时给出相同的奇怪输出。
这是损失函数的pytorch代码:
def loss_function(recon_x, x, mu, logvar):
BCE = F.binary_cross_entropy(recon_x, x.view(-1, 784), size_average=True)
KLD = -0.5 * torch.sum(1 + logvar - mu.pow(2) - logvar.exp())
return (BCE+KLD)
Run Code Online (Sandbox Code Playgroud)
recon_x 是重建图像,x 是 original_image,mu 是均值向量,而 logvar 是包含方差对数的向量。
这里出了什么问题?提前致谢 :)
bayesian-networks autoencoder deep-learning pytorch loss-function
我正在尝试使用 node.js 匹配服务器构建一个简单的 flutter 聊天应用程序。我已经处理了几个小时了,但我无法让应用程序与服务器连接。
这是 Node.js 服务器:
var express=require('express');
var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);
var allClients = {};
io.on('connection', function (socket) {
io.to(socket.id).emit('userCount', Object.keys(allClients).length);
console.log(socket.id,'joined');
//match making logic
});
var port = 8080;
console.log(port);
server.listen(port);
Run Code Online (Sandbox Code Playgroud)
颤振连接代码:
//Find a match for the user
void findMatch() async {
SocketIO socketIO = SocketIOManager().createSocketIO("http://192.168.0.32:8080", "/");
print('Created');
await socketIO.init(); //code execution pauses indefinitely at this line
print('Initialized');
await socketIO.connect();
print('Connected');
socketIO.sendMessage('new user', data);
socketIO.subscribe('match found', (data) async …Run Code Online (Sandbox Code Playgroud) 单击"hi"和"helo"按钮必须'.admin-text'根据计划更改相应文本的内容,但只需将其更改为'undefined'.
var admin_text = document.querySelector('.admin-text');
var infra_btns = [document.getElementById('hi'), document.getElementById('helo')];
var infra_html = ["<p>hi</p>", "<p>helo</p>"];
for(var i = 0; i < 2; i++)
{
infra_btns[i].addEventListener('click', function() {
admin_text.innerHTML = infra_html[i];
});
}Run Code Online (Sandbox Code Playgroud)
<div class="admin">
<div class="admin-nav">
<button class="adminbtns" id="hi">hi</button>
<button class="adminbtns" id="helo">helo</button>
</div>
<div class="admin-text">
</div>
</div>Run Code Online (Sandbox Code Playgroud)
autoencoder ×1
flutter ×1
graphql ×1
html ×1
javascript ×1
node.js ×1
numba ×1
python ×1
pytorch ×1
socket.io ×1