一文详解:电商商品选品与价格监控 API 接口实战指南

SpringBoot+Vue+MySQL 高校学科竞赛平台 完整可运行版(源码+文档) 本项目基于SpringBoot+Vue+MySQL构建高校学科竞赛管理平台,覆盖学生、教师、领队教师、管理员四大角色,实现竞赛发布、报名、刷题、评分、公示等全流程闭环管理。系统架构清晰,技术主流,配套完整源码、数据库脚本、万字论文、开题报告、答辩PPT及部署文档,支持一键运行,适用于毕业设计、课程设计及院系二次开发,真正实现“开箱即用”。 阅读详情

在电商运营中,选品和价格监控是核心竞争力的来源。手动翻页查价格、看库存不仅效率低,还容易错过爆款时机。本文将从架构设计、API 选型、核心代码实现到生产级部署,完整讲解如何通过 API 接口搭建一套自动化选品与价格监控系统。


一、系统架构设计

一套完整的选品价格监控系统通常分为五层:

层级职责关键技术
数据采集层对接各电商平台 API,定时抓取商品数据REST API、异步请求、签名认证
数据清洗层处理空值、格式转换、去重、异常值标记数据校验、正则匹配
时序存储层存储价格历史(时间戳 + 价格)MongoDB / InfluxDB / PostgreSQL
分析引擎层计算价格波动率、同比环比、识别异常统计分析、阈值判断
告警与可视化触发通知、展示趋势图、生成选品报表Webhook、ECharts、Excel 导出

二、API 接入方案选型

2.1 主流平台 API 对比

平台API 类型核心接口认证方式适用场景
京东官方 JOS / 第三方 Open Clawitem_get、item_searchAppKey + 签名 / API Key自营监控、选品库搭建
淘宝/天猫淘宝开放平台taobao.item.price.getAppKey + Token淘宝联盟选品
亚马逊Selling Partner API (SP-API)getPricing、getCatalogItemLWA + AWS 签名跨境竞品分析
拼多多官方 API / 第三方服务商品详情接口签名认证百亿补贴监控
苏宁易购开放平台item_searchMD5 签名全渠道比价

2.2 接入前准备

以京东为例,接入流程如下:

  1. 注册开发者账号:在开放平台申请 AppKey 和 AppSecret

  2. 申请 API 权限:按需申请最小权限(如仅申请"商品价格查询")

  3. 获取 Access Token:通过 OAuth 2.0 或长期 Refresh Token 获取调用凭证

  4. 配置白名单:设置服务器 IP 白名单,增强安全性


三、核心功能实现

3.1 商品数据采集模块

单商品详情获取(Python 示例)
import requests
import hashlib
import time

class JDPriceCollector:
    def __init__(self, app_key, app_secret):
        self.app_key = app_key
        self.app_secret = app_secret
        self.base_url = "https://api.jd.com/routerjson"
    
    def _generate_sign(self, params):
        """生成京东 API 签名"""
        # 1. 参数按 key 排序
        sorted_params = sorted(params.items())
        # 2. 拼接 key=value
        sign_str = ''.join([f"{k}{v}" for k, v in sorted_params])
        # 3. 首尾拼接 app_secret
        sign_str = f"{self.app_secret}{sign_str}{self.app_secret}"
        # 4. MD5 加密转大写
        return hashlib.md5(sign_str.encode()).hexdigest().upper()
    
    def get_item_price(self, sku_id):
        """获取单个 SKU 价格"""
        params = {
            "method": "jingdong.ware.price.get",
            "app_key": self.app_key,
            "timestamp": time.strftime("%Y-%m-%d %H:%M:%S"),
            "v": "2.0",
            "skuId": sku_id
        }
        params["sign"] = self._generate_sign(params)
        
        try:
            resp = requests.get(self.base_url, params=params, timeout=10)
            if resp.status_code == 200:
                return resp.json()
        except Exception as e:
            print(f"请求异常: {e}")
        return None

