Elasticsearch:探索 CLIP 替代方案

news2025/4/8 19:11:34

作者:来自 Elastic Jeffrey Rengifo 及 Tomás Murúa

分析图像到图像和文本到图像搜索的 CLIP 模型的替代方案。

在本文中,我们将通过一个模拟房地产网站的实际示例介绍 CLIP 多模态模型,探索替代方案,并分析它们的优缺点,该网站允许用户使用图片作为参考来搜索房产。

什么是 CLIP?

CLIP(Contrastive Language–Image Pre-training - 对比语言 - 图像预训练)是由 OpenAI 创建的神经网络,使用图像和文本对进行训练,以解决在文本和图像之间寻找相似性的任务,并对 “零样本” 图像进行分类,因此模型不是使用固定标签进行训练的,而是我们为模型提供未知类别,以便它可以对我们提供的图像进行分类。

CLIP 一直是最先进的模型,你可以在此处阅读有关它的更多文章:

  • 实现图像搜索
  • 如何实现图像相似性搜索

然而,随着时间的推移,出现了更多的替代方案。

在本文中,我们将使用房地产示例介绍 CLIP 的两种替代方案的优缺点。以下是我们在本文中将遵循的步骤的摘要:

基本配置:CLIP 和 Elasticsearch

在我们的示例中,我们将使用 Python 创建一个带有交互式 UI 的小项目。我们将安装一些依赖项,例如 Python 转换器,这将授予我们访问我们将使用的某些模型的权限。

创建一个文件夹 /clip_comparison 并按照此处的安装说明进行操作。完成后,安装 Elasticsearch 的 Python 客户端、Cohere SDK 和 Streamlit:

注意:作为一种选择,我建议使用 Python 虚拟环境 (venv)。如果你不想在计算机上安装所有依赖项,这将非常有用。

pip install elasticsearch==8.15.0 cohere streamlit

Streamlit 是一个开源 Python 框架,可让你使用少量代码轻松获得 UI。

我们还将创建一些文件来保存稍后将使用的指令:

  • app.py:UI 逻辑。
  • /services/elasticsearch.py​​:Elasticsearch 客户端初始化、查询和批量 API 调用以索引文档。
  • /services/models.py:用于生成嵌入的模型实例和方法。
  • index_data.py:用于从本地源索引图像的脚本。
  • /data:我们的数据集目录。

我们的应用程序结构应如下所示:

/clip_comparison
  |--app.py
  |--index_data.py
  |--/data
  |--/venv # If you decide to use venv
  |--/services
        |-- __init__.py
        |-- models.py
        |-- elasticsearch.py

配置 Elasticsearch

按照以下步骤存储示例图像。然后我们将使用 knn 向量查询搜索它们。

注意:我们也可以存储文本文档,但对于此示例,我们将仅在图像中搜索。

索引映射

访问 Kibana 开发工具(从 Kibana:Management > Dev Tools)以使用这些映射构建数据结构:

[ ]
PUT clip-images
{
  "mappings": {
    "properties": {
      "image_name": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword"
          }
        }
      },
      "image_embedding": {
        "type": "dense_vector",
        "dims": 768,
        "index": "true",
        "similarity": "cosine"
      },
      "image_data": {
        "type": "binary"
      }
    }
  }
}

PUT embed-images
{
  "mappings": {
    "properties": {
      "image_name": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword"
          }
        }
      },
      "image_embedding": {
        "type": "dense_vector",
        "dims": 1024,
        "index": "true",
        "similarity": "cosine"
      },
      "image_data": {
        "type": "binary"
      }
    }
  }
}
PUT jina-images
{
  "mappings": {
    "properties": {
      "image_name": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword"
          }
        }
      },
      "image_embedding": {
        "type": "dense_vector",
        "dims": 768,
        "index": "true",
        "similarity": "cosine"
      },
      "image_data": {
        "type": "binary"
      }
    }
  }
}

