所以基本上我有一个愿望清单,我有一堆产品,我想使用放置请求将它们添加到愿望清单产品数组中(顺便说一句,我正在使用邮递员)。这是愿望清单模式,是的,我知道数据库中的文档名称是“愿望清单”……我讨厌拼写错误
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var ObjectId = mongoose.Schema.Types.ObjectId;
var whishList = new Schema({
title: {type: String, default: "Cool whishlist"},
products:[{type: ObjectId, ref:'Product'}]
});
module.exports = mongoose.model('WhishList', whishList);
Run Code Online (Sandbox Code Playgroud)
这是产品架构
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var product = new Schema({
title: String,
price: Number,
likes: {type: Number, default: 0}
});
module.exports = mongoose.model('Product', product);
Run Code Online (Sandbox Code Playgroud)
现在这是我试图运行的代码
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var mongoose = require('mongoose');
var db = …Run Code Online (Sandbox Code Playgroud) 所以我正在阅读 pytorch 文档,试图学习和理解一些东西(因为我是机器学习的新手),我发现torch.bernoulli()并且我理解(我想念理解它)它近似于具有 1 到 1 之间的值的张量0 到 1 或 0 取决于值(例如经典学校小于 0.5 = 0 ,大于或等于 0.5 = 1)
经过我自己的一些实验,是的,它按预期工作
>>>y = torch.Tensor([0.500])
>>>x
>>> 0.5000
[torch.FloatTensor of size 1]
>>> torch.bernoulli(x)
>>> 1
[torch.FloatTensor of size 1]
Run Code Online (Sandbox Code Playgroud)
但是当我查看文档时有些奇怪
>>> a = torch.Tensor(3, 3).uniform_(0, 1) # generate a uniform random matrix with range [0, 1]
>>> a
0.7544 0.8140 0.9842
**0.5282** 0.0595 0.6445
0.1925 0.9553 0.9732
[torch.FloatTensor of size 3x3]
>>> torch.bernoulli(a)
1 1 1
**0** 0 …Run Code Online (Sandbox Code Playgroud) python probability-theory torch probability-distribution pytorch