Optical neural network training method and apparatus oriented to logical operations

By constructing a hybrid loss function of logical contrast and mean squared error, and combining it with an adaptive training strategy, the problem of incorrect logic in the training of optical neural networks is solved, and the accuracy of logical operations and the similarity of optical field modes are achieved.

WO2026237099A1PCT designated stage Publication Date: 2026-11-19TSINGHUA UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2025/096372
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2025-05-14
Filing Date
2025-05-21
Publication Date
2026-11-19

AI Technical Summary

Technical Problem

Existing mean square error methods cannot guarantee logical correctness in training optical neural networks for logical operations, leading to the occurrence of erroneous bits.

Method used

A hybrid loss function combining the logical contrast function and the mean square error loss function is constructed. An adaptive training strategy is used to train the optical neural network using the hybrid loss function until the preset convergence requirement is met. Then, the mean square error loss function is switched to optimize the light field distribution.

Benefits of technology

This method achieves accuracy in logical operations and similarity in optical field modes during optical neural network training, solving the problem of logical error bits in traditional methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025096372_19112026_PF_FP_ABST
    Figure CN2025096372_19112026_PF_FP_ABST
Patent Text Reader

Abstract

The present application relates to an optical neural network training method and apparatus oriented to logical operations. The method comprises: determining total optical field energy at each logical-operation output port, and a background light intensity, in order to construct a logical contrast function; on the basis of the logical contrast function, establishing a logical contrast loss function, and on the basis of the logical contrast loss function and a mean-square-error loss function, constructing a hybrid loss function; on the basis of an adaptive training strategy, using the hybrid loss function to train an optical neural network, and determining whether the hybrid loss function meets a preset convergence requirement during training; and if the hybrid loss function fails to meet the preset convergence requirement, continuing the use of the hybrid loss function to train the optical neural network; otherwise, using the mean-square-error loss function to train the optical neural network, in order to generate a target optical neural network meeting preset training requirements. Thus, the present application solves the problems of failure to ensure logical correctness, occurrence of erroneous bits, etc. that arise when existing mean-square-error-based methods are applied to logical operations.
Need to check novelty before this filing date? Find Prior Art

Description

Method and apparatus for training optical neural networks for logic operations Technical Field

[0001] This application relates to the field of optical neural network technology, and in particular to an optical neural network training method and apparatus for logic operations. Background Technology

[0002] Light possesses the fastest propagation speed in physical space and the advantages of being multidimensional and multi-scale. Optical computing, which uses photons to replace traditional electrons for information processing, holds the promise of building a new generation of high-performance computers. Compared with electronic chips, optical computing has disruptive advantages such as high speed, parallelism, and low power consumption. In particular, with the deep development of artificial intelligence algorithms, the physical process of light's limited propagation in a medium has a high degree of similarity in mathematical expression to deep neural network algorithms. Using optical neural networks to implement arithmetic and logical operations is expected to break through the energy efficiency bottleneck of traditional electronic chips.

[0003] Optical neural networks typically employ forward and backward propagation gradient updates for parameter training. The computational performance of diffraction neural networks largely depends on the training method and quality. The forward propagation of light can be represented as a cascade of transfer matrices and diffraction weights. The output light field of each data point in the entire dataset is calculated, and the network's output states are compared with the expected target values ​​to obtain the mean square error (MSE), which is one of the most commonly used loss functions in neural network training.

[0004] Mean squared error (MSE) is commonly used as the loss function in optical neural network training, and it achieves good training results in neural network training for intelligent tasks, especially image processing and recognition. The mathematical expression for the MSE-based loss function is as follows:

[0005] Among them, E i This represents the training prediction value of the model; This represents the current output of the model; m is the total number of pixels.

[0006] Based on the obtained loss function, the gradient that needs to be updated for each neuron in the neural network can be deduced, i.e., backward gradient update. Therefore, the loss function plays a crucial role in neural network training.

[0007] However, the output optical field of optical neural networks for logic operations may exhibit a multi-peak state due to non-ideal factors such as reflection and scattering. If the traditional MSE method is used, the target value will be set as an idealized Gaussian function, square wave function, or impulse function, making it difficult for the neural network training to find network parameters that are both logically correct and physically reasonable, which urgently needs to be addressed. Summary of the Invention