字段类型 dense_vector 将存储模型生成的嵌入。字段 binary 将以 base64 格式存储图像。

注意:将图像以二进制形式存储在 Elasticsearch 中不是一个好习惯。我们这样做只是为了这个例子的实际目的。建议使用静态文件存储库。

现在来看看代码。我们需要做的第一件事是使用 cloud id 和 api-key 初始化 Elasticsearch 客户端。在文件 /services/elasticsearch.py​​ 的开头写入以下代码:

[ ]
from elasticsearch import Elasticsearch, exceptions, helpers
ELASTIC_ENDPOINT = "https://your-elastic-endpoint.com:9243"
ELASTIC_API_KEY = "your-elasticsearch-api-key"
# Elasticsearch client
es_client = Elasticsearch(
    ELASTIC_ENDPOINT,
    api_key=ELASTIC_API_KEY,
)
# index documents using bulk api
def index_images(index_name: str, images_obj_arr: list):

    actions = [
        {
            "_index": index_name,
            "_source": {
                "image_data": obj["image_data"],
                "image_name": obj["image_name"],
                "image_embedding": obj["image_embedding"],
            },
        }
        for obj in images_obj_arr
    ]
    try:
        response = helpers.bulk(es_client, actions)
        return response
    except exceptions.ConnectionError as e:
        return e

# knn search
def knn_search(index_name: str, query_vector: list, k: int):
    query = {
        "size": 4,
        "_source": ["image_name", "image_data"],
        "query": {
            "knn": {
                "field": "image_embedding",
                "query_vector": query_vector,
                "k": k,
                "num_candidates": 100,
                "boost": 10,
            }
        },
    }
    try:
        response = es_client.search(index=index_name, body=query)
        return response
    except exceptions.ConnectionError as e:
        return e
# match all query
def get_all_query(index_name: str):
    query = {
        "size": 400,
        "source": ["image_name", "image_data"],
        "query": {"match_all": {}},
    }
    try:
        return es_client.search(index=index_name, body=query)
    except exceptions.ConnectionError as e:
        return e

配置模型

要配置模型,请将模型实例及其方法放入此文件中:/services/models.py。

Cohere Embed-3 模型作为 Web 服务工作,因此我们需要一个 API 密钥才能使用它。你可以在此处免费获取一个。试用限制为每分钟 5 次调用,每月 1,000 次调用。

要配置模型并使图像可在 Elasticsearch 中搜索,请按照以下步骤操作:

  • 使用 CLIP 将图像转换为向量
  • 将图像像量存储在 Elasticsearch 中
  • 将我们要与存储的图像进行比较的图像或文本向量化。
  • 运行查询以将上一步的条目与存储的图像进行比较并获取最相似的图像。
[ ]
# /services/models.py
# dependencies
import base64
import io
import cohere
from PIL import Image
from transformers import CLIPModel, CLIPProcessor, AutoModel
COHERE_API_KEY = "your-cohere-api-key"
## CLIP model call
clip_model = CLIPModel.from_pretrained("openai/clip-vit-large-patch14")
clip_processor = CLIPProcessor.from_pretrained("openai/clip-vit-large-patch14")
# JinaCLip model call
jina_model = AutoModel.from_pretrained("jinaai/jina-clip-v1", trust_remote_code=True)
# Cohere client initialization
co = cohere.ClientV2(COHERE_API_KEY)

配置 CLIP

要配置 CLIP,我们需要在 models.py 文件中添加生成图像和文本嵌入的方法。

# /services/models.py
# convert images to vector using CLIP
async def clip_image_embeddings(image: Image.Image):
    try:
        inputs = clip_processor(images=image, return_tensors="pt", padding=True)
        outputs = clip_model.get_image_features(**inputs)
        return outputs.detach().cpu().numpy().flatten().tolist()
    except Exception as e:
        print(f"Error generating embeddings: {e}")
        return None
