TWI769724B - Image feature extraction method and image feature extraction device, electronic device and storage media - Google Patents

Image feature extraction method and image feature extraction device, electronic device and storage media Download PDF

Info

Publication number
TWI769724B
TWI769724B TW110107747A TW110107747A TWI769724B TW I769724 B TWI769724 B TW I769724B TW 110107747 A TW110107747 A TW 110107747A TW 110107747 A TW110107747 A TW 110107747A TW I769724 B TWI769724 B TW I769724B
Authority
TW
Taiwan
Prior art keywords
blocks
sub
image
weight
columns
Prior art date
Application number
TW110107747A
Other languages
Chinese (zh)
Other versions
TW202236156A (en
Inventor
顏健武
Original Assignee
鴻海精密工業股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 鴻海精密工業股份有限公司 filed Critical 鴻海精密工業股份有限公司
Priority to TW110107747A priority Critical patent/TWI769724B/en
Application granted granted Critical
Publication of TWI769724B publication Critical patent/TWI769724B/en
Publication of TW202236156A publication Critical patent/TW202236156A/en

Links

Images

Landscapes

  • Image Analysis (AREA)

Abstract

The present application provides an image feature extraction method and an image feature extraction device, an electronic device and a storage medium. The method includes: converting images to an image matrix, and dividing the image matrix to obtain image sub-blocks, dividing the weight matrix to obtain weight vectors, and dividing each weight vector to obtain weight sub-blocks, dividing offset matrix to obtain offset quantum blocks, multiplying the weight sub-blocks of the weight vector with the image sub-blocks to obtain the feature sub-blocks, adding the feature sub-blocks and the offset quantum blocks to obtain image feature sub-blocks, and the image feature sub-blocks making up image feature. The present application can reduce the amount of computation in the neural network in the process of image feature extraction, thus improving efficiency of image feature extraction.

Description

圖像特徵提取方法、裝置、電子設備及存儲介質 Image feature extraction method, device, electronic device and storage medium

本申請涉及影像處理領域,具體涉及一種圖像特徵提取方法、裝置、電子設備及存儲介質。 The present application relates to the field of image processing, and in particular to an image feature extraction method, device, electronic device and storage medium.

在對圖像進行分類、識別和檢測之前,通常需要先對圖像的特徵進行提取,現有的圖像特徵提取方法主要使用圖像與權重向量直接相乘進行運算的方法實現特徵提取,使得圖像特徵提取的效率低下。 Before classifying, identifying and detecting an image, it is usually necessary to extract the features of the image. The existing image feature extraction methods mainly use the method of directly multiplying the image and the weight vector to achieve feature extraction, so that the image Inefficiencies like feature extraction.

鑒於以上內容,有必要提出一種圖像特徵提取方法、裝置、電子設備及存儲介質以提高圖像特徵提取的效率。 In view of the above content, it is necessary to propose an image feature extraction method, apparatus, electronic device and storage medium to improve the efficiency of image feature extraction.

本申請的第一方面提供一種圖像特徵提取方法,所述方法包括:獲取圖像,將所述圖像轉換為圖像矩陣,劃分所述圖像矩陣得到圖像向量,劃分所述圖像向量得到第一數量的圖像子塊;獲取權重矩陣,劃分所述權重矩陣得到第二數量的權重向量,劃分每個所述權重向量得到第一數量的權重子塊;獲取偏移量矩陣,劃分所述偏移量矩陣得到第二數量的偏移量子塊; 對第一數量的圖像子塊與每個所述權重向量的第一數量的權重子塊進行向量乘法得到第二數量的特徵子塊,將所述第二數量的特徵子塊與所述第二數量的偏移量子塊相加得到圖像特徵子塊,所述圖像特徵子塊組成圖像特徵。 A first aspect of the present application provides an image feature extraction method, the method includes: acquiring an image, converting the image into an image matrix, dividing the image matrix to obtain an image vector, and dividing the image vector to obtain a first number of image sub-blocks; obtain a weight matrix, divide the weight matrix to obtain a second number of weight vectors, divide each of the weight vectors to obtain a first number of weight sub-blocks; obtain an offset matrix, dividing the offset matrix to obtain a second number of offset quantum blocks; Perform vector multiplication on the first number of image sub-blocks and the first number of weight sub-blocks of each of the weight vectors to obtain a second number of feature sub-blocks, and combine the second number of feature sub-blocks with the first number of feature sub-blocks. Two numbers of offset quantum blocks are added to obtain image feature sub-blocks, and the image feature sub-blocks constitute image features.

優選地,所述圖像子塊、所述權重子塊、所述偏移量子塊中的每個都具有預設行數與預設列數,所述預設列數與所述預設行數相同。 Preferably, each of the image sub-block, the weight sub-block, and the offset sub-block has a preset number of rows and a preset number of columns, the preset number of columns and the preset number of rows same number.

優選地,所述劃分所述圖像矩陣得到圖像向量包括:將所述圖像矩陣按照所述預設行數進行劃分得到預備圖像向量集,所述預備圖像向量集包括至少一個預備圖像向量;判斷所述預備圖像向量集中是否存在行數小於所述預設行數的預備圖像向量;當所述預備圖像向量中存在行數小於所述預設行數的圖像向量時,使用所述預設數值填充所述行數小於所述預設行數的預備圖像向量得到行數等於所述預設行數的預備圖像向量,將所述預備圖像向量作為所述圖像向量;或當所述預備圖像向量中不存在行數小於所述預設行數的圖像向量時,將所述預備圖像向量作為所述圖像向量。 Preferably, the dividing the image matrix to obtain the image vector includes: dividing the image matrix according to the preset number of rows to obtain a preliminary image vector set, where the preliminary image vector set includes at least one preliminary image vector set. image vector; determine whether there is a preliminary image vector with the number of rows less than the preset number of rows in the preliminary image vector set; when there is an image with the number of rows less than the preset number of rows in the preliminary image vector vector, use the preset value to fill the preliminary image vector with the number of rows less than the preset number of rows to obtain a preliminary image vector with the number of rows equal to the preset number of rows, and use the preliminary image vector as the image vector; or when there is no image vector with a row number smaller than the preset row number in the preliminary image vector, the preliminary image vector is used as the image vector.

優選地,劃分所述圖像向量得到第一數量的圖像子塊包括:將所述圖像向量按照所述預設列數進行劃分得到第一數量的預備圖像子塊;判斷所述預備圖像子塊中是否存在列數小於所述預設列數的預備圖像子塊;當所述預備圖像子塊中存在列數小於所述預設列數的預備圖像子塊時,使用預設數值填充列數小於所述預設列數預備圖像子塊得到列數等於所述預設列數的預備圖像子塊,將第一數量的預備圖像子塊作為所述第一數量的圖像子塊; 或當所述預備圖像子塊中不存在列數小於所述預設列數的預備圖像子塊時,將所述第一數量的預備圖像子塊作為所述第一數量的圖像子塊。 Preferably, dividing the image vector to obtain the first number of image sub-blocks includes: dividing the image vector according to the preset number of columns to obtain the first number of preparatory image sub-blocks; determining the preparatory image sub-blocks Whether there is a preliminary image sub-block with a number of columns smaller than the preset number of columns in the image sub-block; when there is a preliminary image sub-block with a number of columns less than the preset number of columns in the preliminary image sub-block, Filling the preparatory image sub-blocks with a number of columns less than the preset number of columns using a preset value to obtain preparatory image sub-blocks with a number of columns equal to the preset number of columns, and using the first number of preparatory image sub-blocks as the first number of preparatory image sub-blocks a number of image sub-blocks; Or when there is no preliminary image sub-block with a column number smaller than the preset number of columns in the preliminary image sub-block, the first number of preliminary image sub-blocks is used as the first number of images subblock.

優選地,劃分所述權重矩陣得到第二數量的權重向量包括:將所述權重矩陣按照所述列數進行劃分得到第二數量的預備權重向量;判斷所述預備權重向量中是否存在列數小於所述預設列數的預備權重向量;當所述預備權重向量中存在列數小於所述預設列數的權重向量時,使用所述預設數值填充所述列數小於所述預設列數的預備權重向量得到列數等於所述預設列數的預備權重向量,將第二數量的預備權重向量作為第二數量的所述權重向量;或當所述預備權重向量中不存在列數小於所述預設列數的權重向量時,將第二數量的預備權重向量作為第二數量的所述權重向量。 Preferably, dividing the weight matrix to obtain a second number of weight vectors includes: dividing the weight matrix according to the number of columns to obtain a second number of preparatory weight vectors; judging whether the preparatory weight vector has a number of columns less than The preset weight vector with the preset number of columns; when there is a weight vector with the number of columns less than the preset number of columns in the prepared weight vector, use the preset value to fill the number of columns less than the preset number of columns. obtain a preliminary weight vector with the number of columns equal to the preset number of columns, and use the second number of preliminary weight vectors as the second number of the weight vectors; or when there is no column number in the preliminary weight vector When the number of weight vectors is smaller than the preset number of columns, the second number of preparatory weight vectors is used as the second number of weight vectors.

優選地,劃分每個所述權重向量得到第一數量的權重子塊包括:將每個所述權重向量按照所述行數進行劃分得到第四數量的預備權重子塊;判斷所述第四數量是否等於所述第一數量,當所述第四數量小於所述第一數量時,計算所述第四數量與所述第一數量的第一差值,並根據所述第一差值增加預備權重子塊的數量直至得到第一數量的預備權重子塊;或當所述第四數量大於所述第一數量時,從第四數量的預備權重子塊中選擇第一數量的預備權重子塊;判斷所述第一數量的預備權重子塊中是否存在列數小於所述預設列數的預備權重子塊;當所述第一數量的預備權重子塊中存在列數小於所述預設列數的預備權重子塊時,使用預設數值填充列數小於所述預設列數預備權重子塊得到列數等於所述預設列數的預備權重子塊,將第一數量的預備權重子塊作為第一數量的權 重子塊;或當所述第一數量的預備權重子塊中不存在列數小於所述預設列數的預備權重子塊時,將所述第一數量的預備權重子塊作為所述第一數量的權重子塊。 Preferably, dividing each of the weight vectors to obtain a first number of weight sub-blocks includes: dividing each of the weight vectors according to the number of rows to obtain a fourth number of preparatory weight sub-blocks; determining the fourth number of weight sub-blocks; Whether it is equal to the first quantity, when the fourth quantity is smaller than the first quantity, calculate the first difference between the fourth quantity and the first quantity, and increase the reserve value according to the first difference The number of weight sub-blocks until the first number of pre-weight sub-blocks are obtained; or when the fourth number is greater than the first number, the first number of pre-weight sub-blocks is selected from the fourth number of pre-weight sub-blocks ; Judging whether there is a preparatory weight sub-block whose number of columns is less than the preset number of columns in the preparatory weight sub-blocks of the first quantity; When the number of columns is pre-weight sub-blocks, use a preset value to fill the pre-weight sub-blocks with a number of columns smaller than the preset number of columns to obtain pre-weight sub-blocks with a number of columns equal to the preset number of columns, and use the pre-weight sub-blocks of the first number sub-block as the first number of weights heavy sub-block; or when there is no pre-weight sub-block with a number of columns less than the preset number of columns in the first number of pre-weight sub-blocks, the first number of pre-weight sub-blocks is used as the first The number of weighted sub-blocks.

優選地,所述劃分所述偏移量矩陣得到第二數量的偏移量子塊包括:將所述偏移量矩陣按照所述預設行數進行劃分得到預備偏移量向量,從所述預備偏移量向量中選擇一個偏移量向量;將所述偏移量向量按照所述預設列數進行劃分得到第五數量的預備偏移量子塊;判斷所述第五數量是否等於所述第二數量,當所述第五數量小於所述第二數量時,計算所述第五數量與所述第二數量的第二差值,並根據所述第二差值增加預備偏移量子塊的數量直至得到第二數量的預備偏移量子塊;或當所述第五數量大於所述第二數量時,從所述第五數量的預備偏移量子塊中選擇第二數量的預備偏移量子塊;判斷所述第二數量的預備偏移量子塊中是否存在列數小於所述預設列數或行數小於預設行數的預備偏移量子塊;當所述第二數量的預備偏移量子塊中存在列數小於所述預設列數或行數小於預設行數的預備偏移量子塊時,使用預設數值填充列數小於所述預設列數或行數小於預設行數的預備偏移量子塊得到列數等於所述預設列數且行數等於預設行數的預備偏移量子塊,將第二數量的預備偏移量子塊作為所述第二數量的偏移量子塊;或當所述第二數量的預備偏移量子塊中不存在列數小於所述預設列數或行數小於預設行數的預備偏移量子塊時,將第二數量的所述預備偏移量子塊作為所述第二數量的偏移量子塊。 Preferably, the dividing the offset matrix to obtain the second number of offset sub-blocks includes: dividing the offset matrix according to the preset number of rows to obtain a preliminary offset vector, from which the preliminary offset vector is obtained. Select an offset vector from the offset vectors; divide the offset vector according to the preset number of columns to obtain a fifth number of preliminary offset sub-blocks; determine whether the fifth number is equal to the first Two quantities, when the fifth quantity is smaller than the second quantity, calculate a second difference between the fifth quantity and the second quantity, and increase the amount of the preparatory offset quantum block according to the second difference number until a second number of preparatory offset quantum blocks are obtained; or when the fifth number is greater than the second number, select a second number of preparatory offset quantum blocks from the fifth number of preparatory offset quantum blocks block; determine whether there is a preliminary offset quantum block with the number of columns less than the preset number of columns or the number of rows less than the preset number of rows in the second number of preliminary offset quantum blocks; when the second number of preliminary offset quantum blocks exist When there are preliminary offset sub-blocks with the number of columns smaller than the preset number of columns or the number of rows smaller than the preset number of rows in the shift sub-block, use the preset value to fill the number of columns smaller than the preset number of columns or the number of rows smaller than the preset number of rows. The number of rows of preliminary offset sub-blocks is obtained to obtain preliminary offset sub-blocks with the number of columns equal to the preset number of columns and the number of rows equal to the preset number of rows, and the second number of preliminary offset sub-blocks is used as the second number of offset sub-blocks. Shift sub-blocks; or when there is no pre-shift sub-block with a number of columns smaller than the preset number of columns or a number of rows smaller than the preset number of rows in the second number of preliminary offset sub-blocks, transfer the second number of The preliminary offset quantum blocks serve as the second number of offset quantum blocks.

本申請的第二方面提供一種圖像特徵提取裝置,所述裝置包括: 圖像子塊獲取模組,用於獲取圖像,將所述圖像轉換為圖像矩陣,劃分所述圖像矩陣得到圖像向量,劃分所述圖像向量得到第一數量的圖像子塊;權重子塊獲取模組,用於獲取權重矩陣,劃分所述權重矩陣得到第二數量的權重向量,劃分每個所述權重向量得到第一數量的權重子塊;偏移量子塊獲取模組,用於獲取偏移量矩陣,劃分所述偏移量矩陣得到第二數量的偏移量子塊;圖像特徵計算模組,用於對第一數量的圖像子塊與每個所述權重向量的第一數量的權重子塊進行向量乘法得到第二數量的特徵子塊,將所述第二數量的特徵子塊與所述第二數量的偏移量子塊相加得到圖像特徵子塊,所述圖像特徵子塊組成圖像特徵。 A second aspect of the present application provides an image feature extraction device, the device comprising: An image sub-block acquisition module is used to acquire an image, convert the image into an image matrix, divide the image matrix to obtain an image vector, and divide the image vector to obtain a first number of image sub-blocks. block; a weight sub-block acquisition module is used to acquire a weight matrix, divide the weight matrix to obtain a second quantity of weight vectors, and divide each of the weight vectors to obtain a first quantity of weight sub-blocks; an offset quantum block acquisition module group, used to obtain an offset matrix, and divide the offset matrix to obtain a second number of offset sub-blocks; an image feature calculation module, used to compare the first number of image sub-blocks with each of the The first number of weight sub-blocks of the weight vector are vector multiplied to obtain a second number of feature sub-blocks, and the second number of feature sub-blocks and the second number of offset sub-blocks are added to obtain image feature sub-blocks block, the image feature sub-blocks constitute image features.

本申請的第三方面提供一種電子設備,所述電子設備包括:記憶體,存儲至少一個指令;及處理器,執行所述記憶體中存儲的指令以實現所述圖像特徵提取方法。 A third aspect of the present application provides an electronic device, the electronic device includes: a memory that stores at least one instruction; and a processor that executes the instructions stored in the memory to implement the image feature extraction method.

本申請的第四方面提供一種存儲介質,其上存儲有電腦程式,所述電腦程式被處理器執行時實現所述的圖像特徵提取方法。 A fourth aspect of the present application provides a storage medium on which a computer program is stored, and when the computer program is executed by a processor, the image feature extraction method is implemented.

本申請中,本實施方式中,藉由將圖像矩陣、權重矩陣和偏差矩陣劃分為子塊進行運算,減少了圖像特徵提取過程中神經網路中卷積運算的運算量,從而提高了對圖像中特徵進行提取的效率。 In this application, in this embodiment, by dividing the image matrix, the weight matrix and the deviation matrix into sub-blocks for operation, the calculation amount of the convolution operation in the neural network during the image feature extraction process is reduced, thereby improving the The efficiency of extracting features from images.

30:圖像特徵提取裝置 30: Image feature extraction device

301:圖像子塊獲取模組 301: Image sub-block acquisition module

302:權重子塊獲取模組 302: Weight sub-block acquisition module

303:偏移量子塊獲取模組 303: Offset quantum block acquisition module

304:圖像特徵計算模組 304: Image feature calculation module

6:電子設備 6: Electronic equipment

61:記憶體 61: Memory

62:處理器 62: Processor

63:電腦程式 63: Computer Programs

S11~S14:步驟 S11~S14: Steps

圖1為本申請一實施方式中圖像特徵提取方法的流程圖。 FIG. 1 is a flowchart of an image feature extraction method in an embodiment of the present application.

圖2為本申請一實施方式中圖像特徵提取裝置的結構圖。 FIG. 2 is a structural diagram of an image feature extraction apparatus according to an embodiment of the present application.

圖3為本申請一實施方式中電子設備的示意圖。 FIG. 3 is a schematic diagram of an electronic device in an embodiment of the present application.

圖4為本申請一實施方式中圖像特徵提取方法的示意圖。 FIG. 4 is a schematic diagram of an image feature extraction method in an embodiment of the present application.

為了能夠更清楚地理解本發明的上述目的、特徵和優點,下面結合附圖和具體實施例對本發明進行詳細描述。需要說明的是,在不衝突的情況下,本申請的實施例及實施例中的特徵可以相互組合。 In order to more clearly understand the above objects, features and advantages of the present invention, the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present application and the features in the embodiments may be combined with each other in the case of no conflict.

在下面的描述中闡述了很多具體細節以便於充分理解本發明,所描述的實施例僅僅是本發明一部分實施例,而不是全部的實施例。基於本發明中的實施例,本領域普通技術人員在沒有做出創造性勞動前提下所獲得的所有其他實施例,都屬於本發明保護的範圍。 In the following description, many specific details are set forth in order to facilitate a full understanding of the present invention, and the described embodiments are only some, but not all, embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

除非另有定義,本文所使用的所有的技術和科學術語與屬於本發明的技術領域的技術人員通常理解的含義相同。本文中在本發明的說明書中所使用的術語只是為了描述具體的實施例的目的,不是旨在於限制本發明。 Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. The terms used herein in the description of the present invention are for the purpose of describing specific embodiments only, and are not intended to limit the present invention.

優選地,本申請圖像特徵提取方法應用在一個或者多個電子設備中。所述電子設備是一種能夠按照事先設定或存儲的指令,自動進行數值計算和/或資訊處理的設備,其硬體包括但不限於微處理器、專用積體電路(Application Specific Integrated Circuit,ASIC)、可程式設計閘陣列(Field-Programmable Gate Array,FPGA)、數位訊號處理器(Digital Signal Processor,DSP)、嵌入式設備等。 Preferably, the image feature extraction method of the present application is applied in one or more electronic devices. The electronic device is a device that can automatically perform numerical calculation and/or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (ASICs) , Programmable Gate Array (Field-Programmable Gate Array, FPGA), Digital Signal Processor (Digital Signal Processor, DSP), embedded devices, etc.

所述電子設備可以是桌上型電腦、筆記型電腦、平板電腦及雲端伺服器等計算設備。所述電子設備可以與使用者藉由鍵盤、滑鼠、遙控器、觸控板或聲控設備等方式進行人機交互。 The electronic device may be a computing device such as a desktop computer, a notebook computer, a tablet computer, and a cloud server. The electronic device can perform human-computer interaction with the user by means of a keyboard, a mouse, a remote control, a touch pad or a voice control device.

實施例1 Example 1

圖1是本申請一實施方式中圖像特徵提取方法的流程圖。所述圖像特徵提取方法應用於電子設備中。根據不同的需求,所述流程圖中步驟的順序可以改變,某些步驟可以省略。 FIG. 1 is a flowchart of an image feature extraction method in an embodiment of the present application. The image feature extraction method is applied in electronic equipment. According to different requirements, the order of the steps in the flowchart can be changed, and some steps can be omitted.

參閱圖1所示,所述圖像特徵提取方法具體包括以下步驟。 Referring to FIG. 1 , the image feature extraction method specifically includes the following steps.

步驟S11,獲取圖像,將所述圖像轉換為圖像矩陣,劃分所述圖像矩陣得到圖像向量,劃分所述圖像向量得到第一數量的圖像子塊。 Step S11, acquiring an image, converting the image into an image matrix, dividing the image matrix to obtain an image vector, and dividing the image vector to obtain a first number of image sub-blocks.

在本申請的至少一個實施例中,所述將所述圖像轉換為圖像矩陣包括:讀取所述圖像;獲取所述圖像中的圖元點;將所述圖元點的三原色編碼值組成圖元向量,及將所述圖元向量組成所述圖像矩陣。 In at least one embodiment of the present application, the converting the image into an image matrix includes: reading the image; acquiring a primitive point in the image; converting the three primary colors of the primitive point The encoded values form primitive vectors, and the primitive vectors form the image matrix.

在本申請的至少一個實施例中,所述劃分所述圖像矩陣得到圖像向量包括:將所述圖像矩陣按照所述預設行數進行劃分得到預備圖像向量集,所述預備圖像向量集包括至少一個預備圖像向量;判斷所述預備圖像向量集中是否存在行數小於所述預設行數的預備圖像向量;當所述預備圖像向量中存在行數小於所述預設行數的圖像向量時,使用所述預設數值填充所述行數小於所述預設行數的預備圖像向量得到行數等於所述預設行數的預備圖像向量,將所述預備圖像向量作為所述圖像向量;或當所述預備圖像向量中不存在行數小於所述預設行數的圖像向量時,將所述預備圖像向量作為所述圖像向量。 In at least one embodiment of the present application, the dividing the image matrix to obtain the image vector includes: dividing the image matrix according to the preset number of rows to obtain a preliminary image vector set, the preliminary image vector set. The image vector set includes at least one preliminary image vector; it is judged whether there is a preliminary image vector whose number of rows is less than the preset number of rows in the preliminary image vector set; When the image vector with the preset number of lines is used, the preset value is used to fill the preliminary image vector with the number of lines less than the preset number of lines to obtain a preliminary image vector with the number of lines equal to the preset number of lines, and the The preparatory image vector is used as the image vector; or when there is no image vector whose number of rows is less than the preset number of rows in the preparatory image vector, the preparatory image vector is used as the image vector. like a vector.

在本申請的至少一個實施例中,劃分所述圖像向量得到第一數量的圖像子塊包括:將所述圖像向量按照所述預設列數進行劃分得到第一數量的預備圖像子塊; 判斷所述預備圖像子塊中是否存在列數小於所述預設列數的預備圖像子塊;當所述預備圖像子塊中存在列數小於所述預設列數的預備圖像子塊時,使用預設數值填充列數小於所述預設列數預備圖像子塊得到列數等於所述預設列數的預備圖像子塊,將第一數量的預備圖像子塊作為所述第一數量的圖像子塊;或當所述預備圖像子塊中不存在列數小於所述預設列數的預備圖像子塊時,將所述第一數量的預備圖像子塊作為所述第一數量的圖像子塊。 In at least one embodiment of the present application, dividing the image vector to obtain the first number of image sub-blocks includes: dividing the image vector according to the preset number of columns to obtain the first number of preliminary images subblock; Judging whether there is a preparatory image subblock with a number of columns less than the preset number of columns in the preparatory image subblock; when there is a preparatory image in the preparatory image subblock with a number of columns smaller than the preset number When sub-blocks, use a preset value to fill the pre-image sub-blocks with the number of columns less than the preset number of columns to obtain pre-image sub-blocks with the number of columns equal to the preset number of columns, and fill the pre-image sub-blocks with the first number of pre-image sub-blocks. as the first number of image sub-blocks; or when there is no preliminary image sub-block with a number of columns less than the preset number of columns in the preliminary image sub-block, the first number of preliminary image sub-blocks image sub-blocks as the first number of image sub-blocks.

例如,所述預設行數可以是3行,所述預設列數可以是3列,所述預設數值可以是0。當所述圖像矩陣的行數為11行且列數為11列時,按3行劃分所述圖像矩陣得到4個預備圖像向量,其中一個預備圖像向量為2行11列,使用0填充該預備圖像向量,得到4個3行11列的圖像向量;按3列對3行11列的圖像向量進行劃分得到4個預備圖像子塊,其中一個預備圖像子塊為3行2列,使用預設數值0對該預備圖像子塊進行填充,得到4個3行3列的圖像子塊。 For example, the preset number of rows may be 3 rows, the preset number of columns may be 3 columns, and the preset value may be 0. When the number of rows of the image matrix is 11 and the number of columns is 11, divide the image matrix by 3 rows to obtain 4 preliminary image vectors, one of which is 2 rows and 11 columns, using Fill the preliminary image vector with 0 to obtain four image vectors of 3 rows and 11 columns; divide the image vector of 3 rows and 11 columns by 3 columns to obtain 4 preliminary image sub-blocks, one of which is a preliminary image sub-block For 3 rows and 2 columns, use a preset value of 0 to fill the preliminary image sub-block to obtain 4 image sub-blocks with 3 rows and 3 columns.

又例如,參照圖4,將圖像向量A按照預設列數進行劃分,得到m個預備圖像子塊,當第m個預備圖像子塊的列數小於預設列數時,使用0填充第m個預備圖像子塊,得到m個圖像子塊。 For another example, referring to FIG. 4 , the image vector A is divided according to the preset number of columns to obtain m preliminary image sub-blocks. When the number of columns of the m-th preliminary image sub-block is less than the preset number of columns, 0 is used. Fill the m-th preliminary image sub-block to obtain m image sub-blocks.

步驟S12,獲取權重矩陣,劃分所述權重矩陣得到第二數量的權重向量,劃分每個所述權重向量得到第一數量的權重子塊。 Step S12, obtaining a weight matrix, dividing the weight matrix to obtain a second number of weight vectors, and dividing each of the weight vectors to obtain a first number of weight sub-blocks.

在本申請的至少一個實施例中,劃分所述權重矩陣得到第二數量的權重向量包括:將所述權重矩陣按照所述列數進行劃分得到第二數量的預備權重向量;判斷所述預備權重向量中是否存在列數小於所述預設列數的預備權重向量; 當所述預備權重向量中存在列數小於所述預設列數的權重向量時,使用所述預設數值填充所述列數小於所述預設列數的預備權重向量得到列數等於所述預設列數的預備權重向量,將第二數量的預備權重向量作為第二數量的所述權重向量;或當所述預備權重向量中不存在列數小於所述預設列數的權重向量時,將第二數量的預備權重向量作為第二數量的所述權重向量。 In at least one embodiment of the present application, dividing the weight matrix to obtain the second quantity of weight vectors includes: dividing the weight matrix according to the number of columns to obtain the second quantity of preliminary weight vectors; judging the preliminary weights Whether there is a preliminary weight vector with the number of columns less than the preset number of columns in the vector; When there is a weight vector with a number of columns less than the preset number of columns in the prepared weight vector, use the preset value to fill the prepared weight vector with a number of columns less than the preset number of columns, so that the number of columns is equal to the Preliminary weight vectors with a preset number of columns, using the second number of preliminary weight vectors as the second number of weight vectors; or when there is no weight vector with a number of columns less than the preset number of columns in the preliminary weight vector , taking the second quantity of preparatory weight vectors as the second quantity of the weight vectors.

在本申請的至少一個實施例中,劃分每個所述權重向量得到第一數量的權重子塊包括:將每個所述權重向量按照所述行數進行劃分得到第四數量的預備權重子塊;判斷所述第四數量是否等於所述第一數量,當所述第四數量小於所述第一數量時,計算所述第四數量與所述第一數量的第一差值,並根據所述第一差值增加預備權重子塊的數量直至得到第一數量的預備權重子塊;或當所述第四數量大於所述第一數量時,從第四數量的預備權重子塊中選擇第一數量的預備權重子塊;判斷所述第一數量的預備權重子塊中是否存在列數小於所述預設列數的預備權重子塊;當所述第一數量的預備權重子塊中存在列數小於所述預設列數的預備權重子塊時,使用預設數值填充列數小於所述預設列數預備權重子塊得到列數等於所述預設列數的預備權重子塊,將第一數量的預備權重子塊作為第一數量的權重子塊;或當所述第一數量的預備權重子塊中不存在列數小於所述預設列數的預備權重子塊時,將所述第一數量的預備權重子塊作為所述第一數量的權重子塊。 In at least one embodiment of the present application, dividing each of the weight vectors to obtain the first number of weight sub-blocks includes: dividing each of the weight vectors according to the number of rows to obtain a fourth number of preparatory weight sub-blocks ; Determine whether the fourth quantity is equal to the first quantity, and when the fourth quantity is less than the first quantity, calculate the first difference between the fourth quantity and the first quantity, and according to the The first difference value increases the number of preparatory weight sub-blocks until the first number of preparatory weight sub-blocks is obtained; or when the fourth number is greater than the first number, selects the first number of preparatory weight sub-blocks from the fourth number of sub-blocks. a number of pre-weight sub-blocks; determine whether there are pre-weight sub-blocks with a number of columns smaller than the preset number of columns in the first number of pre-weight sub-blocks; when there are pre-weight sub-blocks in the first number of pre-weight sub-blocks When the number of columns is less than the preset number of columns of the pre-weight sub-blocks, using a preset value to fill the pre-weight sub-blocks with the number of columns less than the preset number of columns to obtain the pre-weight sub-blocks of which the number of columns is equal to the preset number of columns, Take the first number of preparatory weight sub-blocks as the first number of weight sub-blocks; or when there is no preparatory weight sub-block with the number of columns less than the preset number of columns in the first number of preparatory weight sub-blocks, use The first number of preparatory weight sub-blocks is used as the first number of weight sub-blocks.

在本申請的至少一個實施例中,所述權重矩陣用於度量圖像矩陣中特徵的重要程度。 In at least one embodiment of the present application, the weight matrix is used to measure the importance of features in the image matrix.

在本申請的至少一個實施例中,所述權重矩陣可以是自編碼器的編碼層中的一個矩陣,也可以是卷積神經網路的卷積層中的一個矩陣,所述權重矩陣可以存儲在人工智慧晶片中,用於進行通用矩陣乘法運算。 In at least one embodiment of the present application, the weight matrix may be a matrix in an encoding layer of an autoencoder or a matrix in a convolutional layer of a convolutional neural network, and the weight matrix may be stored in In artificial intelligence chips, it is used to perform general matrix multiplication operations.

例如,當所述權重矩陣的行數為11行且列數為11列時,按3行劃分所述權重矩陣得到4個預備權重向量,其中一個預備權重向量為2行11列,使用0填充該預備權重向量,得到4個3行11列的權重向量;按3列對3行11列的權重向量進行劃分得到4個預備權重子塊,其中一個預備權重子塊為3行2列,使用預設數值0對該預備權重子塊進行填充,得到4個3行3列的權重子塊。 For example, when the weight matrix has 11 rows and 11 columns, divide the weight matrix by 3 rows to obtain 4 preliminary weight vectors, one of which is 2 rows and 11 columns, and is filled with 0 The preliminary weight vector, four weight vectors with 3 rows and 11 columns are obtained; the weight vector with 3 rows and 11 columns is divided by 3 columns to obtain 4 preliminary weight sub-blocks, one of which is a preliminary weight sub-block with 3 rows and 2 columns, using The preset weight sub-block is filled with a preset value of 0 to obtain four weight sub-blocks with 3 rows and 3 columns.

又例如,參照圖4所示,對權重矩陣B進行按預設列數劃分得到n列預備權重向量,當第n列預備權重向量的列數小於預設列數時,使用0填充第n列預備權重向量,得到n列權重向量;對n列權重向量的每一列按預設行數進行劃分,得到m個預備權重區塊,當第m個預備權重子塊的列數小於預設列數時,使用0填充第m個預備權重子塊,得到m個權重子塊。 For another example, referring to FIG. 4 , divide the weight matrix B according to the preset number of columns to obtain n columns of preliminary weight vectors, and when the number of columns of the nth column of preliminary weight vectors is less than the preset number of columns, use 0 to fill the nth column. Prepare the weight vector to obtain n-column weight vector; divide each column of the n-column weight vector according to the preset number of rows to obtain m preliminary weight blocks, when the number of columns of the mth preliminary weight sub-block is less than the preset number of columns When , use 0 to fill the m-th preparatory weight sub-block to obtain m weight sub-blocks.

步驟S13,獲取偏移量矩陣,劃分所述偏移量矩陣得到第二數量的偏移量子塊。 Step S13: Obtain an offset matrix, and divide the offset matrix to obtain a second number of offset sub-blocks.

在本申請的至少一個實施例中,所述劃分所述偏移量矩陣得到第二數量的偏移量子塊包括:將所述偏移量矩陣按照所述預設行數進行劃分得到預備偏移量向量,從所述預備偏移量向量中選擇一個偏移量向量;將所述偏移量向量按照所述預設列數進行劃分得到第五數量的預備偏移量子塊;判斷所述第五數量是否等於所述第二數量,當所述第五數量小於所述第二數量時,計算所述第五數量與所述第二數量的第二差值,並根據所述第二差值增加預備偏移量子塊的數量直至得到第二數量的預備偏移量子塊;或當所述第 五數量大於所述第二數量時,從所述第五數量的預備偏移量子塊中選擇第二數量的預備偏移量子塊;判斷所述第二數量的預備偏移量子塊中是否存在列數小於所述預設列數或行數小於預設行數的預備偏移量子塊;當所述第二數量的預備偏移量子塊中存在列數小於所述預設列數或行數小於預設行數的預備偏移量子塊時,使用預設數值填充列數小於所述預設列數或行數小於預設行數的預備偏移量子塊得到列數等於所述預設列數且行數等於預設行數的預備偏移量子塊,將第二數量的預備偏移量子塊作為所述第二數量的偏移量子塊;或當所述第二數量的預備偏移量子塊中不存在列數小於所述預設列數或行數小於預設行數的預備偏移量子塊時,將第二數量的所述預備偏移量子塊作為所述第二數量的偏移量子塊。 In at least one embodiment of the present application, the dividing the offset matrix to obtain the second number of offset sub-blocks includes: dividing the offset matrix according to the preset number of rows to obtain preliminary offsets selecting an offset vector from the preliminary offset vectors; dividing the offset vector according to the preset number of columns to obtain a fifth number of preliminary offset sub-blocks; judging the first Whether the five quantity is equal to the second quantity, when the fifth quantity is smaller than the second quantity, calculate the second difference between the fifth quantity and the second quantity, and calculate the second difference according to the second difference Increase the number of preparatory offset quantum blocks until a second number of preparatory offset quantum blocks are obtained; or when the first When the number of five is greater than the second number, select a second number of preliminary offset quantum blocks from the fifth number of preliminary offset quantum blocks; determine whether there is a column in the second number of preliminary offset quantum blocks The number of preliminary offset sub-blocks is less than the preset number of columns or the number of rows is less than the preset number of rows; when the number of columns in the second number of preliminary offset sub-blocks is less than the preset number of columns or the number of rows is less than When there are pre-set offset sub-blocks with a preset number of rows, use a preset value to fill in the pre-offset sub-blocks whose number of columns is less than the preset number of columns or the number of rows is less than the preset number of rows, so that the number of columns is equal to the preset number of columns and the number of rows is equal to the number of preparatory offset quantum blocks, the second number of preparatory offset quantum blocks is used as the second number of preparatory offset quantum blocks; or when the second number of preparatory offset quantum blocks is When there is no preparatory offset quantum block whose number of columns is less than the preset number of columns or the number of rows is less than the preset number of rows, use the second number of the preparatory offset quantum blocks as the second number of offset quantum blocks .

在本申請的至少一個實施例中,所述偏移量矩陣用於度量神經網路產生正激勵或負激勵的難易程度。 In at least one embodiment of the present application, the offset matrix is used to measure the difficulty of generating positive excitation or negative excitation by the neural network.

在本申請的至少一個實施例中,所述偏移量矩陣可以是自編碼器的編碼層中的一個矩陣,也可以是卷積神經網路的卷積層中的一個矩陣,所述偏移量矩陣可以存儲在人工智慧晶片中,用於進行通用矩陣乘法運算。 In at least one embodiment of the present application, the offset matrix may be a matrix in an encoding layer of an autoencoder, or may be a matrix in a convolutional layer of a convolutional neural network, and the offset Matrices can be stored in AI chips for general-purpose matrix multiplication.

例如,當所述權重矩陣的行數為11行且列數為11列時,按3行劃分所述權重矩陣得到4個預備權重向量,選取第一個預備權重向量作為權重向量;按3列對3行11列的權重向量進行劃分得到4個預備權重子塊,其中一個預備權重子塊為3行2列,使用預設數值0對該預備權重子塊進行填充,得到4個3行3列的權重子塊。 For example, when the number of rows of the weight matrix is 11 and the number of columns is 11, the weight matrix is divided into 3 rows to obtain 4 preliminary weight vectors, and the first preliminary weight vector is selected as the weight vector; Divide the weight vector of 3 rows and 11 columns to obtain 4 preparatory weight sub-blocks, one of which is 3 rows and 2 columns, and use the preset value 0 to fill the preparatory weight sub-block to obtain 4 pre-weight sub-blocks of 3 rows and 3 The weight subblock for the column.

又例如,參照圖4所示,對偏移量向量C按照預設列數進行劃分,得到n個預備偏移量子塊,當第n個預備偏移量子塊的列數小於預設列數時,使用0填充第n個預備偏移量子塊,得到n個偏移量子塊。 For another example, referring to FIG. 4 , the offset vector C is divided according to the preset number of columns to obtain n preliminary offset sub-blocks, when the number of columns of the nth preliminary offset sub-block is less than the preset number of columns. , fill the nth preparatory offset quantum block with 0 to obtain n offset quantum blocks.

步驟S14,對第一數量的圖像子塊與每個所述權重向量的第一數量的權重子塊進行向量乘法得到第二數量的特徵子塊,將所述第二數量的特徵子塊與所述第二數量的偏移量子塊相加得到圖像特徵子塊,所述圖像特徵子塊組成圖像特徵。 Step S14, performing vector multiplication on the first number of image sub-blocks and the first number of weight sub-blocks of each of the weight vectors to obtain a second number of feature sub-blocks, and combining the second number of feature sub-blocks with The second number of offset sub-blocks are added to obtain image feature sub-blocks, and the image feature sub-blocks constitute image features.

例如,使用權重向量的4個權重子塊與圖像向量的4個圖像子塊分別相乘並求和,得到4個特徵子塊,將4個特徵子塊與4個偏移量子塊相加得到4個圖像特徵子塊,4個圖像特徵子塊組成圖像特徵。 For example, using the 4 weight sub-blocks of the weight vector and the 4 image sub-blocks of the image vector are respectively multiplied and summed to obtain 4 feature sub-blocks, and the 4 feature sub-blocks are combined with the 4 offset sub-blocks Four image feature sub-blocks are obtained by adding, and the four image feature sub-blocks constitute image features.

又例如參照圖4所示,對圖像向量A與權重矩陣中每列權重向量進行向量乘法運算,即將圖像向量A中的m個圖像子塊與每列權重向量中的m個權重子塊依次相乘並求和,得到n個特徵子塊,將n個特徵子塊與n個偏移量子塊依次相加,得到n個圖像特徵子塊,n個圖像特徵子塊組成圖像特徵。 For another example, as shown in FIG. 4 , a vector multiplication operation is performed on the image vector A and the weight vector in each column of the weight matrix, that is, the m image sub-blocks in the image vector A and the m weight sub-blocks in each column of the weight vector. The blocks are multiplied and summed in turn to obtain n feature sub-blocks, and the n feature sub-blocks and n offset sub-blocks are added in turn to obtain n image feature sub-blocks, and n image feature sub-blocks form a graph like features.

在本申請的至少一個實施例中,在本申請的至少一個實施例中,所述圖像子塊、所述權重子塊、所述偏移量子塊中的每個都具有預設行數與預設列數,所述預設列數與所述預設行數相同。 In at least one embodiment of the present application, in at least one embodiment of the present application, each of the image sub-block, the weight sub-block, and the offset sub-block has a preset number of rows equal to The preset number of columns, the preset number of columns is the same as the preset number of rows.

在本申請的至少一個實施例中,所述圖像特徵提取方法可以用於相似圖像判斷。 In at least one embodiment of the present application, the image feature extraction method can be used to determine similar images.

具體地,使用所述圖像特徵提取方法進行相似圖像判斷包括:獲取第一待檢測圖像和第二待檢測圖像,並將所述第一待檢測圖像與所述第二待檢測圖像轉為第一待檢測圖像向量與第二待檢測圖像向量;使用所述圖像特徵提取方法計算得到所述第一待檢測圖像向量的第一待檢測圖像特徵與所述第二待檢測圖像向量的第二待檢測圖像特徵;使用預設的誤差函數計算所述第一待檢測圖像特徵與所述第二待檢測圖像特徵之間的誤差函數值; 當所述誤差函數值小於預設的閾值時,判斷所述第一待檢測圖像與所述第二待檢測圖像為同一圖像,當所述誤差函數值大於預設的閾值時,判斷所述第一待檢測圖像與所述第二待檢測圖像為不同的圖像。 Specifically, using the image feature extraction method to determine similar images includes: acquiring a first image to be detected and a second image to be detected, and comparing the first image to be detected and the second image to be detected The image is converted into a first to-be-detected image vector and a second to-be-detected image vector; using the image feature extraction method to calculate the first to-be-detected image feature of the first to-be-detected image vector and the described The second to-be-detected image feature of the second to-be-detected image vector; using a preset error function to calculate an error function value between the first to-be-detected image feature and the second to-be-detected image feature; When the error function value is less than a preset threshold, it is determined that the first image to be detected and the second image to be detected are the same image, and when the error function value is greater than the preset threshold, it is determined that the first image to be detected and the second image to be detected are the same image The first image to be detected and the second image to be detected are different images.

在本申請的其他實施方式中,所述圖像特徵提取方法還可以用於自編碼器。 In other embodiments of the present application, the image feature extraction method may also be used in an autoencoder.

具體地,所述圖像特徵提取方法可以用於自編碼器的編碼層和/或解碼層,藉由所述編碼器重構圖像包括:獲取待重構圖像,並將所述待重構圖像轉為待重構圖像向量;將所述待重構圖像向量輸入所述自編碼器的編碼層,所述自編碼器的編碼層使用所述圖像特徵提取方法得到重構圖像隱向量;將所述重構圖像隱向量輸入所述自編碼器的解碼層,所述自編碼器的解碼層使用所述圖像特徵提取方法得到所述待重構圖像的重構圖像。 Specifically, the image feature extraction method can be applied to the encoding layer and/or decoding layer of the self-encoder, and reconstructing the image by the encoder includes: acquiring the image to be reconstructed, and converting the image to be reconstructed. The reconstructed image is converted into an image vector to be reconstructed; the image vector to be reconstructed is input into the coding layer of the self-encoder, and the coding layer of the self-encoder uses the image feature extraction method to obtain reconstruction Image latent vector; input the reconstructed image latent vector into the decoding layer of the self-encoder, and the decoding layer of the self-encoder uses the image feature extraction method to obtain the reconstruction of the image to be reconstructed. compose the image.

本實施方式中,藉由將圖像矩陣、權重矩陣和偏差矩陣劃分為子塊進行運算,減少了圖像特徵提取過程中神經網路中卷積運算的運算量,從而提高了對圖像中特徵進行提取的效率。 In this embodiment, by dividing the image matrix, the weight matrix and the deviation matrix into sub-blocks for operation, the calculation amount of the convolution operation in the neural network in the process of image feature extraction is reduced, thereby improving the accuracy of the image in the image. The efficiency of feature extraction.

實施例2 Example 2

圖2為本申請一實施方式中圖像特徵提取裝置30的結構圖。 FIG. 2 is a structural diagram of an image feature extraction apparatus 30 in an embodiment of the present application.

在一些實施例中,所述圖像特徵提取裝置30運行於電子設備中。所述圖像特徵提取裝置30可以包括多個由程式碼段所組成的功能模組。所述圖像特徵提取裝置30中的各個程式段的程式碼可以存儲於記憶體中,並由至少一個處理器所執行,以執行圖像特徵提取功能。 In some embodiments, the image feature extraction apparatus 30 runs in an electronic device. The image feature extraction device 30 may include a plurality of functional modules composed of program code segments. The program codes of each program segment in the image feature extraction device 30 can be stored in the memory and executed by at least one processor to perform the image feature extraction function.

本實施例中,所述圖像特徵提取裝置30根據其所執行的功能,可以被劃分為多個功能模組。參閱圖2所示,所述圖像特徵提取裝置30可以包括圖像子塊獲取模組301,權重子塊獲取模組302,偏移量子塊獲取模組303及圖 像特徵計算模組304。本申請所稱的模組是指一種能夠被至少一個處理器所執行並且能夠完成固定功能的一系列電腦程式段,其存儲在記憶體中。所述在一些實施例中,關於各模組的功能將在後續的實施例中詳述。 In this embodiment, the image feature extraction apparatus 30 can be divided into a plurality of functional modules according to the functions performed by the image feature extraction apparatus 30 . Referring to FIG. 2, the image feature extraction device 30 may include an image sub-block acquisition module 301, a weight sub-block acquisition module 302, an offset sub-block acquisition module 303 and the Like feature calculation module 304 . A module referred to in this application refers to a series of computer program segments that can be executed by at least one processor and can perform fixed functions, and are stored in a memory. In some embodiments, the functions of each module will be described in detail in subsequent embodiments.

所述圖像子塊獲取模組301獲取圖像,將所述圖像轉換為圖像矩陣,劃分所述圖像矩陣得到圖像向量,劃分所述圖像向量得到第一數量的圖像子塊。 The image sub-block acquisition module 301 acquires an image, converts the image into an image matrix, divides the image matrix to obtain an image vector, and divides the image vector to obtain a first number of image sub-blocks. piece.

在本申請的至少一個實施例中,所述圖像子塊獲取模組301將所述圖像轉換為圖像矩陣包括:讀取所述圖像;獲取所述圖像中的圖元點;將所述圖元點的三原色編碼值組成圖元向量,及將所述圖元向量組成所述圖像矩陣。 In at least one embodiment of the present application, converting the image into an image matrix by the image sub-block acquiring module 301 includes: reading the image; acquiring primitive points in the image; The three primary color-coded values of the primitive points are composed of primitive vectors, and the primitive vectors are composed of the image matrix.

在本申請的至少一個實施例中,所述圖像子塊獲取模組301劃分所述圖像矩陣得到圖像向量包括:將所述圖像矩陣按照所述預設行數進行劃分得到預備圖像向量集,所述預備圖像向量集包括至少一個預備圖像向量;判斷所述預備圖像向量集中是否存在行數小於所述預設行數的預備圖像向量;當所述預備圖像向量中存在行數小於所述預設行數的圖像向量時,使用所述預設數值填充所述行數小於所述預設行數的預備圖像向量得到行數等於所述預設行數的預備圖像向量,將所述預備圖像向量作為所述圖像向量;或當所述預備圖像向量中不存在行數小於所述預設行數的圖像向量時,將所述預備圖像向量作為所述圖像向量。 In at least one embodiment of the present application, dividing the image matrix by the image sub-block obtaining module 301 to obtain an image vector includes: dividing the image matrix according to the preset number of rows to obtain a preliminary image Like a vector set, the preparatory image vector set includes at least one preparatory image vector; it is judged whether there is a preparatory image vector with a row number less than the preset row number in the preparatory image vector set; when the preparatory image vector set is When there is an image vector with the number of rows less than the preset number of rows in the vector, use the preset value to fill the preliminary image vector with the number of rows less than the preset number of rows to obtain a row number equal to the preset number of rows. number of preliminary image vectors, take the preliminary image vector as the image vector; or when there is no image vector with a row number less than the preset number of rows in the preliminary image vector, use the preliminary image vector as the image vector An image vector is prepared as the image vector.

在本申請的至少一個實施例中,所述圖像子塊獲取模組301劃分所述圖像向量得到第一數量的圖像子塊包括:將所述圖像向量按照所述預設列數進行劃分得到第一數量的預備圖像子塊;判斷所述預備圖像子塊中是否存在列數小於所述預設列數的預備圖像子塊;當所述預備圖像子塊中存在列數小於所述預設列數的預備圖像子塊時,使用預設數值填充列數小於所述預設列數預備圖像子塊得到列數等於所述預設列數的預備圖像子塊,將第一數量的預備圖像子塊作為所述第一數量的圖像子塊;或當所述預備圖像子塊中不存在列數小於所述預設列數的預備圖像子塊時,將所述第一數量的預備圖像子塊作為所述第一數量的圖像子塊。 In at least one embodiment of the present application, the image sub-block obtaining module 301 dividing the image vector to obtain the first number of image sub-blocks includes: dividing the image vector according to the preset number of columns Dividing to obtain a first number of preliminary image sub-blocks; judging whether there is a preliminary image sub-block whose number of columns is less than the predetermined number of columns in the preliminary image sub-block; when there is a preliminary image sub-block in the preliminary image sub-block When the number of columns is less than the preset number of columns of the preparatory image sub-block, use a preset value to fill the pre-image sub-block with the number of columns less than the preset number of columns to obtain a preparatory image with the number of columns equal to the preset number of columns sub-blocks, taking the first number of preliminary image sub-blocks as the first number of image sub-blocks; or when there is no preliminary image with a number of columns less than the preset number of columns in the preliminary image sub-blocks In the case of sub-blocks, the first number of preparatory image sub-blocks is used as the first number of image sub-blocks.

所述權重子塊獲取模組302獲取權重矩陣,劃分所述權重矩陣得到第二數量的權重向量,劃分每個所述權重向量得到第一數量的權重子塊。 The weight sub-block obtaining module 302 obtains a weight matrix, divides the weight matrix to obtain a second number of weight vectors, and divides each of the weight vectors to obtain a first number of weight sub-blocks.

在本申請的至少一個實施例中,所述權重子塊獲取模組302劃分所述權重矩陣得到第二數量的權重向量包括:將所述權重矩陣按照所述列數進行劃分得到第二數量的預備權重向量;判斷所述預備權重向量中是否存在列數小於所述預設列數的預備權重向量;當所述預備權重向量中存在列數小於所述預設列數的權重向量時,使用所述預設數值填充所述列數小於所述預設列數的預備權重向量得到列數等於所述預設列數的預備權重向量,將第二數量的預備權重向量作為第二數量的所述權重向量;或當所述預備權重向量中不存在列數小於所述預設列數的權重向量時,將第二數量的預備權重向量作為第二數量的所述權重向量。 In at least one embodiment of the present application, dividing the weight matrix by the weight sub-block obtaining module 302 to obtain the second quantity of weight vectors includes: dividing the weight matrix according to the number of columns to obtain the second quantity of weight vectors. Preparing weight vector; judging whether there is a preparatory weight vector with the number of columns less than the preset number of columns in the preparatory weight vector; when there is a weight vector in the preparatory weight vector whose number of columns is less than the preset number of columns, use The preset value fills the preliminary weight vector with the number of columns less than the preset number of columns to obtain a preliminary weight vector with the number of columns equal to the preset number of columns, and the second number of preliminary weight vectors is used as the second number of all preliminary weight vectors. or when there is no weight vector whose number of columns is less than the preset number of columns in the prepared weight vector, the second number of prepared weight vectors is used as the second number of the weight vectors.

在本申請的至少一個實施例中,所述權重子塊獲取模組302劃分每個所述權重向量得到第一數量的權重子塊包括:將每個所述權重向量按照所述行數進行劃分得到第四數量的預備權重子塊;判斷所述第四數量是否等於所述第一數量,當所述第四數量小於所述第一數量時,計算所述第四數量與所述第一數量的第一差值,並根據所述第一差值增加預備權重子塊的數量直至得到第一數量的預備權重子塊;或當所述第四數量大於所述第一數量時,從第四數量的預備權重子塊中選擇第一數量的預備權重子塊;判斷所述第一數量的預備權重子塊中是否存在列數小於所述預設列數的預備權重子塊;當所述第一數量的預備權重子塊中存在列數小於所述預設列數的預備權重子塊時,使用預設數值填充列數小於所述預設列數預備權重子塊得到列數等於所述預設列數的預備權重子塊,將第一數量的預備權重子塊作為第一數量的權重子塊;或當所述第一數量的預備權重子塊中不存在列數小於所述預設列數的預備權重子塊時,將所述第一數量的預備權重子塊作為所述第一數量的權重子塊。 In at least one embodiment of the present application, the step of dividing each of the weight vectors by the weight sub-block obtaining module 302 to obtain the first number of weight sub-blocks includes: dividing each of the weight vectors according to the number of rows Obtain a fourth quantity of preparatory weight sub-blocks; determine whether the fourth quantity is equal to the first quantity, and when the fourth quantity is less than the first quantity, calculate the fourth quantity and the first quantity and increase the number of preparatory weight sub-blocks according to the first difference until the first number of preparatory weight sub-blocks are obtained; or when the fourth number is greater than the first number, from the fourth Selecting a first number of pre-weight sub-blocks from the number of pre-weight sub-blocks; judging whether there is a pre-weight sub-block with a number of columns less than the preset number of columns in the first number of pre-weight sub-blocks; when the first number of pre-weight sub-blocks is When there are pre-weight sub-blocks with a number of columns smaller than the preset number of columns in a number of pre-weight sub-blocks, use a preset value to fill the pre-weight sub-blocks with a number of columns smaller than the pre-set number of columns to obtain a number of columns equal to the pre-set number of columns. Set the number of columns of pre-weight sub-blocks, and use the first number of pre-weight sub-blocks as the first number of pre-weight sub-blocks; or when there is no column number smaller than the preset column in the first number of pre-weight sub-blocks When the number of preparatory weight sub-blocks is selected, the first number of preparatory weight sub-blocks is used as the first number of weight sub-blocks.

在本申請的至少一個實施例中,所述權重矩陣用於度量圖像矩陣中特徵的重要程度。 In at least one embodiment of the present application, the weight matrix is used to measure the importance of features in the image matrix.

在本申請的至少一個實施例中,所述權重矩陣可以是自編碼器的編碼層中的一個矩陣,也可以是卷積神經網路的卷積層中的一個矩陣,所述權重矩陣可以存儲在人工智慧晶片中,用於進行通用矩陣乘法運算。 In at least one embodiment of the present application, the weight matrix may be a matrix in an encoding layer of an autoencoder or a matrix in a convolutional layer of a convolutional neural network, and the weight matrix may be stored in In artificial intelligence chips, it is used to perform general matrix multiplication operations.

所述偏移量子塊獲取模組303獲取偏移量矩陣,劃分所述偏移量矩陣得到第二數量的偏移量子塊。 The offset quantum block obtaining module 303 obtains an offset matrix, and divides the offset matrix to obtain a second number of offset quantum blocks.

在本申請的至少一個實施例中,所述偏移量子塊獲取模組303劃分所述偏移量矩陣得到第二數量的偏移量子塊包括:將所述偏移量矩陣按照所述預設行數進行劃分得到預備偏移量向量,從所述預備偏移量向量中選擇一個偏移量向量;將所述偏移量向量按照所述預設列數進行劃分得到第五數量的預備偏移量子塊;判斷所述第五數量是否等於所述第二數量,當所述第五數量小於所述第二數量時,計算所述第五數量與所述第二數量的第二差值,並根據所述第二差值增加預備偏移量子塊的數量直至得到第二數量的預備偏移量子塊;或當所述第五數量大於所述第二數量時,從所述第五數量的預備偏移量子塊中選擇第二數量的預備偏移量子塊;判斷所述第二數量的預備偏移量子塊中是否存在列數小於所述預設列數或行數小於預設行數的預備偏移量子塊;當所述第二數量的預備偏移量子塊中存在列數小於所述預設列數或行數小於預設行數的預備偏移量子塊時,使用預設數值填充列數小於所述預設列數或行數小於預設行數的預備偏移量子塊得到列數等於所述預設列數且行數等於預設行數的預備偏移量子塊,將第二數量的預備偏移量子塊作為所述第二數量的偏移量子塊;或當所述第二數量的預備偏移量子塊中不存在列數小於所述預設列數或行數小於預設行數的預備偏移量子塊時,將第二數量的所述預備偏移量子塊作為所述第二數量的偏移量子塊。 In at least one embodiment of the present application, the offset sub-block obtaining module 303 dividing the offset matrix to obtain the second number of offset sub-blocks includes: obtaining the offset matrix according to the preset The number of rows is divided to obtain a preliminary offset vector, and an offset vector is selected from the preliminary offset vector; the offset vector is divided according to the preset number of columns to obtain a fifth number of preliminary offsets. Shifting sub-blocks; judging whether the fifth quantity is equal to the second quantity, when the fifth quantity is less than the second quantity, calculate the second difference between the fifth quantity and the second quantity, and increase the number of preparatory offset quantum blocks according to the second difference until a second number of preparatory offset quantum blocks are obtained; or when the fifth number is greater than the second number, from the fifth number of Selecting a second quantity of preparatory offset quantum blocks from the preparatory offset quantum blocks; judging whether there is a second quantity of preparatory offset quantum blocks in which the number of columns is less than the preset number of columns or the number of rows is less than the preset number of rows Preparing offset quantum blocks; when there are preparatory offset quantum blocks with columns smaller than the preset number of columns or rows smaller than the preset number of rows in the second number of preliminary offset quantum blocks, use a preset value to fill The number of columns is less than the preset number of columns or the number of rows is less than the number of pre-set offset sub-blocks to obtain the number of columns is equal to the number of pre-set columns and the number of rows is equal to the number of pre-set offset sub-blocks, the second The number of preliminary offset quantum blocks is used as the second number of offset quantum blocks; or when there is no column number less than the preset number of columns or the number of rows less than the preset number of columns in the second number of preliminary offset quantum blocks When the number of rows of preliminary offset quantum blocks is used, the second number of the preliminary offset quantum blocks is used as the second number of offset quantum blocks.

在本申請的至少一個實施例中,所述偏移量矩陣用於度量神經網路產生正激勵或負激勵的難易程度。 In at least one embodiment of the present application, the offset matrix is used to measure the difficulty of generating positive excitation or negative excitation by the neural network.

在本申請的至少一個實施例中,所述偏移量矩陣可以是自編碼器的編碼層中的一個矩陣,也可以是卷積神經網路的卷積層中的一個矩陣,所述偏移量矩陣可以存儲在人工智慧晶片中,用於進行通用矩陣乘法運算。 In at least one embodiment of the present application, the offset matrix may be a matrix in an encoding layer of an autoencoder, or may be a matrix in a convolutional layer of a convolutional neural network, and the offset Matrices can be stored in AI chips for general-purpose matrix multiplication.

圖像特徵計算模組304對第一數量的圖像子塊與每個所述權重向量的第一數量的權重子塊進行向量乘法得到第二數量的特徵子塊,將所述第二數量的特徵子塊與所述第二數量的偏移量子塊相加得到圖像特徵子塊,所述圖像特徵子塊組成圖像特徵。 The image feature calculation module 304 performs vector multiplication on the first number of image sub-blocks and the first number of weight sub-blocks of each of the weight vectors to obtain a second number of feature sub-blocks, and the second number of The feature sub-blocks are added with the second number of offset sub-blocks to obtain image feature sub-blocks, and the image feature sub-blocks constitute image features.

在本申請的至少一個實施例中,在本申請的至少一個實施例中,所述圖像子塊、所述權重子塊、所述偏移量子塊中的每個都具有預設行數與預設列數,所述預設列數與所述預設行數相同。 In at least one embodiment of the present application, in at least one embodiment of the present application, each of the image sub-block, the weight sub-block, and the offset sub-block has a preset number of rows equal to The preset number of columns, the preset number of columns is the same as the preset number of rows.

本實施方式中,藉由將圖像矩陣、權重矩陣和偏差矩陣劃分為子塊進行運算,減少了圖像特徵提取過程中神經網路中卷積運算的運算量,從而提高了對圖像中特徵進行提取的效率。 In this embodiment, by dividing the image matrix, the weight matrix and the deviation matrix into sub-blocks for operation, the calculation amount of the convolution operation in the neural network in the process of image feature extraction is reduced, thereby improving the accuracy of the image in the image. The efficiency of feature extraction.

實施例3 Example 3

圖3為本申請一實施方式中電子設備6的示意圖。 FIG. 3 is a schematic diagram of an electronic device 6 in an embodiment of the present application.

所述電子設備6包括記憶體61、處理器62以及存儲在所述記憶體61中並可在所述處理器62上運行的電腦程式63。所述處理器62執行所述電腦程式63時實現上述圖像特徵提取方法實施例中的步驟,例如圖1所示的步驟S11~S14。或者,所述處理器62執行所述電腦程式63時實現上述圖像特徵提取裝置實施例中各模組/單元的功能,例如圖2中的模組301~304。 The electronic device 6 includes a memory 61 , a processor 62 and a computer program 63 stored in the memory 61 and executable on the processor 62 . When the processor 62 executes the computer program 63 , the steps in the above-mentioned embodiment of the image feature extraction method are implemented, such as steps S11 to S14 shown in FIG. 1 . Alternatively, when the processor 62 executes the computer program 63 , the functions of each module/unit in the above-mentioned embodiment of the image feature extraction apparatus, such as modules 301 to 304 in FIG. 2 , are realized.

示例性的,所述電腦程式63可以被分割成一個或多個模組/單元,所述一個或者多個模組/單元被存儲在所述記憶體61中,並由所述處理器62執行,以完成本申請。所述一個或多個模組/單元可以是能夠完成特定功能的一系列電腦程式指令段,所述指令段用於描述所述電腦程式63在所述電子設備6中 的執行過程。例如,所述電腦程式63可以被分割成圖2中的圖像子塊獲取模組301,權重子塊獲取模組302,偏移量子塊獲取模組303及圖像特徵計算模組304,各模組具體功能參見實施例2。 Exemplarily, the computer program 63 can be divided into one or more modules/units, and the one or more modules/units are stored in the memory 61 and executed by the processor 62 , to complete this application. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, and the instruction segments are used to describe the computer program 63 in the electronic device 6 execution process. For example, the computer program 63 can be divided into an image sub-block acquisition module 301, a weight sub-block acquisition module 302, an offset sub-block acquisition module 303 and an image feature calculation module 304 in FIG. For the specific functions of the module, see Embodiment 2.

本實施方式中,所述電子設備6可以是桌上型電腦、筆記本、掌上型電腦、伺服器及雲端終端裝置等計算設備。本領域技術人員可以理解,所述示意圖僅僅是電子設備6的示例,並不構成對電子設備6的限定,可以包括比圖示更多或更少的部件,或者組合某些部件,或者不同的部件,例如所述電子設備6還可以包括輸入輸出設備、網路接入設備、匯流排等。 In this embodiment, the electronic device 6 may be a computing device such as a desktop computer, a notebook, a palmtop computer, a server, and a cloud terminal device. Those skilled in the art can understand that the schematic diagram is only an example of the electronic device 6, and does not constitute a limitation to the electronic device 6, and may include more or less components than the one shown, or combine some components, or different Components such as the electronic device 6 may also include input and output devices, network access devices, bus bars, and the like.

所稱處理器62可以是中央處理模組(Central Processing Unit,CPU),還可以是其他通用處理器、數位訊號處理器(Digital Signal Processor,DSP)、專用積體電路(Application Specific Integrated Circuit,ASIC)、現場可程式設計閘陣列(Field-Programmable Gate Array,FPGA)或者其他可程式設計邏輯器件、分立門或者電晶體邏輯器件、分立硬體元件等。通用處理器可以是微處理器或者所述處理器62也可以是任何常規的處理器等,所述處理器62是所述電子設備6的控制中心,利用各種介面和線路連接整個電子設備6的各個部分。 The processor 62 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs) ), Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor 62 can also be any conventional processor, etc. The processor 62 is the control center of the electronic device 6, and uses various interfaces and lines to connect the entire electronic device 6. various parts.

