mongo的常用操作

mongo常用操作 mongo基本使用 阅读详情
查询 name = "bruce" 的数据
db.users.find({ name : "bruce" });

条件操作符
$gt : >
$lt : <
$gte: >=
$lte: <=
$ne : !=、<>
$in : in
$nin: not in
$all: all
$not: 反匹配(1.3.3及以上版本)

查询 name <> "bruce" and age >= 18 的数据
db.users.find({name: {$ne: "bruce"}, age: {$gte: 18}});

查询 creation_date > '2010-01-01' and creation_date <= '2010-12-31' 的数据
db.users.find({creation_date:{$gt:new Date(2010,0,1), $lte:new Date(2010,11,31)});

查询 age in (20,22,24,26) 的数据
db.users.find({age: {$in: [20,22,24,26]}});

查询 age取模10等于0 的数据
db.users.find('this.age % 10 == 0');
或者
db.users.find({age : {$mod : [10, 0]}});

匹配所有
db.users.find({favorite_number : {$all : [6, 8]}});
可以查询出{name: 'David', age: 26, favorite_number: [ 6, 8, 9 ] }
可以不查询出{name: 'David', age: 26, favorite_number: [ 6, 7, 9 ] }

查询不匹配name=B*带头的记录
db.users.find({name: {$not: /^B.*/}});
查询 age取模10不等于0 的数据
db.users.find({age : {$not: {$mod : [10, 0]}}});

#返回部分字段
选择返回age和_id字段(_id字段总是会被返回)
db.users.find({}, {age:1});
db.users.find({}, {age:3});
db.users.find({}, {age:true});
db.users.find({ name : "bruce" }, {age:1});
0为false, 非0为true

选择返回age、address和_id字段
db.users.find({ name : "bruce" }, {age:1, address:1});

排除返回age、address和_id字段
db.users.find({}, {age:0, address:false});
db.users.find({ name : "bruce" }, {age:0, address:false});

数组元素个数判断
对于{name: 'David', age: 26, favorite_number: [ 6, 7, 9 ] }记录
匹配db.users.find({favorite_number: {$size: 3}});
不匹配db.users.find({favorite_number: {$size: 2}});

$exists判断字段是否存在
查询所有存在name字段的记录
db.users.find({name: {$exists: true}});
查询所有不存在phone字段的记录
db.users.find({phone: {$exists: false}});

$type判断字段类型
查询所有name字段是字符类型的
db.users.find({name: {$type: 2}});
查询所有age字段是整型的
db.users.find({age: {$type: 16}});

对于字符字段,可以使用正则表达式
查询以字母b或者B带头的所有记录
db.users.find({name: /^b.*/i});

$elemMatch(1.3.1及以上版本)
为数组的字段中匹配其中某个元素

Javascript查询和$where查询
查询 age > 18 的记录,以下查询都一样
db.users.find({age: {$gt: 18}});
db.users.find({$where: "this.age > 18"});
db.users.find("this.age > 18");
f = function() {return this.age > 18} db.users.find(f);

排序sort()
以年龄升序asc
db.users.find().sort({age: 1});
以年龄降序desc
db.users.find().sort({age: -1});

限制返回记录数量limit()
返回5条记录
db.users.find().limit(5);
返回3条记录并打印信息
db.users.find().limit(3).forEach(function(user) {print('my age is ' + user.age)});
结果
my age is 18
my age is 19
my age is 20

限制返回记录的开始点skip()
从第3条记录开始,返回5条记录(limit 3, 5)
db.users.find().skip(3).limit(5);

查询记录条数count()
db.users.find().count();
db.users.find({age:18}).count();
以下返回的不是5,而是user表中所有的记录数量
db.users.find().skip(10).limit(5).count();
如果要返回限制之后的记录数量,要使用count(true)或者count(非0)
db.users.find().skip(10).limit(5).count(true);

分组group()
假设test表只有以下一条数据
{ domain: "www.mongodb.org"
, invoked_at: {d:"2009-11-03", t:"17:14:05"}
, response_time: 0.05
, http_action: "GET /display/DOCS/Aggregation"
}
使用group统计test表11月份的数据count:count(*)、total_time:sum(response_time)、 avg_time:total_time/count;
db.test.group(
{ cond: {"invoked_at.d": {$gt: "2009-11", $lt: "2009-12"}}
, key: {http_action: true}
, initial: {count: 0, total_time:0}
, reduce: function(doc, out){ out.count++; out.total_time+=doc.response_time }
, finalize: function(out){ out.avg_time = out.total_time / out.count }
} );

[
{
"http_action" : "GET /display/DOCS/Aggregation",
"count" : 1,
"total_time" : 0.05,
"avg_time" : 0.05
}
]

-java api--------------------------------------------------
使用mongoDB需要导入以下类,当然不是全部需要,用到的类就导入。
import com.mongodb.Mongo;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;
import com.mongodb.DBCursor;
import com.mongodb.ObjectId;

类转换
当把一个类对象存到mongoDB后,从mongoDB取出来时使用setObjectClass()将其转换回原来的类。
public class Tweet implements DBObject {

}
Tweet myTweet = new Tweet();
myTweet.put("user", "bruce");
myTweet.put("message", "fun");
myTweet.put("date", new Date());
collection.insert(myTweet);
//转换
collection.setObjectClass(Tweet);
Tweet myTweet = (Tweet)collection.findOne();

默认ID
当保存的对象没有设置ID时,mongoDB会默认给该条记录设置一个ID("_id")。
当然你也可以设置自己指定的ID,如:(在mongoDB中执行用db.users.save({_id:1,name:'bruce'});)
BasicDBObject bo = new BasicDBObject();
bo.put('_id', 1);
bo.put('name', 'bruce');
collection.insert(bo);

权限
判断是否有mongoDB的访问权限,有就返回true,否则返回false。
boolean auth = db.authenticate(myUserName, myPassword);

查看mongoDB数据库列表
Mongo m = new Mongo();
for (String s : m.getDatabaseNames()) {
System.out.println(s);
}


查看当前库下所有的表名,等于在mongoDB中执行show tables;
Set<String> colls = db.getCollectionNames();
for (String s : colls) {
System.out.println(s);
}

查看一个表的索引
List<DBObject> list = coll.getIndexInfo();
for (DBObject o : list) {
System.out.println(o);
}

删除一个数据库
Mongo m = new Mongo();
m.dropDatabase("myDatabaseName");

建立mongoDB的链接
Mongo m = new Mongo("localhost", 27017);
DB db = m.getDB("myDatabaseName"); //相当于库名
DBCollection coll = db.getCollection("myUsersTable");//相当于表名

#查询数据
查询第一条记录
DBObject firstDoc = coll.findOne();
findOne()返回一个记录,而find()返回的是DBCursor游标对象。

查询全部数据
DBCursor cur = coll.find();
while(cur.hasNext()) {
System.out.println(cur.next());
}

查询记录数量
coll.find().count();
coll.find(new BasicDBObject("age", 26)).count();

设置条件查询
BasicDBObject condition = new BasicDBObject();
condition.put("name", "bruce");
condition.put("age", 26);
coll.find(condition);

查询部分数据块
DBCursor cursor = coll.find().skip(0).limit(10);
while(cursor.hasNext()) {
System.out.println(cursor.next());
}

比较查询(age > 50)
BasicDBObject condition = new BasicDBObject();
condition.put("age", new BasicDBObject("$gt", 50));
coll.find(condition);
比较符
"$gt": 大于
"$gte":大于等于
"$lt": 小于
"$lte":小于等于
"$in": 包含
//以下条件查询20<age<=30
condition.put("age", new BasicDBObject("$gt", 20).append("$lte", 30));

#插入数据
批量插入
List datas = new ArrayList();
for (int i=0; i < 100; i++) {
BasicDBObject bo = new BasicDBObject();
bo.put("name", "bruce");
bo.append("age", i);
datas.add(bo);
}
coll.insert(datas);

正则表达式
查询所有名字匹配 /joh?n/i 的记录
Pattern pattern = Pattern.compile("joh?n", CASE_INSENSITIVE);
BasicDBObject query = new BasicDBObject("name", pattern);
DBCursor cursor = coll.find(query);
-----------------------------------------------------------------

模糊查询:
db.analytics.find({referer_url: /http:.*/i});
db.analytics.find({start_time:{$gte:new Date(2010,5,28),$lt:new Date(2010,5,29)},referer_url:/http:.*/}).count()

正则表达式
查询所有名字匹配 /joh?n/i 的记录
Pattern pattern = Pattern.compile("joh?n", CASE_INSENSITIVE);
BasicDBObject query = new BasicDBObject("name", pattern);
DBCursor cursor = coll.find(query);
condition.put("name", "bruce");
condition.put("age", 26);
coll.find(condition);

查询部分数据块
DBCursor cursor = coll.find().skip(0).limit(10);
while(cursor.hasNext()) {
System.out.println(cursor.next());
}

比较查询(age > 50)
BasicDBObject condition = new BasicDBObject();
condition.put("age", new BasicDBObject("$gt", 50));
coll.find(condition);
比较符
"$gt": 大于
"$gte":大于等于
"$lt": 小于
"$lte":小于等于
"$in": 包含
//以下条件查询20<age<=30
condition.put("age", new BasicDBObject("$gt", 20).append("$lte", 30));

#插入数据
批量插入
List datas = new ArrayList();
for (int i=0; i < 100; i++) {
BasicDBObject bo = new BasicDBObject();
bo.put("name", "bruce");
bo.append("age", i);
datas.add(bo);
}
coll.insert(datas);

正则表达式
查询所有名字匹配 /joh?n/i 的记录
Pattern pattern = Pattern.compile("joh?n", CASE_INSENSITIVE);
BasicDBObject query = new BasicDBObject("name", pattern);
DBCursor cursor = coll.find(query);
--------
日期:
db.cpc_common.cpc_click_log.find({date_created:{$gte:new Date(2010,5,16)}});

---------------------------
建立collection db.createCollection("mycoll", {size:10000000});
----------

索引:db.mycollection.ensureIndex( {active:1} );


一个例子:

<?php

$host = "192.168.190.19";
$port = "27017";
$username = "ucenter";
$password = "123456";
$dbname = "UcenterService";
//第一种方式
$m = new Mongo($host);
$db = $m->$dbname;
$rs = $db->authenticate($username, $password);
//第二种方式


$like_table = "test_mongo";
$test_mongo = $db->$like_table;

$insert_data = array(
"name" => 'garnono',
'age' => 2,
'color' => array(
'first' => 'red',
'second' => 'blue',
),
'num' => (object)array(
'x' => 6,
'y' => 9,
),
);
//insert
$test_mongo->insert($insert_data);
$id = $insert_data['_id'];
//save


//findOne
$findOne = $test_mongo->findOne(array('_id' => new MongoId($id)));
//find


$newkey = array(
'food'=>array(
'bread',
'meet',
),
);
$test_mongo->update(array('name'=>'garnono'), $newkey);

$test_mongo->remove(array('name'=>'garnono'), true);
?>

MONGO常用操作指令 db.collection.update () 方法返回一个WriteResult()对象,其中包含操作的状态。例如,您不能为每个字段指定不同的排序规则,或者如果对排序执行查找,则不能对查找使用一种排序规则,而对排序使用另一种排序规则。指定用于游标的处理操作的时间限制(以毫秒为单位)。如果没有为集合或操作指定排序规则,则MongoDB使用先前版本中使用的简单二进制比较进行字符串比较。允许用户为字符串比较指定特定于语言的规则,例如字母大写和重音符号的规则。),则该操作将使用为集合指定的排序规则。 阅读详情