# 使用示例
collector = JDPriceCollector("your_app_key", "your_app_secret")
price_data = collector.get_item_price("100012345678")
关键词搜索选品(批量获取)

def keyword_search(keyword, page=1, page_size=20, api_key="your_key"):
    """按关键词搜索商品,筛选潜力爆款"""
    url = "https://api-gw.xxx.cn/jd/item_search"
    params = {
        "key": api_key,
        "q": keyword,
        "page": page,
        "page_size": page_size,
        "sort": "salesCount_desc"  # 按销量降序
    }
    
    resp = requests.get(url, params=params, timeout=10)
    if resp.status_code == 200:
        result = resp.json()
        items = result.get("items", [])
        
        # 选品过滤逻辑
        filtered = []
        for item in items:
            price = float(item.get("price", 0))
            sales = int(item.get("sales", 0))
            stock = item.get("stock_status")
            
            # 筛选规则:价格50-200元,销量>30,库存充足
            if 50 <= price <= 200 and sales > 30 and stock == "有货":
                filtered.append({
                    "title": item.get("title"),
                    "price": price,
                    "sales": sales,
                    "shop": item.get("shop_name"),
                    "url": item.get("item_url")
                })
        return filtered
    return []

3.2 价格监控与告警模块

多商品批量监控

import time
import pandas as pd
from datetime import datetime

class PriceMonitor:
    def __init__(self, collector, storage, alert_webhook=None):
        self.collector = collector
        self.storage = storage
        self.alert_webhook = alert_webhook
        self.monitor_list = []  # 监控商品列表
    
    def add_monitor(self, sku_id, target_price, platform="jd"):
        """添加监控商品"""
        self.monitor_list.append({
            "sku_id": sku_id,
            "target_price": target_price,
            "platform": platform
        })
    
    def check_price(self, item):
        """检查单商品价格"""
        sku_id = item["sku_id"]
        target = item["target_price"]
        
        # 获取实时价格
        data = self.collector.get_item_price(sku_id)
        if not data:
            return None
        
        current_price = float(data.get("price", 9999))
        title = data.get("title", "未知商品")
        
        # 存储历史价格
        record = {
            "platform": item["platform"],
            "sku_id": sku_id,
            "title": title,
            "price": current_price,
            "crawl_time": time.time(),
            "crawl_datetime": datetime.now()
        }
        self.storage.save_price(record)
        
        # 价格告警逻辑
        if current_price <= target:
            self._send_alert(title, current_price, target)
            return {"alert": True, "price": current_price, "target": target}
        
        return {"alert": False, "price": current_price}
    
    def _send_alert(self, title, current, target):
        """发送告警通知(支持钉钉/企业微信/邮件)"""
        msg = f"🚨 价格达标提醒\n商品:{title}\n当前价:¥{current}\n目标价:¥{target}"
        if self.alert_webhook:
            requests.post(self.alert_webhook, json={"text": msg})
        print(msg)
    
    def start_monitoring(self, interval=600):
        """启动定时监控循环"""
        print(f"启动监控,共 {len(self.monitor_list)} 个商品,间隔 {interval//60} 分钟")
        while True:
            for item in self.monitor_list:
                self.check_price(item)
                time.sleep(2)  # 避免请求过快
            time.sleep(interval)

3.3 数据存储设计

价格数据是典型的时序数据,推荐使用 MongoDB 或 InfluxDB:

from pymongo import MongoClient