所述記憶體61可用於存儲所述電腦程式63和/或模組/單元,所述處理器62藉由運行或執行存儲在所述記憶體61內的電腦程式和/或模組/單元,以及調用存儲在記憶體61內的資料,實現所述電子設備6的各種功能。所述記憶體61可主要包括存儲程式區和存儲資料區,其中,存儲程式區可存儲作業系統、至少一個功能所需的應用程式(比如聲音播放功能、圖像播放功能等)等;存儲資料區可存儲根據電子設備6的使用所創建的資料(比如音訊資料、電話本等)等。此外,記憶體61可以包括高速隨機存取記憶體,還可以包括非易失性記憶體,例如硬碟、記憶體、插接式硬碟,智慧存儲卡(Smart Media Card,SMC), 安全數位(Secure Digital,SD)卡,快閃記憶體卡(Flash Card)、至少一個磁碟記憶體件、快閃記憶體器件、或其他易失性固態記憶體件。 The memory 61 can be used to store the computer programs 63 and/or modules/units, and the processor 62 runs or executes the computer programs and/or modules/units stored in the memory 61, And call the data stored in the memory 61 to realize various functions of the electronic device 6 . The memory 61 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; storage data The area may store data (such as audio data, phone book, etc.) created according to the use of the electronic device 6, and the like. In addition, the memory 61 may include a high-speed random access memory, and may also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a Smart Media Card (SMC), Secure Digital (SD) card, flash memory card (Flash Card), at least one disk memory device, flash memory device, or other volatile solid state memory device.