[0008] This application provides a training method and apparatus for optical neural networks oriented towards logical operations, in order to solve the problems of existing mean square error methods failing to guarantee logical correctness and resulting in erroneous bits when oriented towards logical operations.

[0009] The first aspect of this application provides a training method for an optical neural network oriented towards logical operations, comprising the following steps: determining the total energy of the light field and the background light intensity of each logical operation output port corresponding to a preset optical neural network, and constructing a logical contrast function based on the total energy of the light field and the background light intensity; establishing a corresponding logical contrast loss function based on the logical contrast loss function, and constructing a hybrid loss function corresponding to the optical neural network based on the logical contrast loss function and a preset mean square error loss function; training the optical neural network using the hybrid loss function based on a preset adaptive training strategy, and determining whether the hybrid loss function meets a preset convergence requirement during the training process; if the hybrid loss function does not meet the preset convergence requirement, continuing to train the optical neural network using the hybrid loss function; if the hybrid loss function meets the preset convergence requirement, training the optical neural network using the mean square error loss function to generate a target optical neural network that meets the preset training requirements.

[0010] Optionally, in one embodiment of this application, constructing the hybrid loss function corresponding to the optical neural network based on the logical contrast loss function and the preset mean square error loss function includes: determining the logical contrast weighting coefficient and the mean square error weighting coefficient corresponding to the logical contrast loss function and the mean square error loss function, respectively; and constructing the hybrid loss function based on the logical contrast weighting coefficient and the mean square error weighting coefficient, combined with the logical contrast loss function and the mean square error loss function.

[0011] Optionally, in one embodiment of this application, the mathematical expression of the logical contrast function is:

[0012] Among them, E i E represents the total energy of the optical field at the output port of the i-th logic operation; back This indicates the background light intensity.

[0013] Optionally, in one embodiment of this application, the mathematical expression of the logical contrast loss function is:

[0014] Among them, LC i T represents the logical contrast function; i This represents the target output logic value of the i-th port, where i is a positive integer.

[0015] Optionally, in one embodiment of this application, the mathematical expression of the hybrid loss function is: e combined =f MSE ·e MSE +f LC ·e LC

[0016] Among them, f MSE e represents the mean square error weighting coefficient; MSE f represents the mean squared error loss function; LC e represents the logical contrast weighting coefficient; LC This represents the logical contrast loss function.

[0017] A second aspect of this application provides a training device for an optical neural network oriented towards logical operations, comprising: a logical contrast module, configured to determine the total light field energy and background light intensity of each logical operation output port corresponding to a preset optical neural network, and to construct a logical contrast function based on the total light field energy and the background light intensity; a loss function construction module, configured to establish a corresponding logical contrast loss function based on the logical contrast function, and to construct a hybrid loss function corresponding to the optical neural network based on the logical contrast loss function and a preset mean square error loss function; and an adaptive training module, configured to train the optical neural network using the hybrid loss function based on a preset adaptive training strategy, and to determine whether the hybrid loss function meets a preset convergence requirement during the training process. If the hybrid loss function does not meet the preset convergence requirement, the optical neural network is further trained using the hybrid loss function; if the hybrid loss function meets the preset convergence requirement, the optical neural network is trained using the mean square error loss function to generate a target optical neural network that meets the preset training requirements.

[0018] Optionally, in one embodiment of this application, the loss function construction module includes: a determining unit, configured to determine the logical contrast weighting coefficient and the mean square error weighting coefficient corresponding to the logical contrast loss function and the mean square error loss function, respectively; and a building unit, configured to construct the hybrid loss function based on the logical contrast weighting coefficient and the mean square error weighting coefficient, and in combination with the logical contrast loss function and the mean square error loss function.

[0019] Optionally, in one embodiment of this application, the mathematical expression of the logical contrast function is:

[0020] Among them, E i E represents the total energy of the optical field at the output port of the i-th logic operation; backThis indicates the background light intensity.

[0021] Optionally, in one embodiment of this application, the mathematical expression of the logical contrast loss function is:

