Server API is based on HTTPS and JSON. Clients send messages to the server following the API, and handle
responses from the server.
For overview and further details on the requirements of the system, see the course project work
requirements elsewhere. This document only documents the API that must be supported by server and
client implementations.
Please note that automatic tests will be conducted to verify the functionality. Therefore, both the server
and the client MUST follow this API. Failing to do so fails the tests. If specific input/output is given in the
requirements, it must be the same in your coursework.
Assignment specifications
Minimum requirements
This section provides the minimum requirements for the coursework, ALL requirements must be completed
REQ1 All text in HTTP body MUST be UTF-8.
REQ2 All content in the HTTP requests and responses MUST be JSON except for the error messages from
server which may be text.
REQ3 All dates and times in JSON content MUST follow the ISO 8601 date format in UTC time zone with
milliseconds, e.g. 2020-12-21T07:57:47.131Z.
REQ4 All times must follow the following pattern: “2020-12-21T07:57:47.123Z”
REQ5 HTTP Headers MUST contain the content size in bytes and content type using standard HTTP
headers.
REQ6 HTTP header Content-Type MUST be “application/json”.
REQ7 Database MUST be used to store all user sent data
1.1. Feature 1: User can send inform others about a sightseeing location
URL: https://server.url/info
Request type: POST
Response code for successfully operation: 200
Response code failed operation: 400-499
Header information that must be included in minimum:
- Content-Length: size of the content
- Content-Type: application/json
Authorization: only registered users can perform this operation
Data format for posting a sightseeing location:
{
“locationName” : “Oulun Tuomiokirkko”,
“locationDescription”: “The church of oulu”,
“locationCity”: “Oulu”,
“locationCountry” : “Finland”,
“locationStreetAddress”: “Kirkkokatu 3 A”,
“originalPoster” : ”Pekka”,
“originalPostingTime” : “2020-12-21T07:57:47.123Z”
}
Where:
- locationName is the name of the location and can be chosen by the user
- locationDecription where user can provide a short freely written description about the location
- locationCity is the name of the city where the sightseeing location is
- locationStreetAddress is the local address for the sightseeing location
- originalPoster is the name of the person who sent the location information (user’s chosen
nickname taken from the user’s profile, not to be mixed with login username)
- originalPostingTime time when the user sent the location information, represented in UTC
NOTE: The server doesn’t care whether same location has been sent multiple times so you must make sure
every location information is unique even it has the same information
1.2. Feature 2: Get sightseeing locations posted by users
URL: https://server.url/info
Request type: GET
Response code for successfully operation: 200
Response code failed operation: 400-499
Header information that must be included in minimum:
- Content-Length: size of the content
- Content-Type: application/json
Authorization: only registered users can perform this operation
Data format for sending locations back to client:
[
{
“locationName” : “Oulun Tuomiokirkko”,
“locationDescription”: “The church of oulu”,
“locationCity”: “Oulu”,
“locationCountry” : “Finland”,
“locationStreetAddress”: “Kirkkokatu 3 A”,
“originalPoster” : ”Pekka”,
“originalPostingTime” : “2020-12-21T07:57:47.123Z”
},
{
“locationName” : “Nallikari Beach”,
“locationDescription”: “Local beach at Nallikari”,
“locationCity”: “Oulu”,
“locationCountry” : “Finland”,
“locationStreetAddress”: “Leiritie 10”,
“originalPoster” : ”Anna”,
“originalPostingTime” : “2023-12-21T07:57:47.123Z”
}
]
NOTE: Server MAY also response with 204 and empty response body if there are no coordinates to deliver
to the client.
1.3. Feature 3: Register and authenticate
URL: https://server.url/registration
Request type: POST
Response code for successfully operation: 200
Response code failed operation: 400-499
Header information that must be included in minimum:
- Content-Length: size of the content
- Content-Type: application/json
Authorization: N/A (user can register an account without previous credentials)
Data format for registering user:
{
“userName” : “username”,
“password” : “password”,
“email” : “user.email@for-contacting.com”,
“userNickname” : “Pekka”
}
Description:
Server MUST NOT accept other than registration requests from unauthorized clients. Client MUST send
passwords using HTTPS. Passwords MUST not be sent over insecure HTTP connections. Server MUST not
store the plain password, but only store a hash of it. A good hash function MUST be used to make sure
hashed passwords are secured and as unique as possible to avoid collisions.
For other than registration requests, users MUST be authenticated using Basic HTTP authentication (see
References). Authentication MUST be done over HTTPS using the Authorization header, where
username:password string MUST be UTF-8.
1.4. Feature 4: User can attach coordinate information to the sightseeing
data
URL: https://server.url/info
Request type: POST
Response code for successfully operation: 200
Response code failed operation: 400-499
Header information that must be included in minimum:
- Content-Length: size of the content
- Content-Type: application/json
Authorization: only registered users can perform this operation
Data format for posting a sightseeing location:
{
“locationName” : “Oulun Tuomiokirkko”,
“locationDescription”: “The church of oulu”,
“locationCity”: “Oulu”,
“locationCountry” : “Finland”,
“locationStreetAddress”: “Kirkkokatu 3 A”,
“originalPoster” : ”Pekka”,
“originalPostingTime” : “2020-12-21T07:57:47.123Z”
, “latitude”: “65.0580507136066”,
“longitude”: “25.469414591526057”
}
Where:
- latitude and longitude represent a geolocation based on java html geolocation api (such as used in
google maps for example).
NOTE: Coordiates are not mandatory, if no coordinates exist for a sightseeing location, no coordinate
information is provided in a message when requested from the server.
Advanced API
Any of the following features successfully implemented (passes unit tests and matches requirements)
increases the assignment grade by 1. For example, if two additional features are implemented successfully,
the grade of the assignment 3. If all exercises are also successfully completed, the final course grade is 4.
Feature 5: Attach weather when sightseeing information is requested
URL: https://server.url/info
Request type: POST
Response code for successfully operation: 200
Response code failed operation: 400-499
Header information that must be included in minimum:
- Content-Length: size of the content
- Content-Type: application/json
Authorization: only registered users can perform this operation
Data format for posting a sightseeing location:
{
“locationName” : “Oulun Tuomiokirkko”,
“locationDescription”: “The church of oulu”,
“locationCity”: “Oulu”,
“locationCountry” : “Finland”,
“locationStreetAddress”: “Kirkkokatu 3 A”,
“originalPoster” : ”Pekka”,
“originalPostingTime” : “2020-12-21T07:57:47.123Z”
, “latitude”: “65.0580507136066”,
“longitude”: “25.469414591526057”,
“weather”:””
}
Where:
- weather is a integer, double or “1C” representation of weather given from the weather service
Other information:
- User can opt to attach weather information
- Weather information is based coordinate location
- Weather information is obtained from custom build service that provides basic weather
information based on coordinates
- The messages with weather information must contain temperature information from the location
specified in the request
- The weather service will be provided separately, the server must send the coordinates to the
weather service that will provide the weather information to be added to the coordinates
Feature 6: User can create sightseeing paths with custom tour message
URL: https://server.url/paths
Request type: POST
Response code for successfully operation: 200
Response code failed operation: 400-499
Header information that must be included in minimum:
- Content-Length: size of the content
- Content-Type: application/json
Authorization: only registered users can perform this operation
Data format for posting a tour:
{
“tour_name” : “Quick city center run”,
“tourDescription”: “15 minute tour in Oulu”,
“locations” :
[
{
“locationID”:”1”
}
]
}
Where:
- tour_name is a string name for the tour
- tourDescription is a string description of the tour
- locations is a JSONArray of locations in the tour
- locationID is an unique integer representing a specific location
URL: https://server.url/paths
Request type: GET
Response code for successfully operation: 200
Response code failed operation: 400-499
Header information that must be included in minimum:
- Content-Length: size of the content
- Content-Type: application/json
Authorization: only registered users can perform this operation
Data format for returning a tour:
[
{
“tour_name” : “Quick city center run”,
“tourDescription”: “15 minute tour in Oulu”,
“locations” :
[
{
“locationID”:”1”
“locationName” : “Oulun Tuomiokirkko”,
“locationDescription”: “The church of oulu”,
“locationCity”: “Oulu”,
“locationCountry” : “Finland”,
“locationStreetAddress”: “Kirkkokatu 3 A”,
“originalPoster” : ”Pekka”,
“originalPostingTime” : “2020-12-21T07:57:47.123Z”
}
]
}
]
Other information
- User can select certain locations (each location has an unique id) as a sightseeing path
- Path is not ordered but rather a “collection” of locations
- locations contain a jsonarray that has a list of locations based on their id (create id for your
message), there is no limit for locations other than how many locations a test adds
Feature 7: Sightseeing information can be updated
URL: https://server.url/info
Request type: POST
Response code for successfully operation: 200
Response code failed operation: 400-499
Header information that must be included in minimum:
- Content-Length: size of the content
- Content-Type: application/json
Authorization: only registered users can perform this operation
Data format for posting an update to an existing message:
{
“locationID”:”1”
“locationName” : “Oulun Tuomiokirkko”,
“locationDescription”: “The church of oulu”,
“locationCity”: “Oulu”,
“locationCountry” : “Finland”,
“locationStreetAddress”: “Kirkkokatu 3 A”,
“originalPoster” : ”Pekka”,
“originalPostingTime” : “2020-12-21T07:57:47.123Z”
}
Where:
- locationID is an unique integer representing a specific location (it needs to be given by the server
when the original location is posted)
Example server response for GET
[
{
“locationID”:”1”
“locationName” : “Oulun Tuomiokirkko”,
“locationDescription”: “The church of oulu”,
“locationCity”: “Oulu”,
“locationCountry” : “Finland”,
“locationStreetAddress”: “Kirkkokatu 3 A”,
“originalPoster” : ”Pekka”,
“originalPostingTime” : “2020-12-21T07:57:47.123Z”
“updatereason”: “just updating stuff”,
“modified”: 2024-1-21T07:57:47.123Z”
}
]
Where:
- originalPostingTime is the original timestamp of the location when it was posted first time
- updatereason is a string where user can state a reason for the update
- modified is a timestamp when the edit was made
Other information:
- User can send updates to the sightseeing locations user has sent
o The modified message must show a timestamp of the latest edit
- In order to identify any location, supply an ID (integer) with the message to provide the update to a
right message
- Whether user is allowed to update the message, the server needs to check if the user (not
nickname) has posted the danger message previously. Remember, the nickname is just nickname
user chooses for particular message, the real identificatory is the registered user
- User can give a reason for the update or leave the field empty (it still must be included in the
message when being updated and when retrieving updated messages from the server)
Feature 8: Server tracks how many times sightseeing location is “visited”
URL: https://server.url/info
Request type: POST
Response code for successfully operation: 200
Response code failed operation: 400-499
Header information that must be included in minimum:
- Content-Length: size of the content
- Content-Type: application/json
Authorization: only registered users can perform this operation
Data format for posting a visit to a site:
{
“locationID”:”1”
“locationVisitor” : “Pekka”
}
where
- locationID is unique integer for the location given by the server
- locationVisitor is a string representing a user
Example response to get request in info context:
[
{
“locationID”:”1”
“locationName” : “Oulun Tuomiokirkko”,
“locationDescription”: “The church of oulu”,
“locationCity”: “Oulu”,
“locationCountry” : “Finland”,
“locationStreetAddress”: “Kirkkokatu 3 A”,
“originalPoster” : ”Pekka”,
“originalPostingTime” : “2020-12-21T07:57:47.123Z”
“timesVisited”:”1”
}
]
where
- timesVisited is an integer representing how many times the place has been visited
URL: https://server.url/topfive
Request type: GET
Response code for successfully operation: 200
Response code failed operation: 400-499
Header information that must be included in minimum:
- Content-Length: size of the content
- Content-Type: application/json
Authorization: only registered users can perform this operation
Example response to get request in topfive context:
[
{
“locationID”:”12”
“locationName” : “Snägäri”,
“timesVisited”:”899”
},
{
“locationID”:”7”
“locationName” : “Lentokenttä”,
“timesVisited”:”100”
},
{
“locationID”:”2”
“locationName” : “Nallikari”,
“timesVisited”:”40”
},
{
“locationID”:”10”
“locationName” : “Kaupungintalo”,
“timesVisited”:”5”
},
{
“locationID”:”1”
“locationName” : “Oulun Tuomiokirkko”,
“timesVisited”:”1”
}
]
Other information:
- Server adds a counter to each sightseeing location to indicate how many times it has been
requested from the server
o Note that this only simulates the “visit counter”
- User can request “top 5 destinations” from the server and the server needs to send the 5 most
viewed locations to user
Extra Feature 9: AI location identification
URL: https://server.url/info
Request type: POST
Response code for successfully operation: 200
Response code failed operation: 400-499
Header information that must be included in minimum:
- Content-Length: size of the content
- Content-Type: application/json
Authorization: only registered users can perform this operation
Data format for posting a visit to a site:
{
“locationName” : “Oulun Tuomiokirkko”,
“locationDescription”: “ai_auto_fill”,
“locationCity”: “Oulu”,
“locationCountry” : “Finland”,
“locationStreetAddress”: “Kirkkokatu 3 A”,
“originalPoster” : ”Pekka”,
“originalPostingTime” : “2020-12-21T07:57:47.123Z”
, “latitude”: “65.0580507136066”,
“longitude”: “25.469414591526057”
}
Other information:
- the field with ai_auto_fill needs to be updated with AI response based on other information given
in the message
- the response must be at least 50 characters
- the test only checks if the description is provided in the returning message and if it is at least 50
characters long
- the description is manually checked in order to see whether the text is corresponding to the
location data and not just some random characters
- The AI component is chat4all open source AI that you can download and use in your own computer.
For instructions, see lecture video about AI and example codes are available in the extra section in
moodle.
Additional Quality Improvements
If the software quality is high enough, the final grade of the assignment can be increased by 1. Note that
these are evaluated by the teacher and there are no guidelines what is required in minimum. Here are
examples of the quality aspects we look for:
• Properly commented code/interfaces
• Usage of unit tests
• Old messages are archieved after certain amount of time (for example after 2 months the messages
are removed from the actual database to for example a text file or other database to prevent the
database becoming too large affecting the speed of it)
• System backup
• System recovery
• Clean code
相关推荐
C++构建高性能HTTPS RESTful JSON服务器:从原理到工程实践
在构建现代网络服务时,高性能与安全性是核心诉求。异步I/O模型通过非阻塞操作和事件驱动机制,允许单线程或少量线程高效处理海量并发连接,这是实现高吞吐、低延迟服务的基础原理。其技术价值在于最大化利用系统资源,尤其适合嵌入式、边缘计算及高并发后端等对资源敏感的场景。结合TLS/SSL协议保障数据传输安全,以及JSON作为轻量级数据交换标准,可以构建出既安全又高效的数据通道。本文以C++为核心,详细阐述了如何利用Boost.Asio、OpenSSL和nlohmann/json等库,从零搭建一个生产就绪的HTTPS
10分钟搞定JSON-Server数据加密:从明文传输到HTTPS安全防护
你还在担心本地模拟API的数据安全吗?使用JSON-Server时,默认的HTTP传输可能导致敏感数据在传输过程中被窃取。本文将带你通过三个步骤实现数据加密传输,无需复杂配置,普通用户也能轻松掌握。读完本文你将学会: - 识别JSON-Server默认传输的安全风险 - 使用中间件实现请求数据加密 - 配置HTTPS实现传输层安全防护 - 验证加密效果的两种实用方法 ## 安全风险:为什么需要加...
Python爬虫实战:JSON解析与HTTPS代理应用
JSON作为轻量级数据交换格式,在Web开发中广泛用于前后端通信。其基于键值对的结构设计,配合Python的json模块可实现快速序列化与反序列化。在爬虫开发中,正确处理JSON数据是获取结构化信息的关键步骤,特别是在处理API接口响应时。HTTPS协议通过SSL/TLS加密保障通信安全,但爬虫常需处理证书验证问题,合理配置代理IP和请求头能有效应对反爬机制。本文以KFC门店数据爬取为例,演示requests库处理JSON响应、SSL证书验证的三种方案,以及高匿代理的实战配置技巧。
JSON Server
Table of contents https://github.com/iisunnyboy/user-app Sponsorship Getting started Routes Plural routes Singular routes Filter Paginate Sort Slice Operators Full-text search Rel...
SAP 移动类型简述
SAP系统中用于标志物料移动(收货/发货/转储/转储记帐)的三位的数字/字母 通常分几大类:收货 发货 转储 库房调整 常用的有: 收货类 (MB1C) 101 采购订单收货 103 采购订单收货至冻结状态 122 无采购订单退货 161 按退货采购订单退货 131 从生产订单 501 无采购订单收货 511 免费收货 发货类(MB1A) 201 成本中心消耗
《深入 UFS Explorer:自定义 RAID 配置指南》
UFS Explorer支持以虚拟模式组装任何受支持的RAID配置,以便后续访问其内容或恢复丢失数据。启动RAID构建器;向RAID构建器主内容区域的列表中添加RAID组件;为不可用组件插入占位符(需当前RAID级别支持且软件兼容);调整组件的准确顺序;在“虚拟RAID配置”区域设置RAID参数;以虚拟模式组装阵列各部分。程序主窗口“存储设备导航面板”中打开的任何存储设备(包括驱动器、逻辑卷、磁盘镜像、虚拟磁盘及其他复杂存储设备)均可作为RAID组件。
使用json-server-auth为json-server添加HTTP请求加密功能
在开发过程中,我们经常使用json-server来快速搭建REST API服务进行前端开发和测试。然而,默认情况下json-server并不提供任何安全机制,所有数据都是公开可访问的。本文将介绍如何通过json-server-auth为json-server添加请求加密和认证功能,确保只有授权用户才能访问数据。 ## json-server的安全性问题 json-server作为一个轻量级的R...
DDR4 硬件设计笔记
DDR4-DRAM是第四代支持双倍数据读取,支持随机位置存取的静态存储器。DDR4-DRAM的工作原理。DDR之T拓扑和Fly-by拓扑。DDR的硬件设计。DDR4 PCB设计要点介绍。DDR4之PCB走线间距的串扰评估。DDR4之内存通道(channel)和内存列(rank)。
ESP32 HTTPS Server 项目教程
ESP32 HTTPS Server 项目教程 1. 项目的目录结构及介绍 esp32_https_server/ ├── docs/ │ └── ... # 项目文档文件 ├── examples/ │ └── ... # 示例代码文件 ├── extras/ │ └── ... # 额外资源文件 ├── src/ │ └── ... # 源代码文件 ├── .edito...
通俗易通解释SLAM问题的数学描述:运动方程和观测方程
高翔博士在他的《视觉SLAM十四讲》中把SLAM问题的数学描述抽象成了两个数学方程,以下对此做个总结,并且对此做一些通俗易懂的解释: 一、方程的总体形式 作为理性层次的描述,我们引入数学方程来描述SLAM过程,其中第一个方程叫做运动方程、第二个方程叫做观测方程,想象一下我们在研究SLAM的时候肯定需要观测机器人(无人汽车、无人机等都可以统称为机器人)的运动(画面感很强哈哈),这样很容易理解并且记忆这两个方程的名称和意义: 二、变量的含义 我们看到,这两个方程中有大量的英文字母作为变量存在其中,下面介绍一下
独家开源|RK3588 平台 YOLOv5 Android 源码级解析:NPU 量化、多线程与目标跟踪实战
本文将带你完成一个完整的AI视觉项目:在搭载RK3588芯片的Android开发板上运行实时目标检测与跟踪应用。实战目标:成功运行官方YOLOV5摄像头实时检测案例技术深度:深入理解RKNN开发框架和源码实现核心技能:掌握NPU推理、多线程并发、目标跟踪等关键技术。
BankAPI API接口实战教程:JSON-RPC与HTTPS POST的完整实现指南
BankAPI是一个为金融机构设计的安全分布式消息系统,支持银行间通过JSON-RPC和HTTPS POST协议进行加密消息传输。本教程将带你从零开始掌握BankAPI接口的核心功能与实战应用,轻松实现金融级安全通信。 ## 一、BankAPI系统架构概览 BankAPI基于PostgreSQL数据库和Apache Web服务器构建,采用三层架构设计确保金融信息传输的安全性和可靠性。系统核心由
【Zephyr存储专题】18_从零教你开发MMC卡驱动(寄存器篇)
本文深入探讨eMMC/SDMMC控制器硬件结构及寄存器配置,为驱动开发提供技术参考。重点解析eMMC内部结构(Flash阵列、控制器、接口)和SDMMC关键寄存器(控制寄存器CR、命令寄存器CMDR等),详细说明各寄存器功能位域,包括时钟控制、DMA配置、命令传输等核心操作。文章还介绍了数据线配置和多线并行传输机制,为开发者实现卡驱动和文件系统适配提供实用指导。
如何快速配置Obsidian Local REST API:HTTPS与API Key安全终极指南
你是否希望在保持安全的前提下,为Obsidian笔记自动化提供强大的API接口?Obsidian Local REST API正是你需要的解决方案。这款插件通过安全的HTTPS连接和API Key认证,为你的脚本、浏览器扩展和AI代理提供了与Obsidian保险库的直接连接通道。本文将深入解析如何正确配置HTTPS证书和API Key保护机制,确保你的笔记数据在自动化流程中始终保持安全。 ##
uniapp - 热更新提示:WGT安装包中manifest.json文件不存在 | unexpected EOF!报错详细解决,完美搞定WGT安装包中WWW目录下manifest.json不存在问题
uniapp,安卓android,苹果ios,热更新,热更新code:-1202报错,,WGT热更新报错,uniapp热更新wgt出现报错manifest.json文件不存,uniapp安卓苹果软件热更新时出现错误unexpected EOF!如何解决,怎么解决热更新wgt报错,app新版本下载安装报错WGT安装包中manifest.json文件不存在,WGT安装包中WWW目录下manifest.json不存在,uniapp热更新报错安装失败[-1201]:WGT/WGTU文件格式错误,uniapp-wgt
【工具插件类教学】Unity翻书效果插件Book-Page Curl Pro教程
特征: • 从左到右和从右到左翻页 • 与画布缩放器 配合使用 • 可配置的自动翻转脚本 • 支持向页面 添加 UI 元素 • 支持透明页面 • 适用于“世界空间”画布
Lightbug HTTP实战教程:构建高并发JSON API服务
Lightbug HTTP是一款为Mojo语言打造的轻量级高性能HTTP框架,以其简洁设计和卓越性能成为构建高并发API服务的理想选择。本教程将带你从零开始搭建一个功能完善的JSON API服务,掌握Lightbug HTTP的核心优势与实战技巧。 ## 🚀 为什么选择Lightbug HTTP? Lightbug HTTP作为Mojo生态中的新兴框架,正处于快速发展阶段。从项目路线图可以清
深度学习工具包 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');```[](https://bitdeli.com/free "Bitdeli Badge")
K8s 核心组件——API Server
Kubernetes API Server(API Server)是 Kubernetes 的核心组件之一,负责暴露 Kubernetes API 给用户和客户端,接收和处理来自客户端的请求,并将其存储到 etcd 中。Kubernetes API Server 主要作用是提供 Kubernetes 各类资源对象(如 Pod、Deployment、Service等)的增、删、改、查及 Watch 等 HTTP REST 接口,是集群内各个功能模块直接数据交互和通信的中心枢纽,是整个系统的数据总线和数据中心。
蓝牙模块HM-10手册
蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。
Devexpress16.2.6破解工具
Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具
Kubernetes API Server详解
Kubernetes API Server 是 Kubernetes 控制平面的核心组件,负责处理所有 RESTful API 请求,管理集群状态,并作为集群内部和外部通信的网关。以下是其核心功能和架构的详细解析。
ssm框架搭建
这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载
5分钟上手API Sprout:轻量级OpenAPI 3 Mock Server安装与启动教程
API Sprout 是一款轻量级、速度极快的跨平台 OpenAPI 3 Mock Server,支持请求验证功能,能帮助开发者快速搭建模拟服务进行接口测试。本文将带你快速完成安装与启动,5分钟内即可体验高效的API模拟服务。 ## 三种快速安装方式 ### Docker 一键部署 🐳 Docker 是安装 API Sprout 最便捷的方式,无需复杂配置即可快速启动: ```bash
C++实现 Https Server 支持 restful json:安全高效的Web服务解决方案
C++实现 Https Server 支持 restful json:安全高效的Web服务解决方案 去发现同类优质开源项目:https://gitcode.com/ 在现代网络应用中,安全与高效的通讯协议至关重要。C++实现 Https Server 支持 restful json 项目的出现,为开发者提供了一种安全、灵活且实用的Web服务解决方案。下面我们将详细探讨这个项目的核心功能、技术背景、...
为什么JSON-Mask比JSONPath更适合API响应过滤?深度解析
在API开发中,数据过滤是提升性能和用户体验的关键环节。JSON-Mask作为一款轻量级的数据过滤工具,凭借其独特的设计理念和高效的处理方式,正在成为开发者的首选。本文将深入探讨JSON-Mask相比JSONPath的核心优势,帮助你理解为什么它更适合API响应过滤场景。 ## 什么是JSON-Mask? JSON-Mask是一个用于选择JS对象特定部分的微型语言和引擎,它能够隐藏或过滤掉不需
C++编程: 基于cpp-httplib和nlohmann/json实现简单的HTTP Server
本文基于 cpp-httplib 和 nlohmann/json 实现简单的 HTTPS Server 实例代码,这两个库均是head-only的。
RESTful API接口规范
RESTful规范 Restful API是目前比较成熟的一套互联网应用程序的API设计理念,Rest是一组架构约束条件和原则,如何Rest约束条件和原则的架构,我们就称为Restful架构,Restful架构具有结构清晰、符合标准、易于理解以及扩展方便等特点,受到越来越多网站的采用! Restful API接口规范包括以下部分: 一、协议 API与用户的通信协议,总是使用HTTPs协议。 二、域名 应该尽量将API部署在专用域名之下,如https://api.专属域名.com;如果确定
MicroWebSrv高级应用:如何集成JSON API与前端框架
MicroWebSrv 是一款专为 MicroPython 打造的微型 HTTP Web 服务器,支持 WebSockets、Python 模板渲染与路由处理器,常被用在 ESP32 和 Pycom 等嵌入式设备上。仅需 3 个文件,你就能在单片机里跑起一个完整的前后端应用——从 JSON API 接口到前端页面全部搞定。这篇文章将带你快速掌握 MicroWebSrv 集成 JSON API 与前
JSONPlaceholder vs Mock.js vs JSON Server:3种前端Mock方案深度对比
本文深度对比了三种主流前端Mock方案:JSONPlaceholder、Mock.js和JSON Server,从零配置、灵活性、数据可控性、部署复杂度四个维度进行全面评测。JSONPlaceholder适合快速原型设计,Mock.js提供高度灵活的数据模拟,而JSON Server则支持完整的REST API功能。文章还提供了性能测试和选型指南,帮助开发者根据项目需求选择最适合的Mock工具。
389



被折叠的 条评论
为什么被折叠?