所述電子設備6集成的模組/單元如果以軟體功能模組的形式實現並作為獨立的產品銷售或使用時,可以存儲在一個電腦可讀取存儲介質中。基於這樣的理解,本申請實現上述實施例方法中的全部或部分流程,也可以藉由電腦程式來指令相關的硬體來完成,所述的電腦程式可存儲於一電腦可讀存儲介質中,所述電腦程式在被處理器執行時,可實現上述各個方法實施例的步驟。其中,所述電腦程式包括電腦程式代碼,所述電腦程式代碼可以為原始程式碼形式、物件代碼形式、可執行檔或某些中間形式等。所述電腦可讀介質可以包括:能夠攜帶所述電腦程式代碼的任何實體或裝置、記錄介質、隨身碟、移動硬碟、磁碟、光碟、電腦記憶體、唯讀記憶體(ROM,Read-Only Memory)、隨機存取記憶體(RAM,Random Access Memory)、電載波信號、電信信號以及軟體分發介質等。 If the modules/units integrated in the electronic device 6 are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the present application realizes all or part of the processes in the methods of the above embodiments, and can also be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, When the computer program is executed by the processor, the steps of the above method embodiments can be implemented. Wherein, the computer program includes computer program code, and the computer program code may be in the form of original code, object code, executable file, or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a flash drive, a removable hard disk, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM, Read-Only Memory); Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium, etc.