[0022] Among them, LC i T represents the logical contrast function; i This represents the target output logic value of the i-th port, where i is a positive integer.

[0023] Optionally, in one embodiment of this application, the mathematical expression of the hybrid loss function is: e combined =f MSE ·e MSE +f LC ·e LC

[0024] Among them, f MSE e represents the mean square error weighting coefficient; MSE f represents the mean squared error loss function; LC e represents the logical contrast weighting coefficient; LC This represents the logical contrast loss function.

[0025] A third aspect of this application provides an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the optical neural network training method for logic operations as described in the above embodiments.

[0026] A fourth aspect of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described optical neural network training method for logic-oriented operations.

[0027] A fifth aspect of this application provides a computer program product, including a computer program that is executed to implement the above-described optical neural network training method for logic operations.

[0028] Therefore, the embodiments of this application have the following beneficial effects:

[0029] The embodiments of this application determine the total light field energy and background light intensity of each logic operation output port corresponding to a preset optical neural network, and construct a logic contrast function based on the total light field energy and background light intensity; establish a corresponding logic contrast loss function based on the logic contrast loss function, and construct a hybrid loss function corresponding to the optical neural network based on the logic contrast loss function and a preset mean square error loss function; train the optical neural network using the hybrid loss function based on a preset adaptive training strategy, and determine whether the hybrid loss function meets the preset convergence requirements during the training process. If the hybrid loss function does not meet the preset convergence requirements, continue to train the optical neural network using the hybrid loss function; if the hybrid loss function meets the preset convergence requirements, train the optical neural network using the mean square error loss function to generate a target optical neural network that meets the preset training requirements. This enables optical neural network training that simultaneously satisfies the accuracy of logic and the similarity of light field modes. Therefore, it solves the problem that existing mean square error methods cannot guarantee logical correctness and may introduce erroneous bits when dealing with logic operations.

[0030] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description

[0031] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein:

[0032] Figure 1 is a flowchart of an optical neural network training method for logic operations according to an embodiment of this application;

[0033] Figure 2 is an example diagram of an optical neural network training device for logic operations according to an embodiment of this application;

[0034] Figure 3 is a schematic diagram of the structure of the electronic device provided in the embodiment of this application.

[0035] Among them, 10-Optical neural network training device for logic operations; 100-Logic contrast module, 200-Loss function construction module, 300-Adaptive training module; 301-Memory, 302-Processor, 303-Communication interface. Detailed Implementation

[0036] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this application, and should not be construed as limiting this application.

[0037] The following describes a training method and apparatus for an optical neural network oriented towards logic operations, based on embodiments of the present application, with reference to the accompanying drawings. Addressing the problems mentioned in the background art, this application provides a training method for an optical neural network oriented towards logic operations. In this method, the total energy of the light field and the background light intensity of each logic operation output port corresponding to a preset optical neural network are determined, and a logic contrast function is constructed based on the total light field energy and the background light intensity. A corresponding logic contrast loss function is established based on the logic contrast loss function, and a hybrid loss function corresponding to the optical neural network is constructed based on the logic contrast loss function and a preset mean square error loss function. Based on a preset adaptive training strategy, the optical neural network is trained using the hybrid loss function, and it is determined whether the hybrid loss function meets a preset convergence requirement during training. If the hybrid loss function does not meet the preset convergence requirement, the optical neural network continues to be trained using the hybrid loss function; if the hybrid loss function meets the preset convergence requirement, the optical neural network is trained using the mean square error loss function to generate a target optical neural network that meets the preset training requirements. This allows for the simultaneous satisfaction of logical accuracy and light field mode similarity in optical neural network training. Therefore, the problem of existing mean square error methods failing to guarantee logical correctness and introducing erroneous bits during logic operations is solved.

[0038] Specifically, Figure 1 is a flowchart of an optical neural network training method for logic operations provided in an embodiment of this application.

[0039] As shown in Figure 1, the training method for this logic-oriented optical neural network includes the following steps:

[0040] In step S101, the total light field energy and background light intensity of each logic operation output port corresponding to the preset optical neural network are determined, and a logic contrast function is constructed based on the total light field energy and background light intensity.