相关推荐

区块链技术在碳足迹数据存证与溯源中的应用深度解析

消费者扫描产品上的二维码,即可通过区块链浏览器查询到该产品的数字碳标签,并追溯其从茶园到货架的每一步碳足迹数据,以及这些数据是如何被智能合约自动计算和认证的,从而建立起强大的品牌信任。如果说哈希链解决了数据的“存”与“证”的问题,那么智能合约则解决了数据“用”与“管”的自动化问题。综上所述,虽然针对“碳足迹数据可追溯性”这一特定应用场景的公开、标准化的性能基准案例尚不丰富,但现有研究和企业级解决方案(特别是联盟链)已经证明,通过合理的技术选型和架构设计,区块链的性能可以满足实际商业需求。

百态·数智思维 | 聚焦大数据、量化与未来AI 1106

mongo常用的操作 有点乱

<br />shell#查询<br /> 查询 name = "bruce" 的数据<br /> db.users.find({ name : "bruce" });<br /><br /> 条件操作符<br /> $gt : ><br /> $lt : <<br /> $gte: >=<br /> $lte: <=<br /> $ne : !=、<><br /> $in : in<br /> $nin: not in<br /> $all: all<br /> $not: 反匹配(

jessicway的专栏 1万+

tree_sitter多语言解析器配置实战指南