class PriceStorage:
    def __init__(self, db_name="price_monitor"):
        self.client = MongoClient("mongodb://localhost:27017/")
        self.db = self.client[db_name]
        self.collection = self.db["price_history"]
        
        # 创建复合索引加速查询
        self.collection.create_index([
            ("platform", 1), 
            ("sku_id", 1), 
            ("crawl_time", -1)
        ])
    
    def save_price(self, price_data):
        """存储单条价格记录"""
        self.collection.insert_one(price_data)
    
    def get_price_history(self, platform, sku_id, days=7):
        """获取最近 N 天价格历史"""
        start_time = time.time() - days * 24 * 3600
        return list(self.collection.find({
            "platform": platform,
            "sku_id": sku_id,
            "crawl_time": {"$gte": start_time}
        }).sort("crawl_time", 1))

四、智能选品策略引擎

4.1 多维度筛选模型

基于采集的数据,可构建自动化选品评分体系:

def product_scoring(item):
    """商品综合评分算法"""
    score = 0
    
    # 价格维度(50-200元为最佳转化区间)
    price = float(item.get("price", 0))
    if 50 <= price <= 200:
        score += 30
    elif 200 < price <= 500:
        score += 20
    
    # 销量维度(日销>30为活跃款)
    sales = int(item.get("sales", 0))
    if sales > 1000:
        score += 25
    elif sales > 100:
        score += 20
    elif sales > 30:
        score += 15
    
    # 评价维度
    rating = float(item.get("rating", 0))
    if rating >= 4.8:
        score += 20
    elif rating >= 4.5:
        score += 15
    
    # 库存维度
    stock = int(item.get("stock", 0))
    if stock > 500:
        score += 15
    elif stock > 100:
        score += 10
    
    # 店铺维度(自营加分)
    if item.get("is_self") == 1:
        score += 10
    
    return score

# 批量选品示例
def batch_select_products(keyword, top_n=20):
    items = keyword_search(keyword)
    scored = [(item, product_scoring(item)) for item in items]
    scored.sort(key=lambda x: x[1], reverse=True)
    return scored[:top_n]

4.2 竞品对标分析

通过自动关联同款商品,实现跨平台比价:

def cross_platform_compare(sku_mapping):
    """跨平台价格对比"""
    results = []
    for product in sku_mapping:
        prices = {}
        for platform, sku in product["skus"].items():
            data = get_price(platform, sku)
            prices[platform] = {
                "price": data["price"],
                "stock": data["stock"],
                "promotion": data.get("coupons", [])
            }
        
        # 计算价差
        min_price = min(p["price"] for p in prices.values())
        max_price = max(p["price"] for p in prices.values())
        
        results.append({
            "name": product["name"],
            "prices": prices,
            "spread": max_price - min_price,
            "spread_rate": (max_price - min_price) / min_price * 100
        })
    return results

五、生产级部署与优化

5.1 频率控制与限流处理

各平台 API 均有调用限制,需实现动态等待机制:

平台默认限流应对策略
京东视权限等级分散采集时间,错开 1-2 分钟
亚马逊 SP-API每小时 4000 次本地 Redis 缓存,重复 ASIN ≥24 小时查询
淘宝10 次/分钟(基础版)令牌桶算法平滑请求

from ratelimit import limits, sleep_and_retry

@sleep_and_retry
@limits(calls=10, period=60)  # 每分钟最多10次
def api_call_with_rate_limit(url, params):
    return requests.get(url, params=params)

5.2 高可用架构设计

# 代理 IP 池(应对封禁)
PROXY_POOL = [
    "http://user:pass@1.1.1.1:8080",
    "http://user:pass@2.2.2.2:8081"
]

def get_with_proxy(url, params, max_retry=3):
    for i in range(max_retry):
        proxy = {"http": random.choice(PROXY_POOL)}
        try:
            resp = requests.get(url, params=params, proxies=proxy, timeout=10)
            if resp.status_code == 200:
                return resp.json()
        except Exception as e:
            print(f"第{i+1}次请求失败: {e}")
            time.sleep(2 ** i)  # 指数退避
    return None

5.3 告警风暴防护

避免同一商品频繁触发告警:

class AlertManager:
    def __init__(self, cooldown=3600):
        self.cooldown = cooldown  # 冷静期1小时
        self.last_alert = {}      # 记录上次告警时间
    
    def should_alert(self, sku_id):
        now = time.time()
        if sku_id in self.last_alert:
            if now - self.last_alert[sku_id] < self.cooldown:
                return False
        self.last_alert[sku_id] = now
        return True

六、实战避坑指南

问题场景解决方案
签名错误日志记录完整参数拼接过程,用官方工具验证本地签名
数据缺失/重复添加重试机制(最多3次),存储前按 SKU+时间戳去重
价格异常(如0元)数据清洗时标记异常值,设置合理价格区间过滤
IP 被封启用住宅代理池,配合请求头随机化、随机延迟 2-5 秒
页面改版导致解析失败优先使用官方 API 而非网页爬虫,API 返回结构化 JSON 不受页面改版影响

七、总结与扩展方向

通过 API 接口实现电商选品与价格监控,核心价值在于:

  • 实时性:分钟级更新,捕捉转瞬即逝的价格波动

  • 可扩展性:支持多平台、多商品,随业务需求灵活扩展

  • 决策支撑:基于数据而非经验制定定价策略,提升竞争力

后续可重点优化方向:

  1. 竞品自动发现:通过商品标题分词 + 图像识别,自动匹配同款竞品

  2. 价格预测:基于 LSTM 时序模型预测未来价格走势,辅助决策

  3. 动态定价联动:监控到竞品降价后,自动调整自身促销策略

  4. 可视化看板:用 Flask + ECharts 构建实时价格趋势大屏

HSPICE用户必看:用Sigrity Broadband SPICE解决复杂封装建模的3个技巧 本文为HSPICE用户分享了三个使用Sigrity Broadband SPICE解决复杂封装建模难题的实战技巧。通过将宽频带S参数高效转换为时域SPICE模型,能显著提升仿真速度、保障收敛性,并精准分析谐振、返回路径不连续及超多端口PDN等关键问题,助力实现高效稳定的系统级信号与电源完整性分析。 阅读详情

相关推荐

Python实战:用Realsense D435和睿尔曼机械臂完成手眼标定的5个关键步骤

本文详细介绍了使用Python、Realsense D435深度相机与睿尔曼机械臂进行手眼标定的完整实战流程。文章将过程拆解为环境搭建、数据采集、核心计算、结果验证和精度优化五个关键步骤,重点剖析了数据采集的黄金法则、常见错误排查以及如何将标定结果集成到视觉抓取程序中,旨在帮助开发者实现毫米级精度的视觉引导机器人系统。

weixin_29103191的博客 321

AI通缩陷阱:效率提升为何利润反被卷没?

在人工智能技术快速普及的今天,企业普遍关注如何通过AI实现降本增效。然而,当生产效率因大模型、AI Agent等工具显著提升时,市场供给随之激增,同质化服务价格不断下探,导致利润空间被压缩,形成所谓的“AI通缩陷阱”。这一现象并非简单的价格战,而是技术普及导致原有价值体系重构。从工程角度看,token成本仅占AI项目总成本的一小部分,人工复审、数据治理、模型迭代等隐性开销往往决定实际毛利。要跳出陷阱,团队需从单纯追求效率提升转向构建数据飞轮、深耕垂直场景,并通过模型抽象层控制供应链风险。本文将从经济学原理与

weixin_33937778的博客 427

支付宝周期扣款实战:从签约到主动扣款的完整Java代码与避坑指南

本文详细介绍了支付宝周期扣款功能的完整Java实现流程,从协议签约到主动扣款的各个环节,包括业务模型设计、签约接口实现、异步通知处理、主动扣款技术等关键步骤。针对开发中常见的陷阱和问题,提供了实用的避坑指南和代码示例,帮助开发者高效实现连续支付功能,提升用户留存率。

weixin_27199085的博客 374

拍立淘图片搜索商品列表接口