[0041] The embodiments of this application first construct a logic contrast function by determining the total light field energy and background light intensity of each logic operation output port of the optical neural network, so as to train an optical neural network oriented to logic tasks, and the light intensity of the output port of the trained optical neural network can meet the correctness requirements of the logic operation.

[0042] Optionally, in one embodiment of this application, the mathematical expression of the logical contrast function is:

[0043] Among them, E i E represents the total energy of the optical field at the output port of the i-th logic operation; back Indicates background light intensity.

[0044] Those skilled in the art should understand that, based on the characteristics of logical operations, when the target output value is logic 1, the peak value of the output port energy does not need to be absolutely 1; it is only necessary to make the energy contrast between the output port position and the non-output port position as high as possible. When the target output value is logic 0, the energy value of the output port also does not need to be absolutely 0; it is only necessary to make the energy of the output port position as close as possible to that of the non-output port position, and the background light field energy as close as possible to 0.

[0045] Therefore, embodiments of this application can construct a logic contrast function (LC) for training optical neural networks oriented towards logic operations, with the LC value of each port as shown in the following formula:

[0046] Among them, E i Let E be the total energy of the light field at the output port of the i-th logic operation, and let E be the average energy of the entire light field output section that does not enter the output port, i.e., the background light intensity E. back .

[0047] In step S102, a corresponding logical contrast loss function is established based on the logical contrast function, and a hybrid loss function corresponding to the optical neural network is constructed based on the logical contrast loss function and the preset mean square error loss function.

[0048] Subsequently, embodiments of this application can combine traditional mean square error loss function and logical contrast loss function to construct a hybrid loss function, thereby enabling the output port of the trained optical neural network to simultaneously meet the requirements of correct logical operation and similarity of optical field mode.

[0049] Optionally, in one embodiment of this application, the mathematical expression for the logical contrast loss function is:

[0050] Among them, LC i Represents the logical contrast function; T i This represents the target output logic value of the i-th port, where i is a positive integer.

[0051] The logical contrast loss function based on logical contrast is shown in the following equation:

[0052] Among them, T i The target output logic value for the i-th port.

[0053] Understandably, based on the definition of the LC loss function, in an ideal state, when the target output is logic 1, the peak value of the output port energy does not need to be absolutely 1. It is sufficient that the energy contrast between the output port and the surrounding background energy is large enough when the output value is logic 1. When the target output is logic 0, the output port energy also does not need to be absolutely 0. It is sufficient that the energy between the output port and the surrounding background energy is as close as possible when the output value is logic 0.

[0054] Optionally, in one embodiment of this application, a hybrid loss function corresponding to the optical neural network is constructed based on the logical contrast loss function and a preset mean square error loss function, including: determining the logical contrast weighting coefficient and the mean square error weighting coefficient corresponding to the logical contrast loss function and the mean square error loss function, respectively; and constructing the hybrid loss function based on the logical contrast weighting coefficient and the mean square error weighting coefficient, combined with the logical contrast loss function and the mean square error loss function.

[0055] It should be noted that while the MSE loss function can guarantee the shape of the light field as much as possible, it cannot guarantee the logical correctness of the operation, which may result in erroneous bits. The LC loss function can enable the network to train the correct bits according to the characteristics of the output port distribution, but its output signal quality is generally poor and has large glitches.

[0056] Therefore, in the embodiments of this application, a hybrid loss function can be constructed by adding the LC and MSE loss functions with certain weights based on the LC loss function.

[0057] Optionally, in one embodiment of this application, the mathematical expression for the hybrid loss function is: e combined =f MSE ·e MSE +f LC ·e LC

[0058] Among them, f MSE e represents the weighting coefficient for the mean square error; MSE f represents the mean squared error loss function; LC Represents the logical contrast weighting coefficient; e LC This represents the logical contrast loss function.

[0059] In practical implementation, embodiments of this application can construct a hybrid loss function based on the logical contrast loss function and the mean square error loss function, combined with the corresponding logical contrast weighting coefficient and mean square error weighting coefficient, as shown in the following equation: e combined =f MSE ·e MSE +f LC ·e LC (4)