本文是一份详细的Tree-sitter多语言解析器配置实战指南。文章从零开始,手把手指导如何搭建Python环境、安装指定版本的tree-sitter库、下载并编译多种语言的语法规则,最终构建一个统一的解析器库。通过实战代码演示了如何初始化解析器、解析代码并遍历语法树,旨在帮助开发者高效处理多语言代码分析任务,并分享了高级技巧与常见问题排坑经验。

weixin_29245767的博客 267

mongodb常用的语法

mongodb常用语法

fang0604631023的博客 2617

OData Request:Create Entity 在 ABAP OData Client Proxy 中的工程化实践

文章摘要 本文针对具备 SAP Gateway 与 ABAP 开发经验的读者,详细讲解如何通过 ABAP OData Client Proxy 实现 OData 服务的 Create 操作。首先对比了 OData V2 与 V4 的 Create 规范差异,强调键、集合 URL 和请求体的标准化要求。随后介绍了 ABAP Client Proxy 的编程模型,包括 Client Proxy、Entity List Resource 和 Create Request/Response 三个核心对象,并提供了完

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 247

ArcGIS Pro符号化教程

本文详细介绍了ArcGIS Pro的软件设置和符号化操作步骤。主要包括:1)设置默认工程目录和关闭地图自动加载;2)创建新工程的基本流程;3)点要素的单一符号化方法,包括样式修改和图层调整;4)图表符号显示过滤器的使用,涉及字段添加、图表类型选择和背景设置。文章还提供了操作截图和数据下载链接,适合GIS初学者学习ArcGIS Pro的基础符号化操作。