"拍立淘"是淘宝的拍照购功能——拍一张商品图,淘宝自动识别并返回一批相似商品。拍立淘接口把这个能力 API 化:你传入一张商品图片,接口自动完成商品识别、特征匹配、相似度排序,最终返回一份商品列表——包含商品标题、价格、销量、店铺信息、主图、商品链接等结构化字段。输入一张图,输出一份商品数据表。

Ob_API20230201的博客 196

如何做好软件需求分析?

软件需求分析也称为系统需求分析或需求分析工程等,是开发人员经过深入细致的调研和分析,准确理解用户和项目的功能、性能、可靠性等具体要求,将用户非形式的需求表述转化为完整的需求定义,从而确定系统必须做什么的过程。软件开发一般包括:可行性分析、需求分析、软件设计、软件开发、软件测试、软件实施、软件服务等步骤,需求分时软件开发的第一步骤。用户需求分析是指在系统设计之前和设计、开发过程中对用户需求所作的调查与分析,是系统设计、系统完善和系统维护的依据。

qq_41854911的博客 1416

攻克反光难题!YOLOv9工业缺陷检测实战:高反光件、微小划痕精准识别(附抗反光代码+产线数据)

文章摘要:本文针对不锈钢、铝合金等高反光工业件的缺陷检测难题,提出了一套“硬件抗反光+YOLOv9小目标增强”的解决方案。通过分析反光干扰(镜面/漫反射)和微小划痕(0.1mm级)两大核心问题,详细介绍了500万像素工业相机+偏振光源的硬件配置方案,以及基于偏振图像融合和超分辨率放大的预处理方法。最终实现误检率1.2%、微小划痕检出率99.3%的工业级检测效果,并提供了可落地的代码实现和车间实测数据。(148字)

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 1042

商品详情接口里 props 和 SKU 到底有什么区别?一文讲透(附避坑指南)

props 和 SKU 的区别,本质上就是**“商品是什么"和"商品怎么卖”**的区别。对接电商数据接口时,把这两个字段的角色分清,能避开绝大多数价格、库存和展示层面的 Bug。如果你在做电商数据采集、选品系统或代购(反向海淘)独立站,需要稳定、结构化的商品详情数据接口(含完整的 props 和 SKU 字段),欢迎交流——我们提供覆盖主流电商平台的标准化数据 API,字段结构统一,对接成本低。

Ob_API20230201的博客 327

【camera-radar】基于ROS的多传感器融合感知系统实现(雷达+相机)(2)

实现功能:代码下载地址:下载地址 1)基于深度学习的目标检测;2)基于雷达的距离估计和预测;3)多传感器感知结果融合模块。 相机感知模块解析 4. Run nodes: python3 fusion_node/main.py python3 gps_node/main.py python3 radar_node/main.py python3 2d_detection_node/main.py #(additional instructions in 2d_detection_node/README.m

踟蹰横渡口,彳亍上滩舟。 9951

一文搞清1688跨境“寻源通”,跨境代采业务!

该人士举例,外国企业批发中国产品,可以自己派人来中国,但此举效率低下,面临语言、文化等各类问题,容易踩坑,企业不如找一个熟悉中国供应链、熟悉产品、在行业耕耘多年的人,即“代采”。因此,上述人士认为,1688能给代采提供价值,省去麻烦,满足那些要求不那么严格的需求,但对于更专业的企业客户而言,价值有限。1688跨境“寻源通”提供跨境版API接口,可将1688的货盘导入各类有流量的平台,比如各国代采网站、服务商SaaS(软件服务)系统、跨境平台等,买家可直接在上述平台看到1688的货盘、订单、物流等信息。

Ob_API20230201的博客 1030

996引擎 - 读写变量性能测试

单轮100万次读写,取3轮平均耗时(毫秒),有效读取率均为100%,数值越小性能越优。

灵台方寸山斜月三星洞 244