[0060] Among them, e LC Represents the logical contrast loss function; e MSE f represents the mean squared error loss function; LC f represents the logical contrast weighting coefficient; MSE f represents the weighting coefficient for the mean square error. MSE and f LC It can be set to an equal value of 0.5, or it can be dynamically adjusted to different proportions according to the network structure.

[0061] Therefore, the embodiments of this application construct the above-mentioned hybrid loss function, thereby enabling network training to simultaneously meet the requirements of logical accuracy and similarity of light field modes, thus achieving better training.

[0062] In step S103, based on a preset adaptive training strategy, an optical neural network is trained using a hybrid loss function, and it is determined whether the hybrid loss function meets the preset convergence requirements during the training process. If the hybrid loss function does not meet the preset convergence requirements, the optical neural network is trained using the hybrid loss function. If the hybrid loss function meets the preset convergence requirements, the optical neural network is trained using the mean square error loss function to generate a target optical neural network that meets the preset training requirements.

[0063] Furthermore, in order to improve training efficiency, this application embodiment can construct an adaptive training method based on the hybrid loss function. In the initial stage of training, the hybrid loss function is used. After multiple iterations, when the value of the loss function is close to convergence and no further improvement is needed, the method is adaptively adjusted to the MSE-based loss function to continue training, optimize the light field distribution, reduce the degree of glitch, and thus enable the output light field to converge quickly and meet the requirements of logical operation accuracy and target light field similarity.

[0064] Therefore, the embodiments of this application, by first employing a hybrid loss function and then adaptively switching to a traditional mean square error neural network training method, not only enable the neural network training to converge quickly, but also ensure that the output port of the trained optical neural network can simultaneously meet the requirements of correct logical operations and similarity of the optical field mode.

[0065] In summary, this application's embodiments, for training optical neural networks based on logical operations, construct a loss function based on logical contrast, and further propose a hybrid loss function combining traditional mean square error and logical contrast, as well as an adaptive training method that switches the loss function during training. This solves the problem that the traditional mean square error method cannot guarantee logical correctness and may produce erroneous bits when facing logical operations, and realizes optical neural network training that can simultaneously satisfy the accuracy of logic and the similarity of the optical field mode.

[0066] According to the optical neural network training method for logic operations proposed in this application, the total energy of the light field and the background light intensity of each logic operation output port corresponding to the preset optical neural network are determined, and a logic contrast function is constructed based on the total energy of the light field and the background light intensity. A corresponding logic contrast loss function is established based on the logic contrast loss function, and a hybrid loss function corresponding to the optical neural network is constructed based on the logic contrast loss function and a preset mean square error loss function. Based on a preset adaptive training strategy, the optical neural network is trained using the hybrid loss function, and it is determined whether the hybrid loss function meets the preset convergence requirements during the training process. If the hybrid loss function does not meet the preset convergence requirements, the optical neural network is trained again using the hybrid loss function. If the hybrid loss function meets the preset convergence requirements, the optical neural network is trained using the mean square error loss function to generate a target optical neural network that meets the preset training requirements, thereby enabling the training of an optical neural network that simultaneously satisfies the accuracy of logic and the similarity of the light field mode.

[0067] Secondly, with reference to the accompanying drawings, an optical neural network training apparatus for logic operations proposed according to an embodiment of this application will be described.

[0068] Figure 2 is a block diagram of an optical neural network training device for logic operations according to an embodiment of this application.

[0069] As shown in Figure 2, the optical neural network training device 10 for logic operations includes: a logic contrast module 100, a loss function construction module 200, and an adaptive training module 300.

[0070] The logic contrast module 100 is used to determine the total light field energy and background light intensity of each logic operation output port corresponding to the preset optical neural network, and to construct a logic contrast function based on the total light field energy and background light intensity.

[0071] The loss function construction module 200 is used to establish a corresponding logical contrast loss function based on the logical contrast function, and to construct a hybrid loss function corresponding to the optical neural network based on the logical contrast loss function and the preset mean square error loss function.

[0072] The adaptive training module 300 is used to train an optical neural network using a hybrid loss function based on a preset adaptive training strategy, and to determine whether the hybrid loss function meets the preset convergence requirements during the training process. If the hybrid loss function does not meet the preset convergence requirements, the optical neural network is trained using the hybrid loss function. If the hybrid loss function meets the preset convergence requirements, the optical neural network is trained using the mean squared error loss function to generate a target optical neural network that meets the preset training requirements.