在本申請所提供的幾個實施例中,應該理解到,所揭露的裝置和方法,可以藉由其它的方式實現。例如,以上所描述的裝置實施例僅僅是示意性的,例如,所述模組的劃分,僅僅為一種邏輯功能劃分,實際實現時可以有另外的劃分方式。 In the several embodiments provided in this application, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the device embodiments described above are only illustrative. For example, the division of the modules is only a logical function division, and other division methods may be used in actual implementation.

另外,在本申請各個實施例中的各功能模組可以集成在相同處理模組中,也可以是各個模組單獨物理存在,也可以兩個或兩個以上模組集成在相同模組中。上述集成的模組既可以採用硬體的形式實現,也可以採用硬體加軟體功能模組的形式實現。 In addition, each functional module in each embodiment of the present application may be integrated in the same processing module, or each module may exist physically alone, or two or more modules may be integrated in the same module. The above-mentioned integrated modules can be implemented in the form of hardware, or can be implemented in the form of hardware plus software function modules.

對於本領域技術人員而言,顯然本發明不限於上述示範性實施例的細節,而且在不背離本發明的精神或基本特徵的情況下,能夠以其他的具體形式實現本發明。因此,無論從哪一點來看,均應將實施例看作是示範性的, 而且是非限制性的,本發明的範圍由所附請求項而不是上述說明限定,因此旨在將落在申請專利範圍的等同要件的含義和範圍內的所有變化涵括在本發明內。不應將申請專利範圍中的任何附圖標記視為限制所涉及的申請專利範圍。此外,顯然“包括”一詞不排除其他模組或步驟,單數不排除複數。電子設備申請專利範圍中陳述的多個模組或電子設備也可以由同一個模組或電子設備藉由軟體或者硬體來實現。第一,第二等詞語用來表示名稱,而並不表示任何特定的順序。 It will be apparent to those skilled in the art that the present invention is not limited to the details of the above-described exemplary embodiments, but that the present invention may be embodied in other specific forms without departing from the spirit or essential characteristics of the invention. Therefore, the embodiments should be regarded as exemplary in all respects, And, without limitation, the scope of the invention is defined by the appended claims rather than the foregoing description, and therefore all changes that come within the meaning and range of equivalents to the claimed scope are intended to be embraced therein. Any reference signs in the patentable scope should not be construed as limiting the claimed scope. Furthermore, it is clear that the word "comprising" does not exclude other modules or steps, and the singular does not exclude the plural. Multiple modules or electronic devices stated in the scope of the electronic device patent application can also be implemented by the same module or electronic device through software or hardware. The terms first, second, etc. are used to denote names and do not denote any particular order.