WwLK123的博客 548

MongoDB aggregate

聚合查询 // aggregate里的各种查询可以组合使用 // 聚合查询 Entry.aggregate([ { // $match 筛选,和find查询条件一致 $match: { $or: [{'showcase.type': CONSTANT.contestType.STANDARD}], 'sho...

Irene-li 1106

下载MNIST数据集并使用python将数据转换成NumPy数组(源码解析)

下载MNIST数据集并使用python将数据转换成NumPy数组首先来分析init_mnist函数接下来继续分析load_mnist函数实现数据集转换的python脚本的代码显示MNIST图像并确认数据 下载MNIST数据集并将数据转换成NumPy数组的Python脚本里面最重要的就是load_mnist函数,其他项目想要调用数据集的话,就可以调用load_mnist函数,得到一个字典类型的数据,字典的值是一个Numpy数组。 这些过程是如何实现的,现在开始逐字逐句分析源码: 在load_mnist函数中第

及时总结 4268

MongoDB find查询语句详解

mongodb find查询与SQL查询对比子健筛选复杂查询查询条件操作符正则表达式子项查询排序分页 与SQL查询对比 作用 SQL MongoDB 所有记录 SELECT * FROM users db.users.find() age=18的记录 SELECT * FROM users WHERE age=33 db.users.find({age:18}) 子键(字段...

weixin_43886133的博客 1597

31、双相不锈钢直齿轮加工与性能研究及人工神经网络在焊接中的应用

本文研究了双相不锈钢直齿轮在不同加工方法(WEDM与滚齿加工)下的磨损行为,分析了表面粗糙度、齿厚变化、磨损率及润滑性能随转速的变化规律,并对比了两种工艺的优劣。同时,探讨了人工神经网络(ANN)在AA7050铝合金搅拌摩擦焊中的应用,通过建立工艺参数与焊接质量之间的预测模型,实现了对焊缝硬度和峰值温度的准确预测。研究为高性能齿轮制造和铝合金焊接提供了理论支持和技术参考,并提出了未来在润滑优化、加工工艺改进及智能控制方面的研究方向。

ggg99的专栏 150

Joule 终于会说 ABAP 了:从 ADT 提效到 ABAP AI SDK + ISLM 自建企业级 AI 场景的落地路线

生成结构化摘要(故障现象、初步原因、处理动作、备件消耗)自动给出建议分类(电气、机械、软件、网络)把摘要回写到工单抬头,方便后续统计与知识沉淀如果你用 CAP 来做这类服务,通常会在 Node.js 层封装一个对 AI Hub 的调用,再通过 OData 或 Event 把结果写回 SAP。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 342

mongo 正则取反

db.LOG_ACCESS.find({HTTP_USER_AGENT:{$not:/(android|ios|mozilla|apache)/i}},{HTTP_USER_AGENT:1}) ...

chouyada5278的博客 818

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Mongo常用操作

mongo数据库常用操作 1.连接数据库 mongo ip:port/databaseName -u user -p password example:mongo 127.0.0.1:31000/admin -u siteRootAdmin -p mongodb_password 2.数据库 2.1显示数据库 show dbs 2.2创建/使用数据库 use databaseName 2.3删除数...

Jonebuqi的博客 300

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

mongo常用操作总结

MongDB常用操作总结 MongoDB的安装详见另外教程 一、mongoDB入门 操作 对应的命令 显示数据库列表 show dbs 切换/创建数据库当创建一个集合(table)的时候会自动创建当前数据库 use yourDB 显示当前数据库中的集合类似关系数据库中的表 show collections Help查看命令提示 db.help() db.yourColl.help()db.youColl.find().help(); 删除当前使用数据库 db.dropData

TonyOliver的博客 395

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

mongo常用的操作

shell#查询 查询 name = "bruce" 的数据 db.users.find({ name : "bruce" }); 条件操作符 $gt : > $lt : $gte: >= $lte: $ne : !=、 $in : in $nin: not in $all: all $not: 反匹配(1.3.3及以上版本) 查询 name = 18 的数据

笑看人生的专栏 762

Mongo 常用操作

Mongo 常用操作 数据库相关 show dbs; #创建/切换数据库 use test; #查看数据库状态 db.stats(); #删除数据库 db.dropDatabase(); 集合相关 # 创建集合 db.createCollection("text"); #重命名 db.text.renameCollection("test"); #删除 db.test.drop(); 文档 文档数据操作 #增加 db.test.insert({title:"怪物猎人世界评测","rank":2,"tag

lvoye的博客 158

Mongo常用操作汇总

什么是MongoDB ? MongoDB 是由C++语言编写的,是一个基于分布式文件存储的开源数据库系统。 在高负载的情况下,添加更多的节点,可以保证服务器性能。 MongoDB 旨在为WEB应用提供可扩展的高性能数据存储解决方案。 MongoDB 将数据存储为一个文档,数据结构由键值(key=>value)对组成。MongoDB 文档类似于 JSON 对象。字段值可以包含其他文档,数组及文...

heima201907的博客 454

mongo shell 常用操作

复制集群信息 [root@mongo2 ~]# cat /etc/hosts 10.xx.xx.01 mongo1 member1.mongo.com 10.xx.xx.02 mongo2 member2.mongo.com 10.xx.xx.03 mongo3 member3.mongo.com ---------------------------------------------------------- mongo shell 常用操作 [root@mongo2 ~]# mongo --po

GongMeiyan的博客 310

mongo开启慢日志及常用命令行操作、数据备份

1.setProfilingLevel是针对库进行设置的,需要use切换到指定库执行命令,只会对该库生效,其他库不会有任何影响;通过连接命令行后执行语句开启慢查询,好处是不需要重启服务,但服务只要重启后就会失效;:指定 mongo的端口号,默认是 27017;如:连接指定的主机的mongo库;–host:指定连接的主机地址;库名:用于指定账号密码认证的库;:指定 mongo的主机地址;–port:指定连接的端口;: 列出指定集合的所有索引;:指定需要备份的数据库;:指定连接的用户名;:指定需要备份的集合;

诚不我欺的博客 1164

mongo 常用操作指令

一 启动mongodb: [root@localhost centos1_user1]# Systemctl start mongod 二 查看mongodb状态: [root@localhost centos1_user1]# Systemctl status mongod 三 关闭mongodb: [root@localhost centos1_user1]# Systemctl stop mongod 四 查看mongodb版本信息: [root@localhost centos1_user1]# M

cang23456_博客 899
上一篇: mongodb如何判断一次操作是否成功
下一篇: MongoDB忘记密码、批量插入等命令
CsharpGame
博客等级 码龄21年 11粉丝 1原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值