What does shot mean?

本文深入探讨了Shot在人工智能领域的应用,特别是在少样本学习、零样本学习及迁移学习中的含义。解析了C-way K-shot的概念,以及在不同场景下Shot所代表的数据量描述单位,帮助读者理解其在实验设置中的作用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

前言

最近看了一些论文,反复提到一个词:shot。那么shot究竟指的是什么?通过查阅资料和思考后,进行一下总结。

Shot都在哪里出现?

首先,根据牛津词典,shot的一种解释是the act of firing a gun,或者 an attempt to score a goal or point in a game。shot在目前火热的各个领域都有出现:

  • 少样本学习(few-shot learning)和零样本学习(zero-shot learning)
  • 迁移学习(transfer learning)存在few-shot和zero-shot的问题
  • 一些论文的实验中在数据量上出现shot

这么多shot,究竟是代表一样的含义,还是有区别,再或者是既有区别又有联系?我们该怎么理解呢?

少样本学习

在少样本学习中,我们经常可以看到C-way K-shot。要解释这个词,要先从meta-learning说起。
在这里插入图片描述

meta-learning的目标是在一系列学习任务中训练一个模型,这个模型能仅用少量几个样本就能学会解决新任务。

  • C-way K-shot:在meta-learning的实验设置上,我们严格地称之为C-way
    K-shot方式。C代表meta-learning task的类别,K代表每个类别的样本数。如上图,是一个5-way
    5-shot的实验设置,在meta-learning
    training和testing都各有有5个类别的图片,每一类图片都有5张。当然我们也看到meta-training
    tasks也有测试集。一般来说,在实验采样的过程中,其实会给每类图片采样6个样本(K+1),前5个样本是作为meta-training
    tasks 的train,最后一个样本作为当前类的test。

我们并没有介绍一个meta-learning的经典框架:MAML。Model-Agnostic Meta-Learning for Fast Adaptation of Deep Networks,ICML 2017。
结合上面的描述更好理解。强烈推荐大家看一看。

零样本学习

这方面我没有调研,只是学习一些概念,主要是想要和上面的少样本学习区分开。举个例子,爸爸在家给小明看了三种动物照片,包括马,豹子,熊猫,小明学会了。随后,爸爸并告诉小明,有四条腿,有花纹,黑白相间的动物是斑马。那么小明可以从很多动物中,认出哪一个是斑马。这就是零样本学习。zero-shot就指的是,从来没有人给小明看过斑马的照片,但是小明从已有的知识中,学习过四条腿是什么样子,有花纹是什么样子,黑白相间又是什么。

迁移学习

由于笔者的研究方向是任务型的多轮对话,因此这里拿它举例。对该领域不了解的同学也不必担心。任务型对话与闲聊最大的区别在于,是任务驱动的,这在生活中很常见,比如订餐,定电影票,导航,天气查询等地。那么,在任务型对话中,迁移学习中zero-shot和few-shot是一个什么问题呢?

  • zero-shot:我们已经有大量的训练数据(源域),这些数据涉及多个领域,比如定餐,打出租车,我们的测试数据(目标域)却是定火车票。也就是说,目标域与源域完全不一样。
  • few-shot:跟上面一样,我们已经有大量的训练数据(源域),这些数据涉及多个领域,比如定餐,打出租车,我们的测试数据(目标域)是定火车票。但是不同的地方是,现在我们的测试数据有一些样本可用,换句话说,我们告诉机器人大量数据,这样是定餐,那样是打出租车,得到一个较好的模型。现在我们继续给机器人少量的定火车票数据,让模型得以微调,在测试的时候,希望它能在订火车票任务上表现较好。

总结

  • shot粗略地理解为一种描述数据量的单位(类似于长度单位是米),在不同的应用场景下,few shot / zero shot 的具体指代(解释)会有稍微的差异。
  • 迁移学习中的shot用于强调目标域与源域在数据分布上不完全一致。zero-shot 指代某些词或用户行为在训练数据中从未出现,但在测试集中存在。few-shot 指代某些词或用户行为在训练数据中很少量出现,但在测试集中出现。
  • 少样本学习/ 零样本学习中的shot强调可用于训练的数据量很少。这里说明一下,少样本学习是meta-learning 的一个监督学习的应用,但不限于meta-learning去解决。少样本学习还有其他方式解决方式,比如数据增强和正则化等。
  • 实验中的shot指某类数据出现的频率/次数,比如few shot(少量出现) many shot (大量出现)等。比如测试数据中有些词没有在训练集出现,就可以称之为zero shot。有点像OOV,但是OOV只是shot的一种情况。
### MobileNet SSD Implementation in Keras Tutorial and Usage #### Overview of MobileNet SSD with Keras MobileNet SSD (Single Shot MultiBox Detector) is a highly efficient object detection model that combines the lightweight architecture of MobileNets with the fast single-shot detection framework. This combination allows for real-time object detection on mobile devices while maintaining reasonable accuracy levels[^1]. #### Key Components of MobileNet SSD Model The core components include: - **Base Network**: Utilizes MobileNet as the backbone feature extractor. - **Detection Layers**: Adds several convolutional layers on top of MobileNet to predict bounding boxes and class scores. #### Installation Requirements To implement MobileNet SSD using Keras, ensure these dependencies are installed: ```bash pip install tensorflow keras opencv-python h5py numpy matplotlib ``` #### Loading Pre-trained Weights For convenience, pre-trained weights can be loaded directly from public repositories or trained models available online. Here’s how one might load such a model: ```python from keras.models import load_model model_path = 'path_to_mobilenet_ssd_weights.hdf5' ssd_model = load_model(model_path) ``` #### Data Preparation Data preparation involves converting images into tensors suitable for feeding into the network. For instance: ```python import cv2 import numpy as np def preprocess_image(image_path): img = cv2.imread(image_path) resized_img = cv2.resize(img, (300, 300)) input_data = np.array(resized_img).astype('float32') input_data -= [123, 117, 104] # Mean subtraction based on ImageNet statistics input_data = np.expand_dims(input_data, axis=0) return input_data ``` #### Performing Inference Once everything is set up, performing inference becomes straightforward: ```python input_tensor = preprocess_image('example.jpg') predictions = ssd_model.predict(input_tensor) for pred in predictions[0]: confidence = pred[-1] if confidence >= 0.5: # Confidence threshold label_id = int(pred[-2]) box_coords = pred[:4] * [width, height, width, height] print(f'Detected {label_id} at coordinates {box_coords}') ``` --related questions-- 1. How does MobileNet differ from other CNN architectures used in object detection? 2. What optimizations techniques exist specifically for deploying MobileNet SSD on edge devices? 3. Can you provide an example of fine-tuning a pre-trained MobileNet SSD model on custom datasets within Keras? 4. Are there any specific considerations when choosing between TensorFlow and PyTorch implementations of MobileNet SSD?
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值