# convert text to to vector
async def clip_text_embeddings(description: str):
    try:
        inputs = clip_processor([description], padding=True, return_tensors="pt")
        outputs = clip_model.get_text_features(**inputs)
        return outputs.detach().cpu().numpy().flatten().tolist()
    except Exception as e:
        print(f"Error generating embeddings: {e}")
        return None

对于所有模型,你需要声明类似的方法:一个用于从图像生成嵌入(clip_image_embeddings),另一个用于从文本生成嵌入(clip_text_embeddings)。

outputs.detach().cpu().numpy().flatten().tolist() 链是一种将 pytorch tensors 转换为更可用格式的常见操作:

  • .detach():从计算图中删除张量,因为我们不再需要计算梯度。
  • .cpu():将 tensors 从 GPU 移动到 CPU,因为 numpy 仅支持 CPU。
  • .numpy():将 tensors 转换为 numPy 数组。
  • .flatten():转换为 1D 数组。
  • .toList():转换为 Python 列表。

此操作将多维 tensor 转换为可用于嵌入操作的纯数字列表。

现在让我们看一些 CLIP 替代方案。

竞争对手 1:JinaCLIP

JinaCLIP 是 Jina AI 开发的 CLIP 变体,专门用于改进多模态应用中的图像和文本搜索。它通过增加图像和文本表示的灵活性来优化 CLIP 性能。

与原始 OpenAI CLIP 模型相比,JinaCLIP 在文本转文本、文本转图像、图像转文本和图像转图像任务中表现更好,如下图所示:

ModelText-TextText-to-ImageImage-to-TextImage-Image
jina-clip-v10.4290.8990.8030.916
openai-clip-vit-b160.1620.8810.7560.816
%increase vs OpenAI CLIP165%2%6%12%

它能够提高不同类型查询的精度,因此非常适合需要更精确、更详细分析的任务。

你可以在此处阅读有关 JinaCLIP 的更多信息。

要在我们的应用中使用 JinaCLIP 并生成嵌入,我们需要声明以下方法:

[ ]
# /services/models.py
# convert images to vector using JinaClip model
async def jina_image_embeddings(image: Image.Image):
    try:
        image_embeddings = jina_model.encode_image([image])
        return image_embeddings[0].tolist()
    except Exception as e:
        print(f"Error generating embeddings: {e}")
        return None
# convert text to vector
async def jina_text_embeddings(description: str):
    try:
        text_embeddings = jina_model.encode_text(description)
        return text_embeddings.tolist()
    except Exception as e:
        print(f"Error generating embeddings: {e}")
        return None

竞争对手 2:Cohere Image Embeddings V3

Cohere 开发了一种名为 Embed-3 的图像嵌入模型,它是 CLIP 的直接竞争对手。主要区别在于 Cohere 专注于企业数据(如图表、产品图像和设计文件)的表示。Embed-3 使用一种先进的架构,可以降低对文本数据的偏见风险,这目前是 CLIP 等其他多模态模型的劣势,因此它可以在文本和图像之间提供更精确的结果。

你可以在下方看到 Cohere 的图表,该图表显示了在这种数据中使用 Embed 3 与 CLIP 相比的改进结果:

有关更多信息,请访问 Embed3。

就像我们对之前的模型所做的那样,让我们​​声明使用 Embed 3 的方法:

[ ]
# /services/models.py
# convert images to vector using Cohere Embed model
async def embed_image_embeddings(image: Image.Image):
    try:
        img_byte_arr = io.BytesIO()
        image.save(img_byte_arr, format="JPEG")
        img_byte_arr = img_byte_arr.getvalue()
        stringified_buffer = base64.b64encode(img_byte_arr).decode("utf-8")
        content_type = "image/jpeg"
        image_base64 = f"data:{content_type};base64,{stringified_buffer}"
        response = co.embed(
            model="embed-english-v3.0",
            input_type="image",
            embedding_types=["float"],
            images=[image_base64],
        )
     return response.embeddings.float_[0]
    except Exception as e:
        print(f"Error generating embeddings: {e}")
        return None