綜上所述,本發明符合發明專利要件,爰依法提出專利申請。惟,以上所述僅為本發明之較佳實施方式,舉凡熟悉本案技藝之人士,在援依本案創作精神所作之等效修飾或變化,皆應包含於以下之申請專利範圍內。 To sum up, the present invention complies with the requirements of an invention patent, and a patent application can be filed in accordance with the law. However, the above descriptions are only the preferred embodiments of the present invention, and for those who are familiar with the techniques of this case, equivalent modifications or changes made in accordance with the creative spirit of this case shall be included in the scope of the following patent application.

S11~S14:步驟 S11~S14: Steps

Claims (8)

一種圖像特徵提取方法,應用於電子設備,其中,所述方法包括:獲取圖像,將所述圖像轉換為圖像矩陣,劃分所述圖像矩陣得到圖像向量,劃分所述圖像向量得到第一數量的圖像子塊;獲取權重矩陣,劃分所述權重矩陣得到第二數量的權重向量,劃分每個所述權重向量得到第一數量的權重子塊,其中,所述權重矩陣為自編碼器的編碼層中的一個矩陣,或為卷積神經網路的卷積層中的一個矩陣,所述權重矩陣用於度量圖像矩陣中特徵的重要程度;獲取偏移量矩陣,劃分所述偏移量矩陣得到第二數量的偏移量子塊,包括:將所述權重矩陣按照所述列數進行劃分得到第二數量的預備權重向量;判斷所述預備權重向量中是否存在列數小於所述預設列數的預備權重向量;當所述預備權重向量中存在列數小於所述預設列數的權重向量時,使用所述預設數值填充所述列數小於所述預設列數的預備權重向量得到列數等於所述預設列數的預備權重向量,將第二數量的預備權重向量作為第二數量的所述權重向量;或當所述預備權重向量中不存在列數小於所述預設列數的權重向量時,將第二數量的預備權重向量作為第二數量的所述權重向量,其中,所述偏移量矩陣為自編碼器的編碼層中的一個矩陣,或為卷積神經網路的卷積層中的一個矩陣,所述偏移量矩陣用於度量卷積神經網路或自編碼器產生正激勵或負激勵的難易程度;對第一數量的圖像子塊與每個所述權重向量的第一數量的權重子塊進行向量乘法得到第二數量的特徵子塊,將所述第二數量的特徵子塊與所述第二數量的偏移量子塊相加得到圖像特徵子塊,所述圖像特徵子塊組成圖像特徵,其中, 所述圖像子塊、所述權重子塊、所述偏移量子塊中的每個都具有預設行數與預設列數,所述預設列數與所述預設行數相同。 An image feature extraction method, applied to electronic equipment, wherein the method comprises: acquiring an image, converting the image into an image matrix, dividing the image matrix to obtain an image vector, dividing the image vector to obtain a first number of image sub-blocks; obtain a weight matrix, divide the weight matrix to obtain a second number of weight vectors, divide each of the weight vectors to obtain a first number of weight sub-blocks, wherein the weight matrix is a matrix in the coding layer of the self-encoder, or a matrix in the convolutional layer of the convolutional neural network, the weight matrix is used to measure the importance of the features in the image matrix; obtain the offset matrix, divide Obtaining a second number of offset sub-blocks from the offset matrix includes: dividing the weight matrix according to the number of columns to obtain a second number of preparatory weight vectors; judging whether there is a number of columns in the preparatory weight vector A prepared weight vector less than the preset number of columns; when there is a weight vector with a number of columns less than the preset number of columns in the prepared weight vector, use the preset value to fill the number of columns less than the preset number of columns. The preparatory weight vector of the number of columns obtains a preparatory weight vector with the number of columns equal to the preset number of columns, and the preparatory weight vector of the second quantity is used as the weight vector of the second quantity; or when there is no column in the preparatory weight vector When the number of weight vectors is less than the preset number of columns, the second number of preparatory weight vectors is used as the second number of weight vectors, wherein the offset matrix is a matrix in the coding layer of the self-encoder , or a matrix in the convolutional layer of the convolutional neural network, the offset matrix is used to measure the difficulty of the convolutional neural network or the autoencoder to generate positive or negative excitation; for the first number of graphs The image sub-blocks perform vector multiplication with the first number of weight sub-blocks of each of the weight vectors to obtain a second number of feature sub-blocks, and the second number of feature sub-blocks is combined with the second number of offset sub-blocks. The blocks are added to obtain image feature sub-blocks, and the image feature sub-blocks form image features, wherein, Each of the image sub-block, the weight sub-block, and the offset sub-block has a preset number of rows and a preset number of columns, and the preset number of columns is the same as the preset number of rows. 如請求項1所述的圖像特徵提取方法,其中,所述劃分所述圖像矩陣得到圖像向量包括:將所述圖像矩陣按照所述預設行數進行劃分得到預備圖像向量集,所述預備圖像向量集包括至少一個預備圖像向量;判斷所述預備圖像向量集中是否存在行數小於所述預設行數的預備圖像向量;當所述預備圖像向量中存在行數小於所述預設行數的圖像向量時,使用所述預設數值填充所述行數小於所述預設行數的預備圖像向量得到行數等於所述預設行數的預備圖像向量,將所述預備圖像向量作為所述圖像向量;或當所述預備圖像向量中不存在行數小於所述預設行數的圖像向量時,將所述預備圖像向量作為所述圖像向量。 The image feature extraction method according to claim 1, wherein the dividing the image matrix to obtain the image vector comprises: dividing the image matrix according to the preset number of rows to obtain a set of preliminary image vectors , the preliminary image vector set includes at least one preliminary image vector; determine whether there is a preliminary image vector with a row number less than the preset number of rows in the preliminary image vector set; when there is a preliminary image vector in the preliminary image vector When the image vector with the number of lines is less than the preset number of lines, use the preset value to fill the preliminary image vector with the number of lines less than the preset number of lines to obtain a preliminary image vector with the number of lines equal to the preset number of lines an image vector, using the preliminary image vector as the image vector; or when there is no image vector with a row number less than the preset number of rows in the preliminary image vector, the preliminary image vector vector as the image vector. 如請求項1所述的圖像特徵提取方法,其中,劃分所述圖像向量得到第一數量的圖像子塊包括:將所述圖像向量按照所述預設列數進行劃分得到第一數量的預備圖像子塊;判斷所述預備圖像子塊中是否存在列數小於所述預設列數的預備圖像子塊;當所述預備圖像子塊中存在列數小於所述預設列數的預備圖像子塊時,使用預設數值填充列數小於所述預設列數預備圖像子塊得到列數等於所述預設列數的預備圖像子塊,將第一數量的預備圖像子塊作為所述第一數量的圖像子塊;或當所述預備圖像子塊中不存在列數小於所述預設列數的預備圖像子塊時,將所述第一數量的預備圖像子塊作為所述第一數量的圖像子塊。 The image feature extraction method according to claim 1, wherein dividing the image vector to obtain the first number of image sub-blocks comprises: dividing the image vector according to the preset number of columns to obtain the first number of sub-blocks. number of preliminary image sub-blocks; determine whether there are preliminary image sub-blocks with a number of columns less than the preset number of columns in the preliminary image sub-blocks; when the number of columns in the preliminary image sub-block is less than the When there are pre-set image sub-blocks with a preset number of columns, use a preset value to fill the pre-image sub-blocks with a number of columns less than the preset number of columns to obtain pre-image sub-blocks with a number of columns equal to the preset number of columns, A number of preparatory image sub-blocks are used as the first number of image sub-blocks; or when there is no preparatory image sub-block with a column number smaller than the preset number of columns in the preparatory image sub-block, use The first number of preliminary image sub-blocks are used as the first number of image sub-blocks. 如請求項1所述的圖像特徵提取方法,其中,劃分每個所述權重向量得到第一數量的權重子塊包括:將每個所述權重向量按照所述行數進行劃分得到第四數量的預備權重子塊;判斷所述第四數量是否等於所述第一數量,當所述第四數量小於所述第一數量時,計算所述第四數量與所述第一數量的第一差值,並根據所述第一差值增加預備權重子塊的數量直至得到第一數量的預備權重子塊;或當所述第四數量大於所述第一數量時,從第四數量的預備權重子塊中選擇第一數量的預備權重子塊;判斷所述第一數量的預備權重子塊中是否存在列數小於所述預設列數的預備權重子塊;當所述第一數量的預備權重子塊中存在列數小於所述預設列數的預備權重子塊時,使用預設數值填充列數小於所述預設列數預備權重子塊得到列數等於所述預設列數的預備權重子塊,將第一數量的預備權重子塊作為第一數量的權重子塊;或當所述第一數量的預備權重子塊中不存在列數小於所述預設列數的預備權重子塊時,將所述第一數量的預備權重子塊作為所述第一數量的權重子塊。 The image feature extraction method according to claim 1, wherein dividing each of the weight vectors to obtain a first number of weight sub-blocks comprises: dividing each of the weight vectors according to the number of rows to obtain a fourth number of sub-blocks The preparatory weight sub-block of the value, and increase the number of preparatory weight sub-blocks according to the first difference value until the first number of preparatory weight sub-blocks are obtained; or when the fourth number is greater than the first number, from the fourth number of preparatory weights Selecting a first number of pre-weight sub-blocks in the sub-blocks; judging whether there are pre-weight sub-blocks with a number of columns less than the preset number of columns in the first number of pre-weight sub-blocks; when the first number of pre-weight sub-blocks exist When there are pre-weight sub-blocks with a number of columns less than the preset number of columns in the weight sub-block, use a preset value to fill the pre-weight sub-block with a number of columns less than the preset number of columns to obtain a pre-weight sub-block with a number of columns equal to the preset number of columns. Preparing weight sub-blocks, using the first number of pre-weight sub-blocks as the first number of weight sub-blocks; or when there is no pre-weight with a column number smaller than the preset number of columns in the first number of pre-weight sub-blocks In the case of sub-blocks, the first number of preparatory weight sub-blocks is used as the first number of weight sub-blocks. 如請求項1所述的圖像特徵提取方法,其中,所述劃分所述偏移量矩陣得到第二數量的偏移量子塊包括:將所述偏移量矩陣按照所述預設行數進行劃分得到預備偏移量向量,從所述預備偏移量向量中選擇一個偏移量向量;將所述偏移量向量按照所述預設列數進行劃分得到第五數量的預備偏移量子塊; 判斷所述第五數量是否等於所述第二數量,當所述第五數量小於所述第二數量時,計算所述第五數量與所述第二數量的第二差值,並根據所述第二差值增加預備偏移量子塊的數量直至得到第二數量的預備偏移量子塊;或當所述第五數量大於所述第二數量時,從所述第五數量的預備偏移量子塊中選擇第二數量的預備偏移量子塊;判斷所述第二數量的預備偏移量子塊中是否存在列數小於所述預設列數或行數小於預設行數的預備偏移量子塊;當所述第二數量的預備偏移量子塊中存在列數小於所述預設列數或行數小於預設行數的預備偏移量子塊時,使用預設數值填充列數小於所述預設列數或行數小於預設行數的預備偏移量子塊得到列數等於所述預設列數且行數等於預設行數的預備偏移量子塊,將第二數量的預備偏移量子塊作為所述第二數量的偏移量子塊;或當所述第二數量的預備偏移量子塊中不存在列數小於所述預設列數或行數小於預設行數的預備偏移量子塊時,將第二數量的所述預備偏移量子塊作為所述第二數量的偏移量子塊。 The image feature extraction method according to claim 1, wherein the dividing the offset matrix to obtain the second number of offset sub-blocks comprises: performing the offset matrix according to the preset number of rows. Divide to obtain a preliminary offset vector, and select an offset vector from the preliminary offset vector; divide the offset vector according to the preset number of columns to obtain a fifth number of preliminary offset quantum blocks ; Determine whether the fifth quantity is equal to the second quantity, when the fifth quantity is less than the second quantity, calculate the second difference between the fifth quantity and the second quantity, and calculate the second difference according to the The second difference increases the number of preparatory offset quantum blocks until a second number of preparatory offset quantum blocks is obtained; or when the fifth number is greater than the second number, from the fifth number of preparatory offset quantum blocks Select a second number of preliminary offset sub-blocks in the block; determine whether there is a preliminary offset sub-block with a number of columns smaller than the preset number of columns or a number of rows smaller than the preset number of rows in the second number of preliminary offset sub-blocks block; when there are preliminary offset sub-blocks with the number of columns less than the preset number of columns or the number of rows less than the preset number of rows in the second number of preliminary offset sub-blocks, use the preset value to fill in the number of columns less than the preset number of rows. The pre-offset quantum blocks with the preset number of columns or rows less than the preset number of rows obtain the pre-offset sub-blocks with the number of columns equal to the preset number of columns and the number of rows equal to the preset number of rows, and the second number of pre-offset quantum blocks are Shift sub-blocks as the second number of offset sub-blocks; or when there is no preparation with a column number smaller than the preset number of columns or a row number smaller than the preset number of rows in the second number of preliminary offset sub-blocks When offsetting the quantum blocks, the second quantity of the preparatory offset quantum blocks is used as the second quantity of offset quantum blocks. 一種圖像特徵提取裝置,其中,所述裝置包括:圖像子塊獲取模組,用於獲取圖像,將所述圖像轉換為圖像矩陣,劃分所述圖像矩陣得到圖像向量,劃分所述圖像向量得到第一數量的圖像子塊;權重子塊獲取模組,用於獲取權重矩陣,劃分所述權重矩陣得到第二數量的權重向量,劃分每個所述權重向量得到第一數量的權重子塊,其中,所述權重矩陣為自編碼器的編碼層中的一個矩陣,或為卷積神經網路的卷積層中的一個矩陣,所述權重矩陣用於度量圖像矩陣中特徵的重要程度;偏移量子塊獲取模組,用於獲取偏移量矩陣,劃分所述偏移量矩陣得到第二數量的偏移量子塊,包括:將所述權重矩陣按照所述列數進行劃分得到第二數量的預備權重向量;判斷所述預備權重向量中是否存在列數小於所述預設列 數的預備權重向量;當所述預備權重向量中存在列數小於所述預設列數的權重向量時,使用所述預設數值填充所述列數小於所述預設列數的預備權重向量得到列數等於所述預設列數的預備權重向量,將第二數量的預備權重向量作為第二數量的所述權重向量;或當所述預備權重向量中不存在列數小於所述預設列數的權重向量時,將第二數量的預備權重向量作為第二數量的所述權重向量,其中,所述偏移量矩陣為自編碼器的編碼層中的一個矩陣,或為卷積神經網路的卷積層中的一個矩陣,所述偏移量矩陣用於度量卷積神經網路或自編碼器產生正激勵或負激勵的難易程度;圖像特徵計算模組,用於對第一數量的圖像子塊與每個所述權重向量的第一數量的權重子塊進行向量乘法得到第二數量的特徵子塊,將所述第二數量的特徵子塊與所述第二數量的偏移量子塊相加得到圖像特徵子塊,所述圖像特徵子塊組成圖像特徵。 An image feature extraction device, wherein the device comprises: an image sub-block acquisition module for acquiring an image, converting the image into an image matrix, dividing the image matrix to obtain an image vector, Dividing the image vector to obtain a first number of image sub-blocks; a weight sub-block obtaining module is used to obtain a weight matrix, dividing the weight matrix to obtain a second number of weight vectors, and dividing each of the weight vectors to obtain a first number of weight sub-blocks, wherein the weight matrix is a matrix in an encoding layer of an autoencoder, or a matrix in a convolutional layer of a convolutional neural network, and the weight matrix is used to measure the image The importance of the features in the matrix; the offset quantum block obtaining module is used to obtain the offset matrix, and dividing the offset matrix to obtain a second number of offset quantum blocks, including: obtaining the weight matrix according to the Dividing the number of columns to obtain a second number of preliminary weight vectors; judging whether there is a number of columns in the preliminary weight vector that is smaller than the preset number of columns When there is a weight vector with a number of columns less than the preset number of columns in the preliminary weight vector, use the preset value to fill the preliminary weight vector with the number of columns less than the preset number of columns. Obtaining a preparatory weight vector with a number of columns equal to the preset number of columns, and using the second number of preparatory weight vectors as the second number of the weight vectors; or when there is no column number in the preparatory weight vector that is smaller than the preset number of columns When the number of columns is the weight vector, the second number of preparatory weight vectors is used as the second number of the weight vectors, wherein the offset matrix is a matrix in the coding layer of the self-encoder, or a convolutional neural network. A matrix in the convolutional layer of the network, the offset matrix is used to measure the difficulty of the convolutional neural network or the self-encoder to generate positive excitation or negative excitation; the image feature calculation module is used for the first The number of image sub-blocks and the first number of weight sub-blocks of each of the weight vectors are vector multiplied to obtain a second number of feature sub-blocks, and the second number of feature sub-blocks is combined with the second number of feature sub-blocks. The offset quantum blocks are added to obtain image feature sub-blocks, and the image feature sub-blocks constitute image features. 一種電子設備,其中,所述電子設備包括:記憶體,存儲至少一個指令;及處理器,執行所述記憶體中存儲的指令以實現如請求項1至5中任一項所述的圖像特徵提取方法。 An electronic device, wherein the electronic device comprises: a memory that stores at least one instruction; and a processor that executes the instructions stored in the memory to realize the image according to any one of claim 1 to 5 Feature extraction method. 一種存儲介質,其上存儲有電腦程式,其中:所述電腦程式被處理器執行時實現如請求項1至5中任一項所述的圖像特徵提取方法。 A storage medium having a computer program stored thereon, wherein: the computer program implements the image feature extraction method according to any one of claim 1 to 5 when the computer program is executed by a processor.
TW110107747A 2021-03-04 2021-03-04 Image feature extraction method and image feature extraction device, electronic device and storage media TWI769724B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW110107747A TWI769724B (en) 2021-03-04 2021-03-04 Image feature extraction method and image feature extraction device, electronic device and storage media

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW110107747A TWI769724B (en) 2021-03-04 2021-03-04 Image feature extraction method and image feature extraction device, electronic device and storage media