选课系统进不去?我用 Python 做了个“捡漏挂机”脚本,全自动监控空余名额

频率控制:脚本请求频率不要太高(建议间隔 3-5 秒以上),否则可能被教务系统封 IP,甚至会被教务处请喝茶。仅供学习:本文旨在通过选课场景教学requests和网络抓包原理,请勿用于非法用途或破坏公平性。刷新页面 -> 等待加载 -> 用眼睛看人数 -> 没满?-> 点击选课 -> 确认这个流程最大的瓶颈在于**“等待加载”和“人的反应时间”**。网页加载需要渲染 HTML、CSS、图片,而 Python 脚本只需要请求一个微小的 JSON 数据接口,速度是浏览器的10 倍以上。fill:#333;

BUG猿的博客 292

InnoDB 内存结构总览:Change Buffer、AHI 与 Log Buffer

本文系统梳理InnoDB内存结构中的ChangeBuffer、Adaptive Hash Index(AHI)与LogBuffer。ChangeBuffer缓存二级索引页不在内存时的变更,减少随机IO,仅在页加载时合并;聚簇索引修改立即执行,因数据本身不可延后。AHI基于高频等值查询自动构建哈希索引,加速定位,仅支持等值操作。LogBuffer为redo log内存缓冲,配合磁盘日志实现崩溃恢复。三者均服务于性能优化,其中ChangeBuffer与AHI共享BufferPool空间,而LogBuffer独立

bksczm的博客 292

【案例讲解】LVGL关于旋转的配置

在实现项目中,因为横竖屏的关系,需要对其做90度的旋转。配置旋转时发现一些局部刷新控件,旋转后效果不对。异常图标正常图标。

Bigan(安)的博客 4284

V8 机制、手写核心函数与 TypeScript 类型体操

或固定初始化(如数组先定长、对象先给全字段)保持类型与形状稳定;这些都比"换框架"更基础。只能处理纯数据(丢函数、Date、RegExp、循环引用报错)。生产级深拷贝要处理:原始值短路、循环引用、V8(Chrome / Node 的 JS 引擎)不是"解释一行跑一行"那么简单,它用。图:V8 执行流程——解释执行 + 热点优化,优化失败会 Deopt 回退。JS 内存自动管理,但"自动"不等于"不会漏"。是"固定间隔最多执行一次"。手写 Promise 是"懂异步"的试金石。是"停下后才执行最后一次",

qq_38468358的博客 349

深度学习工具包 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")

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

Spring Boot 数据源与 MyBatis(-Plus) 自定义配置详解

本文详解 Spring Boot 中单数据源环境下 HikariCP 与 MyBatis-Plus 的自定义配置。通过手动声明 SqlSessionFactory,实现下划线转驼峰、日志输出、一级缓存策略等精细化控制。结合 HikariCP 核心参数调优(如最大连接数、连接生命周期),确保高性能与稳定性。适用于仅需访问单一数据库的场景,避免多数据源复杂性,兼顾性能与可维护性。

BADAO_LIUMANG_QIZHI的博客 206

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

Java EE 进阶:8.MyBatis 操作数据库(入门)(第一弹)

Java EE 进阶:8.MyBatis 操作数据库(入门)(第一弹)

要努力去发光,而不是被照亮~ 145

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

LeetCode Hot 100 二叉树专题(二)3 题(Java)

本篇文章共 3 题:543. 二叉树的直径、102. 二叉树的层序遍历、108. 将有序数组转换为二叉搜索树。 每道题都统一按「① 题目分析 & 解题思路 → ② 常见解法(附代码)及讲解 → ③ 知识点总结」的顺序组织;代码使用 Java 编写,节点定义沿用 LeetCode 默认的 TreeNode。

2401_88612756的博客 368

【从零理解 Spring AI · 12】MCP 的两种角色:做客户端还是做服务端

上一篇讲了 MCP 的概念:标准协议、三大角色、M+N 替代 M×N。