# convert text to vector
async def embed_text_embeddings(description: str):
    try:
        response = co.embed(
            texts=[description],
            model="embed-english-v3.0",
            input_type="classification",
            embedding_types=["float"],
        )
     return response.embeddings.float_[0]
    except Exception as e:
        print(f"Error generating embeddings: {e}")
        return None

准备好函数后,让我们通过在文件 index_data.py 中添加以下代码来在 Elasticsearch 中索引数据集:

[ ]
# dependencies
import asyncio
import base64
import os
from PIL import Image
from services.elasticsearch import index_images
from services.models import (
    clip_image_embeddings,
    embed_image_embeddings,
    jina_image_embeddings,
)
# function to encode images
def encode_image_to_base64(image_path):
    with open(image_path, "rb") as img_file:
        return base64.b64encode(img_file.read()).decode("utf-8")
async def main():
    # folder with images
    folder_path = "./data"
    jina_obj_arr = []
    embed_obj_arr = []
    clip_obj_arr = []
    for filename in os.listdir(folder_path):
        img_path = os.path.join(folder_path, filename)
        print(f"Processing {filename}...")
        try:
            image_data = Image.open(img_path)
            # generating images embeddings
            clip_result, embed_result, jina_result = await asyncio.gather(
                clip_image_embeddings(image_data),
                embed_image_embeddings(image_data),
                jina_image_embeddings(image_data),
            )
            image_base64 = encode_image_to_base64(img_path)
            # building documents
            jina_obj_arr.append(
                {
                    "image_name": filename,
                    "image_embedding": jina_result,
                    "image_data": image_base64,
                }
            )
            embed_obj_arr.append(
                {
                    "image_name": filename,
                    "image_embedding": embed_result,
                    "image_data": image_base64,
                }
            )
            clip_obj_arr.append(
                {
                    "image_name": filename,
                    "image_embedding": clip_result,
                    "image_data": image_base64,
                }
            )
        except Exception as e:
            print(f"Error with {filename}: {e}")
    print("Indexing images in Elasticsearch...")
    # indexing images
    jina_count, _ = index_images(jina_index, jina_obj_arr)
    cohere_count, _ = index_images(embed_index, cohere_obj_arr)
    openai_count, _ = index_images(clip_index, openai_obj_arr)
    print("Cohere count: ", cohere_count)
    print("Jina count: ", jina_count)
    print("OpenAI count: ", openai_count)
if __name__ == "__main__":
    asyncio.run(main())

使用以下命令对文档进行索引:

python index_data.py

一旦数据集被索引,我们就可以创建 UI。

测试 UI

创建 UI

我们将使用 Streamlit 构建 UI 并并排比较这三种替代方案。

要构建 UI,我们首先将导入和依赖项添加到文件 app.py:

[ ]
# app.py
import asyncio
import base64
from io import BytesIO
import streamlit as st
from PIL import Image
from services.elasticsearch import get_all_query, knn_search
# declared functions imports
from services.models import (
    clip_image_embeddings,
    clip_text_embeddings,
    embed_image_embeddings,
    embed_text_embeddings,
    jina_image_embeddings,
    jina_text_embeddings,
)

对于此示例,我们将使用两个视图;一个用于图像搜索,另一个用于查看图像数据集:

[ ]
# app.py
if "selected_view" not in st.session_state:
    st.session_state.selected_view = "Index"
def change_view(view):
    st.session_state.selected_view = view
st.sidebar.title("Menu")
if st.sidebar.button("Search image"):
    change_view("Index")
if st.sidebar.button("All images"):
    change_view("Images")

让我们添加搜索图像的视图代码:

[ ]
if st.session_state.selected_view == "Index":
    # Index page
    st.title("Image Search")
    col1, col_or, col2 = st.columns([2, 1, 2])
    uploaded_image = None
    with col1:
        uploaded_image = st.file_uploader("Upload image", type=["jpg", "jpeg", "png"])
    with col_or:
        st.markdown(
            "<h3 style='text-align: center; margin-top: 50%;'>OR</h3>",
            unsafe_allow_html=True,
        )
    input_text = None
    with col2:
        st.markdown(
            "<div style='display: flex; margin-top: 3rem;  align-items: center; height: 100%; justify-content: center;'>",
            unsafe_allow_html=True,
        )
        input_text = st.text_input("Type text")
        st.markdown("</div>", unsafe_allow_html=True)
    st.write("")
    st.write("")
    search_button = st.markdown(
        """
        <style>
            .stButton>button {
                width: 50%;
                height: 50px;
                font-size: 20px;
                margin: 0 auto;
                display: block;
            }
        </style>
        """,
        unsafe_allow_html=True,
    )
    submit_button = st.button("Search")
    if uploaded_image:
        st.image(uploaded_image, caption="Uploaded Image", use_container_width=True)
    if submit_button:
        if uploaded_image or input_text:
            async def fetch_embeddings():
                data = None
                if uploaded_image:
                    image = Image.open(uploaded_image)
                    data = image
                elif input_text:
                    data = input_text
                # Getting image or text embeddings
                if uploaded_image:
                    openai_result, cohere_result, jina_result = await asyncio.gather(
                        clip_image_embeddings(data),
                        embed_image_embeddings(data),
                        jina_image_embeddings(data),
                    )
                elif input_text:
                    openai_result, cohere_result, jina_result = await asyncio.gather(
                        clip_text_embeddings(data),
                        embed_text_embeddings(data),
                        jina_text_embeddings(data),
                    )
                return openai_result, cohere_result, jina_result
            results = asyncio.run(fetch_embeddings())
            openai_result, cohere_result, jina_result = results
            if openai_result and cohere_result and jina_result:
                # calling knn query
                clip_search_results = knn_search("clip-images", openai_result, 5)
                jina_search_results = knn_search("jina-images", jina_result, 5)
                embed_search_results = knn_search("embed-images", cohere_result, 5)
                clip_search_results = clip_search_results["hits"]["hits"]
                jina_search_results = jina_search_results["hits"]["hits"]
                embed_search_results = embed_search_results["hits"]["hits"]
                st.subheader("Search Results")
                col1, spacer1, col2, spacer2, col3 = st.columns([3, 0.2, 3, 0.2, 3])
                def print_results(results):
                    for hit in results:
                        image_data = base64.b64decode(hit["_source"]["image_data"])
                        image = Image.open(BytesIO(image_data))
                        st.image(image, use_container_width=True)
                        st.write("score: ", hit["_score"])
                # printing results
                with col1:
                    st.write("CLIP")
                    print_results(clip_search_results)
                with col2:
                    st.write("JinaCLIP")
                    print_results(jina_search_results)
                with col3:
                    st.write("Cohere")
                    print_results(embed_search_results)
        else:
            st.warning("Please upload an image or type text to search.")

现在,图像视图的代码:

[ ]
elif st.session_state.selected_view == "Images":
    # images page
    st.header("All images")
    # getting all images
    images = get_all_query("jina-images")
    hits = images["hits"]["hits"]
    columns = st.columns(5)
    for idx, hit in enumerate(hits):
        image_data = base64.b64decode(hit["_source"]["image_data"])
        image = Image.open(BytesIO(image_data))
        with columns[idx % 5]:
            st.image(image, use_container_width=True)

我们将使用以下命令运行该应用程序:

streamlit run app.py

使用 Elasticsearch 来进行图形搜索 - CLIP 替代品