Publications (2)

Publication Number Publication Date
TWI769724B true TWI769724B (en) 2022-07-01
TW202236156A TW202236156A (en) 2022-09-16

Family

ID=83439423

Family Applications (1)

Application Number Title Priority Date Filing Date
TW110107747A TWI769724B (en) 2021-03-04 2021-03-04 Image feature extraction method and image feature extraction device, electronic device and storage media

Country Status (1)

Country Link
TW (1) TWI769724B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TW202032423A (en) * 2019-01-31 2020-09-01 大陸商北京市商湯科技開發有限公司 Method for image processing and apparatus thereof
CN111695560A (en) * 2020-05-12 2020-09-22 浙江省农业科学院 Method for actively positioning and focusing crop diseases and insect pests based on convolutional neural network
CN112132841A (en) * 2020-09-22 2020-12-25 上海交通大学 Medical image cutting method and device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TW202032423A (en) * 2019-01-31 2020-09-01 大陸商北京市商湯科技開發有限公司 Method for image processing and apparatus thereof
CN111695560A (en) * 2020-05-12 2020-09-22 浙江省农业科学院 Method for actively positioning and focusing crop diseases and insect pests based on convolutional neural network
CN112132841A (en) * 2020-09-22 2020-12-25 上海交通大学 Medical image cutting method and device

