tf.nn.sparse_softmax_cross_entropy_with_logits

简介:
相当于合并了softmax和cross_entropy两步
sparse_softmax_cross_entropy_with_logits(_sentinel=None, labels=None, logits=None, name=None)
    Computes sparse softmax cross entropy between `logits` and `labels`.
    
    Measures the probability error in discrete classification tasks in which the
    classes are mutually exclusive (each entry is in exactly one class).  For
    example, each CIFAR-10 image is labeled with one and only one label: an image
    can be a dog or a truck, but not both.
    
    **NOTE:**  For this operation, the probability of a given label is considered
    exclusive.  That is, soft classes are not allowed, and the `labels` vector
    must provide a single specific index for the true class for each row of
    `logits` (each minibatch entry).  For soft softmax classification with
    a probability distribution for each entry, see
    `softmax_cross_entropy_with_logits`.
    
    **WARNING:** This op expects unscaled logits, since it performs a `softmax`
    on `logits` internally for efficiency.  Do not call this op with the
    output of `softmax`, as it will produce incorrect results.
    
    A common use case is to have logits of shape `[batch_size, num_classes]` and
    labels of shape `[batch_size]`. But higher dimensions are supported.
    
    **Note that to avoid confusion, it is required to pass only named arguments to
    this function.**
    
    Args:
      _sentinel: Used to prevent positional parameters. Internal, do not use.
      labels: `Tensor` of shape `[d_0, d_1, ..., d_{r-1}]` (where `r` is rank of
        `labels` and result) and dtype `int32` or `int64`. Each entry in `labels`
        must be an index in `[0, num_classes)`. Other values will raise an
        exception when this op is run on CPU, and return `NaN` for corresponding
        loss and gradient rows on GPU.
      logits: Unscaled log probabilities of shape
        `[d_0, d_1, ..., d_{r-1}, num_classes]` and dtype `float32` or `float64`.
      name: A name for the operation (optional).
    
    Returns:
      A `Tensor` of the same shape as `labels` and of the same type as `logits`
      with the softmax cross entropy loss.
    
    Raises:
      ValueError: If logits are scalars (need to have rank >= 1) or if the rank
        of the labels is not equal to the rank of the logits minus one.
目录
相关文章
|
存储 人工智能 机器人
使用CLIP和LLM构建多模态RAG系统
在本文中我们将探讨使用开源大型语言多模态模型(Large Language Multi-Modal)构建检索增强生成(RAG)系统。本文的重点是在不依赖LangChain或LLlama index的情况下实现这一目标,这样可以避免更多的框架依赖。
795 0
|
数据采集 并行计算 PyTorch
modelscope问题之训练报错如何解决
ModelScope训练是指在ModelScope平台上对机器学习模型进行训练的活动;本合集将介绍ModelScope训练流程、模型优化技巧和训练过程中的常见问题解决方法。
1204 0
|
监控 PyTorch 算法框架/工具
Qwen-VL怎么用自己的数据集微调
Qwen-VL怎么用自己的数据集微调
1599 0
|
9月前
|
JSON 人工智能 自然语言处理
小模型也能有类o1的慢思考能力?使用CAMEL生成CoT数据、Unsloth微调Qwen2.5-1.5B模型并上传至Hugging Face
本项目利用CAMEL生成高质量的CoT数据,结合Unsloth对Qwen2.5-1.5B模型进行微调,并将结果上传至Hugging Face。通过详细步骤介绍从数据生成到模型微调的完整流程,涵盖环境配置、API密钥设置、ChatAgent配置、问答数据生成与验证、数据转换保存、模型微调及推理保存等内容。最终展示了如何优化问答系统并分享实用技巧。 [CAMEL-AI](https://github.com/camel-ai/camel) 是一个开源社区,致力于智能体扩展研究。欢迎在GitHub上关注并加入我们!
1016 15
tf.keras.layers.Dense
【8月更文挑战第20天】tf.keras.layers.Dense。
307 2
|
9月前
|
数据采集 人工智能 自然语言处理
Qwen模型角色扮演最佳实践
角色扮演大模型通过模拟特定角色的行为、语言风格和情感表达,实现高度拟人化和定制化的互动体验。与传统通用模型相比,角色扮演模型在语言风格、性格特征和情绪反应上更加细腻,提供更真实的交互体验。本文介绍了如何通过system prompt、few-shot学习和微调等技术实现大模型的拟人化,包括使用阿里云百炼平台进行角色扮演测试,以及如何通过合成数据和Lora微调提高模型的表演效果。最终,展示了如何通过优化数据质量和训练策略,显著提升角色扮演模型的表现。
|
9月前
|
数据采集 前端开发 物联网
【项目实战】通过LLaMaFactory+Qwen2-VL-2B微调一个多模态医疗大模型
本文介绍了一个基于多模态大模型的医疗图像诊断项目。项目旨在通过训练一个医疗领域的多模态大模型,提高医生处理医学图像的效率,辅助诊断和治疗。作者以家中老人的脑部CT为例,展示了如何利用MedTrinity-25M数据集训练模型,经过数据准备、环境搭建、模型训练及微调、最终验证等步骤,成功使模型能够识别CT图像并给出具体的诊断意见,与专业医生的诊断结果高度吻合。
【项目实战】通过LLaMaFactory+Qwen2-VL-2B微调一个多模态医疗大模型
|
人工智能 物联网 异构计算
AI智能体研发之路-模型篇(一):大模型训练框架LLaMA-Factory在国内网络环境下的安装、部署及使用
AI智能体研发之路-模型篇(一):大模型训练框架LLaMA-Factory在国内网络环境下的安装、部署及使用
1561 1
|
人工智能 JavaScript IDE
使用Coze工作流(二)
使用Coze工作流(二)
1875 0
|
数据采集 机器学习/深度学习 自然语言处理
ModelScope模型库体验之中文StructBERT系列预训练语言模型
StructBERT在BERT的基础上提出改进优化,通过在句子级别和词级别引入两个新的目标函数,打乱句子/词的顺序并使模型对其进行还原的方式,能让机器更好地掌握人类语法,加深对自然语言的理解,使得模型学习到更强的语言结构信息。
47566 0
ModelScope模型库体验之中文StructBERT系列预训练语言模型