由于多模态性,我们可以在图像数据库中根据文本(文本到图像的相似性)或图像(图像到图像的相似性)运行搜索。

使用 UI 搜索

为了比较这三种模型,我们将使用一个场景,即房地产网页希望通过允许用户使用图像或文本进行搜索来改善其搜索体验。我们将讨论每种模型提供的结果。

我们将上传 “rustic home” 的图片:

以下是搜索结果。如你所见,根据我们上传的图像,每个模型都生成了不同的结果:

此外,你还可以看到根据文本查找房屋特征的结果:

如果搜索 “modern”,这三个模型都会显示良好的结果。但是,JinaCLIP 和 Cohere 会在第一个位置显示相同的房屋。

功能比较

下面是本文中介绍的三个选项的主要功能和价格的摘要:

ModelCreated byEstimated PriceFeatures
CLIPOpenAI每次重复运行 0.00058 美元 (https://replicate.com/krthr/clip-embeddings)针对文本和图像的通用多模态模型;适用于无需特定训练的各种应用。
JinaCLIPJina AI每 100 万枚 Jina tokens 需 0.018 美元 (https://jina.ai/embeddings/)针对多模式应用优化的 CLIP 变体。提高了检索文本和图像的精度。
Embed-3CohereCohere 上每 100 万个 tokens 收费 0.10 美元,每份数据和图像收费 0.0001 美元(https://cohere.com/pricing)专注于企业数据。改进了图形和图表等复杂视觉数据的检索。

如果你要搜索长图像描述,或者想要进行文本转文本和图像转文本,则应放弃 CLIP,因为 JinaCLIP 和 Embed-3 都针对此用例进行了优化。

JinaCLIP 是一种通用模型,而 Cohere 的模型更侧重于企业数据,如产品或图表。

在数据上测试模型时,请确保涵盖:

  • 你感兴趣的所有模式:文本转图像、图像转文本、文本转文本
  • 长图像描述和短图像描述
  • 相似概念匹配(同一类型对象的不同图像)
  • 负面
    • 硬负面:与预期输出相似但仍然错误
    • 简单负面:与预期输出不相似且错误
  • 具有挑战性的场景
    • 不同的角度/视角
    • 各种照明条件
    • 抽象概念(“modern”、“cozy”、“luxurious”)
  • 特定领域案例
    • 技术图表或图表(尤其是 Embed-3)
    • 产品变化(颜色、尺寸、样式)

结论

虽然 CLIP 是进行图像相似性搜索时的首选模型,但在某些情况下,商业和非商业替代方案都可以表现得更好。

JinaCLIP 是一款强大的一体化工具,据称在文本到文本嵌入方面比 CLIP 更精确。

Embed-3 遵循 Cohere 的路线,通过使用典型的业务文档使用真实数据训练模型来满足业务客户的需求。

在我们的小实验中,我们可以看到 JinaClip 和 Cohere 都显示了有趣的图像到图像和文本到图像结果,并且在这些类型的任务中表现与 CLIP 非常相似。

Elasticsearch 允许你搜索嵌入,将向量搜索与全文搜索相结合,使你能够搜索图像和其中的文本。

想要获得 Elastic 认证?了解下一次 Elasticsearch 工程师培训的时间!

Elasticsearch 包含新功能,可帮助你为你的用例构建最佳搜索解决方案。深入了解我们的示例笔记本以了解更多信息,开始免费云试用,或立即在本地机器上试用 Elastic。

原文:Exploring CLIP alternatives - Elasticsearch Labs

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2301355.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Nginx 在Linux中安装、使用

Nginx 在Linux中安装、使用 一、官网下载Nginx 官网地址&#xff1a;http://nginx.org/en/download.html 二、上传到服务器解压 1、上传到指定的服务器地址 上传的地址自己决定&#xff0c;我上传到 /data/home/prod/nginx/ 2、解压 使用命令&#xff1a; tar -zxvf “你的N…

【Spring+MyBatis】_图书管理系统(下篇)

图书管理系统上篇、中篇如下&#xff1a; 【SpringMyBatis】_图书管理系统&#xff08;上篇&#xff09;-CSDN博客 【SpringMyBatis】_图书管理系统&#xff08;中篇&#xff09;-CSDN博客 目录 功能5&#xff1a;删除图书 6.1 约定前后端交互接口 6.2 后端接口 6.3 前端…

若依-@Excel新增注解numberFormat

Excel注解中原本的scale会四舍五入小数&#xff0c;导致进度丢失 想要的效果 显示的时候保留两个小数真正的数值是保留之前的数值 还原过程 若以中有一個專門的工具类&#xff0c;用来处理excel的 找到EXCEL导出方法exportExcel()找到writeSheet,写表格的方法找到填充数据的方法…

Cherry-Studio下载安装教程,AI面向开发者的工具或平台(付安装包)

文章目录 一、Cherry Studio是什么&#xff1f;二、功能特点 一、Cherry Studio是什么&#xff1f; Cherry Studio 是一款开源跨平台的多模型服务桌面客户端&#xff0c;集成超 300 个大语言模型&#xff0c;内置 300 多个预配置 AI 助手&#xff0c;支持多格式文件处理、全局…

多信道接收机

线性调频&#xff08;LFM&#xff09;信号&#xff0c;模拟多个目标反射的回波信号&#xff0c;并进行混频和滤波处理。 % 参数设置 c 3e8; % 光速 (m/s) f0 8.566e9; % 载波频率 (Hz) T 10e-6; % 脉冲持续时间 (s) B 100e6; % 信号带宽 (Hz) mu B / T; % 调频斜率 (Hz/s…

修改项目的一些前端记录(自用)

<div style"background:#f2f2f2;position:absolute;top:75px;width:10%;bottom:0px">\<ol class"tree">\<li>\<label for"folder1" class"folderOne foldertop"><img src"common/img/时间.png" …

阿里云虚机的远程桌面登录提示帐户被锁定了

提示由于安全原因&#xff0c;帐户被锁定。 阿里云虚机ECS的远程桌面登录提示帐户被锁定了&#xff0c;只能登录阿里云处理 阿里云-计算&#xff0c;为了无法计算的价值 需选择通过VNC连接 然后计算机管理&#xff0c;解除帐户锁定即可。

AD(Altium Designer)器件封装——立创商城导出原理图和PCB完成器件封装操作指南

1、立创商城下载原理图和PCB图 1.1 打开立创商城 官网:www.SZLCSC.COM 1.2 寻找所需器件 以芯片为例 器件类——>芯片类——>对应芯片 1.3 确定所需芯片 确定芯片——>数据手册 1.4 打开原理图和PCB图 1:原理图 2:PCB 3:打开 1.5 导出原理图 操作

【DeepSeek系列】04 DeepSeek-R1:带有冷启动的强化学习

文章目录 1、简介2、主要改进点3、两个重要观点4、四阶段后训练详细步骤4.1 冷启动4.2 推理导向的强化学习4.3 拒绝采样和有监督微调4.4 针对所有场景的强化学习 5、蒸馏与强化学习对比6、评估6.1 DeepSeek-R1 评估6.2 蒸馏模型评估 7、结论8、局限性与未来方向 1、简介 DeepS…

Mac 清理缓存,提高内存空间

步骤 1.打开【访达】 2.菜单栏第五个功能【前往】&#xff0c;点击【个人】 3.【command shift J】显示所有文件&#xff0c;打开【资源库】 4.删除【Containers】和【Caches】文件 Containers 文件夹&#xff1a;用于存储每个应用程序的沙盒数据&#xff0c;确保应用程序…

fpga助教面试题

第一题 module sfp_pwm( input wire clk, //clk is 200M input wire rst_n, input wire clk_10M_i, input wire PPS_i, output reg pwm ) reg [6:0] cunt ;always (posedge clk ) beginif(!rst_n)cunt<0;else if(cunt19) //200M是10M的20倍cunt<0;elsecunt<cunt1;…

【强化学习】Q-learning算法详解:含MATLAB和Python实现代码

Q-learning算法详解 1. Q-learning算法简介Q-Learning算法的基本概念Q-Learning算法的核心思想Q-learning算法步骤Q-Learning算法的特点 MATLAB 实现 Q-learningPython 实现 Q-learning参考 强化学习属于机器学习&#xff0c;但与以前的监督学习和无监督学习的处理对象和任务都…

Java 多数据源时事务回滚问题

目录 问题描述 1、Atomikos事务管理器 2、MyBatis-Plus多数据源支持 dynamic-datasource 特性 约定 使用方法 mybatis-mate 特性 使用方法 问题描述 在多数据源的情况下&#xff0c;如果一个事务跨越多个数据源&#xff0c;当其中一个数据源的操作失败时&#xff0c;我…

使用html css js 开发一个 教育机构前端静态网站模板

这个教育机构网站模板是专为前端开发初学者设计的练习项目&#xff0c;适合正在学习前端的学生或自学者使用。网站内容包括首页、课程体系、师资力量、关于我们和联系我们等基础页面&#xff0c;帮助学习者熟悉网页布局、样式设计和交互功能的实现。 静态页面 简单截图 应用…

在IDEA的Maven中(同步所有Maven项目)和(重新加载所有Maven项目)的区别

特性同步所有 Maven 项目 (Sync All Maven Projects)重新加载所有 Maven 项目 (Reload All Maven Projects)主要作用使 IDEA 项目结构、依赖关系与 pom.xml 文件同步。强制重新读取所有 pom.xml 文件&#xff0c;并重建 IDEA 的 Maven 项目模型。缓存使用 IDEA 缓存的 Maven 项…

el-table树状表格,默认展开第一个节点的每一层

效果如图 <template><el-table:data"tableData"style"width: 100%":tree-props"{ children: children, hasChildren: hasChildren }":expand-row-keys"expandRowKeys"row-key"id"expand-change"handleExpan…

使用VSCODE开发C语言程序

使用vscode配置C语言开发环境 一、安装VSCODE 1、下载vscode ​ 从官方网站&#xff08;https://code.visualstudio.com/Download&#xff09;上&#xff0c;下载windows版本的vscode 2、安装vscode ​ 下载完毕后&#xff0c;按照提示进行安装即可&#xff08;尽可能不要安…

【数据结构初阶第十二节】设计循环队列

云边有个稻草人-CSDN博客 必须有为成功付出代价的决心&#xff0c;然后想办法付出这个代价。 还有最后一道关于队列的习题&#xff0c;这题有点难&#xff0c;准备好迎接挑战吧&#xff01; 目录 1.【题目】 2.实现循环队列推荐用数组&#xff0c;Why? 3.Q1&#xff1a;如…

【数据分享】1929-2024年全球站点的逐年降雪深度数据(Shp\Excel\免费获取)

气象数据是在各项研究中都经常使用的数据&#xff0c;气象指标包括气温、风速、降水、能见度等指标&#xff0c;说到气象数据&#xff0c;最详细的气象数据是具体到气象监测站点的数据&#xff01; 有关气象指标的监测站点数据&#xff0c;之前我们分享过1929-2024年全球气象站…

【强化学习的数学原理】第10课-Actor-Critic方法-笔记

学习资料&#xff1a;bilibili 西湖大学赵世钰老师的【强化学习的数学原理】课程。链接&#xff1a;强化学习的数学原理 西湖大学 赵世钰 文章目录 一、最简单的Actor-Critic&#xff08;QAC&#xff09;二、Advantage Actor-Critic&#xff08;A2C&#xff09;三、重要性采样和…