Also Published As

Publication number Publication date
TW202236156A (en) 2022-09-16

Similar Documents

Publication Publication Date Title
CN108701250B (en) Data fixed-point method and device
US20180121789A1 (en) Data processing method and apparatus
CN106855952B (en) Neural network-based computing method and device
JP2019503530A (en) Image alteration detection method, system, electronic apparatus, and storage medium
CN113449854A (en) Method and device for quantifying mixing precision of network model and computer storage medium
CN110209714A (en) Report form generation method, device, computer equipment and computer readable storage medium
CN111358430B (en) Training method and device for magnetic resonance imaging model
CN116567170A (en) Video super-resolution parallel scheduling method and device for cloud platform and cloud platform
US9143159B2 (en) DPD/BCD to BID converters
TWI769724B (en) Image feature extraction method and image feature extraction device, electronic device and storage media
WO2018082320A1 (en) Data stream join method and device
CN110378479B (en) Image input method and device based on deep learning and terminal equipment
CN115017877B (en) Storage method of layout file and local reconstruction method of sample database
WO2023071566A1 (en) Data processing method and apparatus, computer device, computer-readable storage medium, and computer program product
CN113505765B (en) Age prediction method and device based on user head portrait and electronic equipment
CN113610856B (en) Method and device for training image segmentation model and image segmentation
CN112612427B (en) Vehicle stop data processing method and device, storage medium and terminal
TWI761109B (en) Cell density grouping method, cell density grouping device, electronic device and storage media
CN114417998A (en) Data feature mapping method, device, equipment and storage medium
CN115034351A (en) Data processing method, convolutional neural network training method and device and FPGA
CN115035322A (en) Image feature extraction method and device, electronic equipment and storage medium
TWI748867B (en) Image defect dection method, image defect dection device, electronic device and storage media
TWI755212B (en) Method and related equipment for determinting input dimensions of model
TWI762193B (en) Image defect detection method, image defect detection device, electronic device and storage media
TWI755213B (en) Method and device for detecting defections, computer device and storage medium