nice_lcj520的博客 512

JDK 下载安装:装完 Java 提示「不是内部或外部命令」?环境变量没配

JDK 是写 Java 程序必须装的东西。它包含运行 Java 的虚拟机(JRE)和编译 Java 的编译器(javac)——装了它,能跑、.java文件能编译成可执行程序。免费,学习和小规模生产都不花钱。

科小怪的博客 638

Java 集合容器高频面试题全解:HashMap 树化阈值、1.7 死循环与 ConcurrentHashMap 演进(2026 招聘 JD 真题复盘)

HashMap 树化阈值 8 的泊松分布依据、退化阈值 6 的防抖设计、JDK 1.7 头插成环死循环的排查与修复、1.8 尾插后为何仍线程不安全、ConcurrentHashMap 放弃分段锁的原因与 ForwardingNode 协作扩容、computeIfAbsent 死锁陷阱、大集合找重复的场景题选型,附三层追问链自测。题目来源为 38 期公开招聘 JD 样本与字节、拼多多、建行、美团、快手公开面经。

蒙眼过河 349

java框架大全

java框架大全

qq_39326137的博客 184

Java 多态 学习笔记

多态是面向对象编程的重要特性,指同一操作作用于不同对象时产生不同行为。其核心在于“父类引用指向子类对象”,结合方法重写实现运行时动态绑定。多态使代码更灵活、可扩展,如用Person p = new Student();统一处理各类人员注册,无需修改调用逻辑。但多态无法直接调用子类特有方法,需通过instanceof判断并强制转换。编译时看左边(类型),运行时看右边(实际对象),实现解耦与维护便利。

AA_AA114514的博客 365

SecureRandom做随机源,这个Java随机字符串工具类有3个方法

本文分享一款JDK17环境下的Java随机字符串工具类,内置3个开箱即用的方法,全部采用SecureRandom加密安全随机源,不存在弱随机、可预测、取模偏差等问题。工具类支持默认62字符集随机串、纯数字随机串、自定义字符集随机串三种生成模式,支持Unicode码点级别的字符集处理,兼容Emoji等增补字符,边界处理严格,异常信息明确,适合验证码、邀请码、盐值、随机口令、短链码等场景,源码可直接复制使用。

Java后端 | AI智能体应用实战派 | 电脑技能行家 300

IDEA 简介:从零认识 IntelliJ IDEA

IDEA 全称,是由 JetBrains 公司开发的一款主流 Java 集成开发环境(IDE)。它集代码编辑、编译、调试、测试、版本控制、构建管理等功能于一体,被大量 Java 开发者视为日常开发的首选工具。所谓 IDE(Integrated Development Environment,集成开发环境),就是把写代码所需的各类工具整合到同一个界面中。相比只用文本编辑器加命令行编译,IDE 能显著减少重复操作,让开发者把精力集中在业务逻辑上。

ztI10的博客 162

Java实现批量线段相交检测(跨积判定+扫描线优化与踩坑复盘)

【代码】Java实现批量线段相交检测(跨积判定+扫描线优化与踩坑复盘)

m0_64476639的博客 332

TRingBuffer两端都能增删(快递站版)

TRingBuffer 是一个支持两端增删、下标访问且容量动态增长的环形双端队列。它通过无符号索引的永不归零设计,利用减法自动模运算实现空满判断与元素计数,避免了传统环形缓冲浪费格子的问题。内部以票号(索引)标记首尾,扩容时重排元素为连续存储,保证 O(1) 操作与高缓存效率。虽不线程安全,但其高效性使其成为游戏开发中事件队列、命令缓冲等场景的理想选择。

u013768914的博客 301
上一篇: (某音)商品详情接口douyin. item_get_app Java 开发实战指南
下一篇: 一文带你了解API 接口测试 | API 接口测试文档
APIshop
博客等级 码龄1年 109粉丝 175原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值