[0073] Optionally, in one embodiment of this application, the loss function construction module 200 includes: a determination unit and a construction unit.

[0074] The determining unit is used to determine the logical contrast weighting coefficient and the mean square error weighting coefficient corresponding to the logical contrast loss function and the mean square error loss function, respectively.

[0075] A unit is established to construct a hybrid loss function based on the logical contrast weighting coefficient and the mean square error weighting coefficient, combined with the logical contrast loss function and the mean square error loss function.

[0076] Optionally, in one embodiment of this application, the mathematical expression of the logical contrast function is:

[0077] Among them, E i E represents the total energy of the optical field at the output port of the i-th logic operation; back Indicates background light intensity.

[0078] Optionally, in one embodiment of this application, the mathematical expression for the logical contrast loss function is:

[0079] Among them, LC i Represents the logical contrast function; T i Let represent the target output logic value of the i-th port, where i is a positive integer. Optionally, in one embodiment of this application, the mathematical expression of the hybrid loss function is: e combined =f MSE ·e MSE +f LC ·e LC

[0080] Among them, f MSE e represents the weighting coefficient for the mean square error; MSE f represents the mean squared error loss function; LC Represents the logical contrast weighting coefficient; e LC This represents the logical contrast loss function.

[0081] It should be noted that the foregoing explanation of the embodiment of the optical neural network training method for logic operations also applies to the optical neural network training device for logic operations in this embodiment, and will not be repeated here.

[0082] The optical neural network training device for logic operations proposed in this application includes a logic contrast module 100, used to determine the total light field energy and background light intensity of each logic operation output port corresponding to a preset optical neural network, and to construct a logic contrast function based on the total light field energy and background light intensity; a loss function construction module 200, used to establish a corresponding logic contrast loss function based on the logic contrast function, and to construct a hybrid loss function corresponding to the optical neural network based on the logic contrast loss function and a preset mean square error loss function; and an adaptive training module 300, used to train the optical neural network using the hybrid loss function based on a preset adaptive training strategy, and to determine whether the hybrid loss function meets a preset convergence requirement during the training process. If the hybrid loss function does not meet the preset convergence requirement, the optical neural network is trained using the hybrid loss function. If the hybrid loss function meets the preset convergence requirement, the optical neural network is trained using the mean square error loss function to generate a target optical neural network that meets the preset training requirements, thereby enabling the training of an optical neural network that simultaneously satisfies the accuracy of logic and the similarity of the light field mode.

[0083] Figure 3 is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device may include:

[0084] The memory 301, the processor 302, and the computer program stored on the memory 301 and capable of running on the processor 302.

[0085] When the processor 302 executes the program, it implements the optical neural network training method for logic operations provided in the above embodiments.

[0086] Furthermore, electronic devices also include:

[0087] Communication interface 303 is used for communication between memory 301 and processor 302.

[0088] The memory 301 is used to store computer programs that can run on the processor 302.

[0089] The memory 301 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.

[0090] If the memory 301, processor 302, and communication interface 303 are implemented independently, they can be interconnected via a bus to communicate with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of representation, only one thick line is used in Figure 3, but this does not indicate that there is only one bus or one type of bus.

[0091] Optionally, in a specific implementation, if the memory 301, processor 302, and communication interface 303 are integrated on a single chip, then the memory 301, processor 302, and communication interface 303 can communicate with each other through an internal interface.

[0092] Processor 302 may be a central processing unit (CPU), an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application.

[0093] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described optical neural network training method for logic-oriented operations.

[0094] This application also provides a computer program product, including a computer program, which, when executed, is used to implement the above-described optical neural network training method for logic operations.

[0095] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.

[0096] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "N" means at least two, such as two, three, etc., unless otherwise explicitly specified.

[0097] Any process or method described in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or N executable instructions for implementing custom logic functions or processes, and the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as should be understood by those skilled in the art to which embodiments of this application pertain.

[0098] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection having one or more wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Alternatively, the computer-readable medium may be paper or other suitable media on which the program can be printed, since the program can be obtained electronically by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in a computer memory.

[0099] It should be understood that the various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, the N steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. If implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

[0100] Those skilled in the art will understand that all or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, the program includes one or a combination of the steps of the method embodiments.

[0101] Furthermore, the functional units in the various embodiments of this application can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.

[0102] The storage medium mentioned above can be a read-only memory, a disk, or an optical disk, etc. Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of this application.

Claims

1. A method for training an optical neural network oriented to logical operations, characterized by, The method comprises the following steps: determining the total optical field energy and the background light intensity of each logical operation output port corresponding to the preset optical neural network, and constructing a logical contrast function based on the total optical field energy and the background light intensity; establishing a corresponding logical contrast loss function according to the logical contrast function, and constructing a hybrid loss function corresponding to the optical neural network based on the logical contrast loss function and a preset mean square error loss function; training the optical neural network by using the hybrid loss function based on a preset adaptive training strategy, and determining whether the hybrid loss function meets a preset convergence requirement in the training process; if the hybrid loss function does not meet the preset convergence requirement, the optical neural network is continuously trained by using the hybrid loss function; if the hybrid loss function meets the preset convergence requirement, the optical neural network is trained by using the mean square error loss function to generate a target optical neural network meeting a preset training requirement.

2. The method of claim 1, wherein, The method comprises the following steps: respectively determining a logical contrast weighting coefficient and a mean square error weighting coefficient corresponding to the logical contrast loss function and the mean square error loss function; constructing the hybrid loss function based on the logical contrast weighting coefficient and the mean square error weighting coefficient and in combination with the logical contrast loss function and the mean square error loss function.

3. The method of claim 1, wherein, The mathematical expression of the logic contrast function is: wherein E i represents the total energy of the light field at the i-th logical operation output port; E back represents the background light intensity.

4. The method of claim 1, wherein, The mathematical expression of the logic contrast loss function is: wherein LC i represents the logic contrast function; T i represents the target output logic value of the i-th port, wherein i belongs to positive integers.

5. The method of claim 2, wherein, The mathematical expression of the mixed loss function is: combined = f MSE · e MSE + f LC · e LC Among them, f MSE e represents the weighting coefficient of the mean square error; MSE f represents the mean squared error loss function; LC e represents the logical contrast weighting coefficient; LC This represents the logical contrast loss function.

6. A training device for an optical neural network oriented towards logical operations, characterized in that, The method comprises the following steps: a logical contrast module configured to determine the total optical field energy and the background light intensity of each logical operation output port corresponding to the preset optical neural network, and construct a logical contrast function based on the total optical field energy and the background light intensity; a loss function construction module configured to establish a corresponding logical contrast loss function according to the logical contrast function, and construct a hybrid loss function corresponding to the optical neural network based on the logical contrast loss function and a preset mean square error loss function; an adaptive training module configured to train the optical neural network by using the hybrid loss function based on a preset adaptive training strategy, and determine whether the hybrid loss function meets a preset convergence requirement in the training process; if the hybrid loss function does not meet the preset convergence requirement, the optical neural network is continuously trained by using the hybrid loss function; if the hybrid loss function meets the preset convergence requirement, the optical neural network is trained by using the mean square error loss function to generate a target optical neural network meeting a preset training requirement.

7. The apparatus of claim 6, wherein, The loss function construction module comprises: a determination unit configured to respectively determine a logical contrast weighting coefficient and a mean square error weighting coefficient corresponding to the logical contrast loss function and the mean square error loss function; an establishment unit configured to construct the hybrid loss function based on the logical contrast weighting coefficient and the mean square error weighting coefficient and in combination with the logical contrast loss function and the mean square error loss function.

8. An electronic device, comprising: The method comprises the following steps: A memory, a processor, and a computer program stored on the memory and executable on the processor, the processor executing the program to implement the method of claim 1-5.

9. A computer-readable storage medium having stored thereon a computer program, characterized in that, The program is executed by a processor for implementing the method of claim 1-5.

10. A computer program product comprising a computer program, characterized in that, The computer program is executed for implementing the method of claim 1-5.