Heterogeneous neural network multi-paradigm unified execution and training scheduling method and device

CN122414301BActive Publication Date: 2026-10-09XIAMEN UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202610871024.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-06-16
Publication Date
2026-10-09
Estimated Expiration
2046-06-16

AI Technical Summary

Technical Problem

现有技术缺乏统一的运行时协调机制,难以在同一训练循环中自动兼容多种训练方法的执行顺序与更新逻辑,导致混合训练流程的实现高度依赖人工编写复杂调度代码;再者,当异构神经网络需要进行端到端联合训练时,人工神经网络部分的误差梯度需通过边界传递至脉冲神经网络部分

Benefits of technology

[0007] Furthermore, when impulsive temporal dependent plasticity training and backpropagation-based gradient training are detected to coexist, an accumulation-delay application mechanism is executed to separate the calculation and application of weight updates. This ensures the integrity of the computation graph during forward propagation, enabling backpropagation to correctly calculate gradients. At the same time, it allows impulsive temporal dependent plasticity to learn based on complete impulsive temporal information. The two updates do not interfere with each other, realizing the coordinated execution of local plasticity learning rules and global gradient optimization in the same network, avoiding update timing conflicts and computation graph conflicts.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122414301B_ABST
    Figure CN122414301B_ABST
Patent Text Reader

Abstract

The present disclosure provides a multi-paradigm unified execution and training scheduling method and device of a heterogeneous neural network, and relates to the technical field of computers. The multi-paradigm unified execution and training scheduling method of the heterogeneous neural network comprises: parsing an intermediate representation file output by a compilation system, extracting a network topology structure, sub-network division information and a training method configuration corresponding to each sub-network from the intermediate representation file; generating a network execution plan according to the network topology structure; sequentially executing each network execution phase according to the execution plan; and according to the training method configuration, when it is detected that the pulse timing-dependent plasticity training and the gradient training based on the back propagation coexist, a cumulative-delay application mechanism is executed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and in particular to a method and apparatus for multi-paradigm unified execution and training scheduling of heterogeneous neural networks. Background Technology

[0002] As neural network technology develops towards heterogeneous integration, combining artificial neural networks (ANNs) with spiking neural networks (SNNs) to construct heterogeneous neural networks has become an important research direction. A typical heterogeneous neural network development toolchain usually includes a programming language layer, a compilation layer, and a runtime execution layer. The programming language layer is responsible for providing unified network description capabilities, the compilation layer is responsible for converting high-level descriptions into structured intermediate representations, and the runtime execution layer is responsible for receiving the intermediate representation files output by the compilation system, actually scheduling the computation execution of each part of the network, managing the states of neurons and synapses, and coordinating the network training process.

[0003] Several problems exist in the actual execution and training of heterogeneous neural networks. First, at the runtime execution level, artificial neural networks use a static tensor computation mode, and their forward propagation can be completed instantaneously. However, the computation of spiking neural networks is essentially the time evolution of a dynamic system, requiring iterative execution across multiple discrete time steps. The runtime system needs to coordinate these two drastically different computation modes to achieve efficient scheduling while ensuring the correctness of data dependencies. Second, different subnetworks of heterogeneous neural networks often employ differentiated training paradigms, which differ fundamentally in update timing, learning signal sources, and parameter update methods. Existing technologies lack a unified runtime coordination mechanism, making it difficult to automatically accommodate the execution order and update logic of multiple training methods within the same training loop. This leads to a high dependence on manually written complex scheduling code for the implementation of hybrid training processes. Furthermore, when heterogeneous neural networks require end-to-end joint training, the error gradient of the artificial neural network part needs to be propagated to the spiking neural network part through the boundary. If the spiking neural network part executes local learning rules such as pulse temporal dependence plasticity locally during forward propagation and modifies synaptic weights in real time, it will directly disrupt the integrity of the computational graph upon which backpropagation depends. Summary of the Invention

[0004] This disclosure provides a multi-paradigm unified execution and training scheduling method and device for heterogeneous neural networks.

[0005] According to one aspect of this disclosure, a multi-paradigm unified execution and training scheduling method for heterogeneous neural networks is provided, comprising: The intermediate representation file output by the compilation system is parsed, and the network topology, sub-network partitioning information, and training method configurations corresponding to each sub-network are extracted from the intermediate representation file. Based on the network topology, a network execution plan is generated, which includes multiple network execution stages arranged in sequence, including an artificial neural network stage, a spiking neural network stage, or a boundary transition stage. The network execution phases are executed sequentially according to the execution plan. In the artificial neural network phase, forward propagation is performed. In the boundary transition phase, data format conversion between the artificial neural network and the spiking neural network is performed. In the spiking neural network phase, the time step iteration loop is entered, and synaptic transmission calculation, neuron dynamic state update, pulse firing judgment, and state reset operation are performed sequentially in each time step. According to the training method configuration, when the coexistence of pulse time-dependent plasticity training and gradient training based on backpropagation is detected, an accumulation-delay application mechanism is executed. During the time step iteration of forward propagation, the accumulation-delay application mechanism only calculates and accumulates the weight update amount to an independent accumulation update buffer, keeping the weight parameters unchanged. After forward propagation is completed, loss function calculation is completed, backpropagation is completed, and the parameters of the artificial neural network are updated, the weight update amount accumulated in the accumulation update buffer is uniformly applied to the weight parameters corresponding to the spiking neural network part.

[0006] According to one technical solution, the intermediate representation file of the target heterogeneous neural network is parsed to extract the network topology, subnetwork partitioning information, and training method configurations corresponding to each subnetwork. Then, a network execution plan is generated based on the network topology, including an artificial neural network stage, a spiking neural network stage, or a boundary transition stage. Each stage is executed sequentially according to this plan. Specifically, the artificial neural network stage directly performs forward propagation; the boundary transition stage performs data format conversion; and the spiking neural network stage enters a time-step iteration loop and sequentially performs synaptic transmission calculation, neuron dynamics state update, spike firing judgment, and state reset operations. This allows the heterogeneous neural network to automatically identify and coordinate two distinct computational modes during runtime, significantly reducing scheduling overhead while ensuring data dependency correctness and avoiding the need for users to manually write complex loop and branch code.

[0007] Furthermore, when impulsive temporal dependent plasticity training and backpropagation-based gradient training are detected to coexist, an accumulation-delay application mechanism is executed to separate the calculation and application of weight updates. This ensures the integrity of the computation graph during forward propagation, enabling backpropagation to correctly calculate gradients. At the same time, it allows impulsive temporal dependent plasticity to learn based on complete impulsive temporal information. The two updates do not interfere with each other, realizing the coordinated execution of local plasticity learning rules and global gradient optimization in the same network, avoiding update timing conflicts and computation graph conflicts.

[0008] A multi-paradigm unified execution and training scheduling method for heterogeneous neural networks according to at least one embodiment of the present disclosure generates a network execution plan based on the network topology, including: The computing nodes and their connections are extracted from the network topology to construct a directed acyclic graph. The computing nodes include artificial neural network layer nodes, spiking neural network neuron group nodes, and boundary transition nodes set between the artificial neural network layer and the spiking neural network neuron group. Perform a topological sort on the directed acyclic graph to obtain the execution order of nodes that satisfy data dependencies; The nodes are traversed in the execution order, and multiple consecutive artificial neural network layer nodes are merged into an artificial neural network stage, multiple consecutive spiking neural network neuron group nodes are merged into a spiking neural network stage, and each boundary transition node becomes an independent boundary transition stage. A time step configuration is associated with each spiking neural network stage, which specifies the number of time steps required for that spiking neural network stage to be iterated.

[0009] According to at least one embodiment of the heterogeneous neural network multi-paradigm unified execution and training scheduling method of this disclosure, an accumulation-delay application mechanism is executed, including: At the beginning of each training batch, the cumulative update buffer is initialized as a zero tensor with the same shape as the synaptic weight matrix of the spiking neural network part, and the presynaptic trace variables and postsynaptic trace variables are reset to zero; The forward propagation time step iteration is performed. In each time step, based on the presynaptic pulse firing sequence and postsynaptic pulse firing sequence at the current time, and combined with the exponentially decaying trace variable, the long-term enhancement update term and the long-term suppression update term are calculated respectively. The difference between the long-term enhancement update term and the long-term suppression update term is used as the weight update amount and accumulated into the cumulative update buffer. After completing the forward propagation, the loss function is calculated and back propagation is performed to obtain the gradient values ​​of the parameters that need to be updated. Update the parameters of the artificial neural network part based on the gradient value; The accumulated weight update amount in the cumulative update buffer is multiplied by the learning rate and then added to the synaptic weight matrix, and weight boundary clipping is performed.

[0010] According to at least one embodiment of the heterogeneous neural network multi-paradigm unified execution and training scheduling method of this disclosure, the difference between long-term enhancement update terms and long-term suppression update terms is accumulated as a weight update amount and added to the accumulated update buffer, including: Based on the current values ​​of the synaptic weight matrix, the preset upper and lower weight thresholds, determine the long-term enhancement scaling factor and the long-term suppression scaling factor. The long-term enhancement update term is multiplied element-wise by the long-term enhancement scaling factor, and the long-term suppression update term is multiplied element-wise by the long-term suppression scaling factor to achieve a scaling of the update amount that smoothly decays as the weight approaches the boundary. The difference between the scaled long-term enhancement update term and the long-term suppression update term is used as the weight update amount and accumulated into the cumulative update buffer.

[0011] The multi-paradigm unified execution and training scheduling method for heterogeneous neural networks according to at least one embodiment of the present disclosure further includes an execution reward modulation pulse time-dependent plasticity training mechanism, wherein the reward modulation pulse time-dependent plasticity training mechanism includes: After each training batch completes forward propagation, the classification accuracy of the current batch of samples is calculated based on the network output and the true labels, and the dynamic baseline accuracy is determined based on the total number of task categories, wherein the dynamic baseline accuracy is the reciprocal of the total number of task categories. The classification accuracy is compared with the dynamic benchmark accuracy, and the corresponding reward modulation signal is determined based on the comparison result; The accumulated weight update amount in the cumulative update buffer is multiplied by the reward modulation signal and then applied to the weight parameters corresponding to the spiking neural network part.

[0012] The multi-paradigm unified execution and training scheduling method for heterogeneous neural networks according to at least one embodiment of the present disclosure further includes an execution separation optimizer management mechanism, the separation optimizer management mechanism comprising: Based on the training method configuration of each sub-network, identify the sub-network that needs to be trained by gradient based on backpropagation, as well as the corresponding optimizer type and learning rate parameter of the sub-network; For each subnetwork that needs gradient training, collect all trainable parameters contained in that subnetwork and form a parameter set; Based on the optimizer type and the learning rate parameter, create an independent optimizer instance for each parameter group, and establish a mapping relationship between the sub-network identifier and the optimizer instance; In each training iteration, after performing backpropagation to calculate the gradients of all parameters, the mapping relationship is traversed, and the parameter update method of each optimizer instance is called in turn to update their respective parameter groups.

[0013] According to at least one embodiment of the heterogeneous neural network multi-paradigm unified execution and training scheduling method of the present disclosure, the multi-paradigm unified execution and training scheduling method of the heterogeneous neural network further includes: Based on the training method configuration corresponding to each sub-network, the training method type specified for each sub-network is determined. The training method type includes backpropagation, surrogate gradient, impulsive temporal dependent plasticity, Heb learning, evolutionary strategy, or parameter freezing. If any subnetwork has a training method type of spurious temporal dependent plasticity, then the spurious temporal dependent plasticity training process based on the cumulative-delay application mechanism is invoked; if there is no spurious temporal dependent plasticity but there is an evolutionary policy, then the evolutionary policy training process is invoked; if there is no spurious temporal dependent plasticity and an evolutionary policy but there is Heb learning, then the Heb learning training process is invoked; if there is no spurious temporal dependent plasticity, an evolutionary policy, or Heb learning, then the surrogate gradient training process is invoked.

[0014] The multi-paradigm unified execution and training scheduling method for heterogeneous neural networks according to at least one embodiment of the present disclosure further includes an execution neuron state management mechanism, the neuron state management mechanism comprising: For each spiking neural network stage, a state tensor is maintained for each spiking neuron model therein, the state tensor including the membrane potential tensor; Before the spiking neural network phase begins execution, the state tensor is allocated according to the batch size and the number of neurons, and initialized to the initial values ​​defined by the spiking neuron model. In the forward propagation at each time step, a new state value is calculated based on the current input current and the discretized dynamic equation of the spiking neuron model. After the calculation is completed, a gradient cutoff operation is performed on the new state value to disconnect the gradient connection between it and the old state value. For a spiking neuron model that emits pulses, a corresponding reset strategy is executed on the state value of the spiking neuron model.

[0015] According to another aspect of this disclosure, an electronic device is provided, comprising: a memory storing execution instructions; and a processor executing the execution instructions stored in the memory, such that the processor executes a multi-paradigm unified execution and training scheduling method for heterogeneous neural networks according to any embodiment of this disclosure.

[0016] According to another aspect of this disclosure, a readable storage medium is provided, wherein executable instructions are stored therein, which, when executed by a processor, are used to implement a multi-paradigm unified execution and training scheduling method for heterogeneous neural networks according to any embodiment of this disclosure.

[0017] According to another aspect of this disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements a multi-paradigm unified execution and training scheduling method for heterogeneous neural networks according to any embodiment of this disclosure. Attached Figure Description

[0018] The accompanying drawings illustrate exemplary embodiments of the present disclosure and, together with the description thereof, serve to explain the principles of the present disclosure. These drawings are included to provide a further understanding of the present disclosure and are incorporated in and constitute a part of this specification.

[0019] Figure 1 This is a schematic diagram of the architecture of a runtime system according to one embodiment of the present disclosure.

[0020] Figure 2 This is a flowchart illustrating a multi-paradigm unified execution and training scheduling method for heterogeneous neural networks according to one embodiment of the present disclosure.

[0021] Figure 3 This is a flowchart illustrating step S220 of a multi-paradigm unified execution and training scheduling method for heterogeneous neural networks according to one embodiment of the present disclosure.

[0022] Figure 4 This is a flowchart illustrating the cumulative-delay application mechanism in a multi-paradigm unified execution and training scheduling method for heterogeneous neural networks according to one embodiment of the present disclosure.

[0023] Figure 5 This is a flowchart illustrating the soft boundary constraints in a multi-paradigm unified execution and training scheduling method for heterogeneous neural networks according to one embodiment of the present disclosure.

[0024] Figure 6 This is a flowchart illustrating the reward modulation pulse timing-dependent plasticity training mechanism in a multi-paradigm unified execution and training scheduling method for heterogeneous neural networks according to one embodiment of the present disclosure.

[0025] Figure 7 This is a flowchart illustrating the neuron state management mechanism in a multi-paradigm unified execution and training scheduling method for heterogeneous neural networks according to one embodiment of the present disclosure.

[0026] Figure 8 This is a flowchart illustrating the separate optimizer management mechanism in a multi-paradigm unified execution and training scheduling method for heterogeneous neural networks according to one embodiment of the present disclosure.

[0027] Figure 9 This is a schematic structural block diagram of an electronic device according to one embodiment of the present disclosure. Detailed Implementation

[0028] The present disclosure will now be described in further detail with reference to the accompanying drawings and examples. It should be understood that the specific examples described herein are for illustrative purposes only and are not intended to limit the scope of the disclosure. Furthermore, it should be noted that, for ease of description, only the parts relevant to the present disclosure are shown in the accompanying drawings.

[0029] It should be noted that, where there is no conflict, the embodiments and features described in this disclosure can be combined with each other. The technical solutions of this disclosure will now be described in detail with reference to the accompanying drawings and embodiments.

[0030] Existing technologies struggle to coordinate the heterogeneous computational execution of artificial neural networks and spiking neural networks during heterogeneous neural network operation, to uniformly schedule multiple differentiated training paradigms, and to resolve the computational graph conflict between local learning rules and global gradient propagation.

[0031] To address this, the present disclosure proposes the following technical solution: In this solution, the intermediate representation file of the target heterogeneous neural network is parsed to extract the network topology, subnetwork partitioning information, and training method configurations corresponding to each subnetwork. Then, a network execution plan is generated based on the network topology, including an artificial neural network stage, a spiking neural network stage, or a boundary transition stage. Each stage is executed sequentially according to this plan. Specifically, the artificial neural network stage directly performs forward propagation; the boundary transition stage performs data format conversion; and the spiking neural network stage enters a time-step iteration loop and sequentially performs synaptic transmission calculation, neuron dynamics state update, spike firing judgment, and state reset operations. This allows the heterogeneous neural network to automatically identify and coordinate two distinct computational modes during runtime, significantly reducing scheduling overhead while ensuring data dependency correctness and avoiding the need for users to manually write complex loop and branch code.

[0032] Furthermore, when impulsive temporal dependent plasticity training and backpropagation-based gradient training are detected to coexist, an accumulation-delay application mechanism is executed to separate the calculation and application of weight updates. This ensures the integrity of the computation graph during forward propagation, enabling backpropagation to correctly calculate gradients. At the same time, it allows impulsive temporal dependent plasticity to learn based on complete impulsive temporal information. The two updates do not interfere with each other, realizing the coordinated execution of local plasticity learning rules and global gradient optimization in the same network, avoiding update timing conflicts and computation graph conflicts.

[0033] To facilitate description and make the technical solutions of this disclosure easier to understand, the terminology of this disclosure will be explained before describing the technical solutions of this disclosure.

[0034] STDP (Spike-Timing Dependent Plasticity): A biologically inspired synaptic learning rule that adjusts synaptic weights based on the time difference in the firing of spikes between neurons before and after the synapse.

[0035] Accumulate-Deferred-Apply Mechanism: This mechanism separates the weight update calculation and application in STDP. During forward propagation, only the weight update amount is accumulated without modifying the weights. After backpropagation is completed, the weights are applied uniformly, thereby resolving the computation graph conflict between STDP and backpropagation.

[0036] Surrogate Gradient: A training method that replaces the non-differentiable step portion of a spiking function with a smooth, differentiable function, enabling spiking neural networks to be trained using standard backpropagation.

[0037] Straight-Through Estimator (STE): A technique that performs discretization during forward propagation and bypasses discretization to directly pass gradients during backward propagation. It is used to maintain gradient flow connectivity at the boundaries of artificial neural networks and spiking neural networks.

[0038] Soft Boundary Constraint: An improved mechanism that dynamically scales the STDP update amount based on the distance between the weights and the boundary, avoiding the synaptic learning stagnation problem caused by hard boundary pruning.

[0039] Reward-Modulated STDP (R-STDP): The intensity and direction of STDP updates are dynamically adjusted based on task performance (such as classification accuracy), and a dynamic baseline strategy is adopted to adapt to different task difficulties.

[0040] Separate Optimizer: Creates separate optimizer instances for the artificial neural network part and the spiking neural network part of the heterogeneous neural network, supporting different learning rates, optimization algorithms and scheduling strategies.

[0041] Synaptic Trace: An exponentially decaying local variable used to record the recent pulse activity history of neurons. It can efficiently calculate STDP weight updates and avoid traversing the entire pulse history.

[0042] Intermediate Representation (IR): A structured file output by the compilation system, containing complete information such as network topology, neuron configuration, and training methods.

[0043] Figure 1 This is a schematic diagram of the architecture of a runtime system according to one embodiment of the present disclosure.

[0044] like Figure 1 As shown, the runtime system includes an intermediate representation parser, a unified execution scheduler, a multi-paradigm training coordinator, a boundary transition executor, a neuron state manager, and an adaptive optimization controller.

[0045] Specifically, the intermediate representation parser is responsible for parsing the intermediate representation file output by the compilation system, extracting information such as network topology, neuron model configuration, synaptic connection relationships, learning rule settings, boundary transformation specifications, and subnetwork training configuration, and converting this information into runtime data structures.

[0046] The unified execution scheduler is responsible for coordinating the execution order of various parts of the heterogeneous neural network, managing the time step iteration of the SNN, handling the data dependencies between subnetworks, and implementing an efficient hierarchical execution strategy.

[0047] The multi-paradigm training coordinator is responsible for the unified management of different training methods, including six training paradigms: backpropagation, surrogate gradient, STDP, Heb learning, evolutionary strategy, and parameter freezing. It assigns corresponding training processes to different sub-networks through a training method registration and distribution mechanism.

[0048] The boundary transformation executor is responsible for performing data format conversion between ANN and SNN at runtime, including encoding continuous values ​​to impulses and decoding impulses to continuous values, and maintaining the transitivity of gradients through the pass-through estimator technique.

[0049] The neuron state manager is responsible for maintaining the internal state of SNN neurons, including membrane potential, adaptive variables, synaptic traces, etc. It provides a unified interface for state initialization, update, and reset, and implements an efficient memory management strategy.

[0050] The adaptive optimization controller manages multiple independent optimizer instances, implements a separate optimizer mechanism, and generates reward signals based on dynamic information during training to achieve reward modulation learning.

[0051] Preferably, the runtime system also includes a network layer module as infrastructure, providing computational units such as ANN layer reuse mechanism, SNNLinear (proxy gradient mode), STDPLinearLayer (STDP mode), and hybrid network containers (such as HybridNet, HybridSandwichNet, HybridParallelNet, etc.) for building actual executable network models.

[0052] Figure 2This is a flowchart illustrating a multi-paradigm unified execution and training scheduling method for heterogeneous neural networks according to one embodiment of the present disclosure. This multi-paradigm unified execution and training scheduling method for heterogeneous neural networks can be applied to the runtime system described above, which can be deployed in a terminal device or server, wherein the terminal device includes, but is not limited to, one or more of smartphones, tablets, laptops, and desktop computers.

[0053] like Figure 2 As shown, the multi-paradigm unified execution and training scheduling method for heterogeneous neural networks preferably includes steps S210 to S240.

[0054] In step S210, the intermediate representation file output by the compilation system is parsed, and the network topology, sub-network partitioning information, and training method configurations corresponding to each sub-network are extracted from the intermediate representation file.

[0055] In this implementation, the intermediate representation parser takes a structured intermediate representation file output by the compilation system as input, which contains complete network definitions and configuration information. Preferably, the parsing process includes four stages: metadata extraction, model definition parsing, network structure parsing, and configuration information parsing.

[0056] In the metadata extraction phase, the intermediate representation parser first reads the header metadata of the intermediate representation file, including source file information, compiler version, discretization method, time step, and network type marker. The network type marker indicates whether the network is an ANN, SNN, or a heterogeneous neural network, and the runtime system selects the appropriate execution strategy accordingly.

[0057] During the model definition resolution phase, the intermediate representation parser extracts the neuron and synapse model definitions from the intermediate representation file. For the neuron model, the intermediate representation parser extracts information such as the model name, parameter list, initial state values, discretized state update expression, threshold conditions, and reset logic. For the synapse model, the intermediate representation parser extracts the weight parameters, learning rule type, and their parameter configuration. The intermediate representation parser maintains a model registry, mapping model names to runtime instantiable neuron and synapse classes.

[0058] During the network structure parsing phase, the intermediate representation parser constructs the network's topological representation (i.e., the network topology). For ANN layers, the intermediate representation parser extracts parameters such as layer type, input / output dimensions, kernel size, stride, and padding. For SNN neuron groups, the intermediate representation parser extracts the number of neurons, the model used, and the initial state configuration. For connections, the intermediate representation parser extracts the source node, target node, connection topology type, synaptic model references, and weight initialization configuration. For hybrid connections, the intermediate representation parser additionally extracts the boundary transformation specifications, including the source-side transformation function, the target-side transformation function, and their parameters.

[0059] During the configuration information parsing phase, the intermediate representation parser extracts the runtime configuration and training configuration. The runtime configuration includes the default time step, batch size, etc. The training configuration includes the training method configuration for each sub-network, optimizer type, learning rate, and training method-specific parameters, etc.

[0060] Based on the parsing results of the intermediate representation parser, the runtime system generates the following core data structures: Execution Plan Data Structure: This execution plan data structure describes the execution order and dependencies of the network. It includes multiple network execution stages, such as ANN stages, SNN stages, or boundary transformation stages. Each execution stage includes a stage identifier, a type marker (to distinguish between ANN, SNN, and boundary transformation stages), a list of included nodes, input dependencies, and an output target. Preferably, the network execution plan also includes a time step configuration to specify the number of iterations and the step size for the SNN stage.

[0061] Subnetwork configuration data structure: This describes the training configuration of each subnetwork. Each subnetwork configuration data structure includes a subnetwork identifier, training method name, optimizer type, learning rate, and training method-specific parameters. Specifically, for the STDP training method, the training method-specific parameters include the forward synapse time constant, the backward synapse time constant, the LTP magnitude, the LTD magnitude, and weight boundaries. For the evolutionary strategy training method, the training method-specific parameters include population size, mutation rate, and elite ratio.

[0062] Model instance registry: Used to maintain the mapping relationship between neuron model names and runtime classes. The runtime system predefines efficient implementations of commonly used neuron models, including LIF, IF, Izhikevich, and AdEx. The intermediate representation parser retrieves the corresponding class from the model instance registry based on the model reference in the intermediate representation file and instantiates it.

[0063] Based on the data structure constructed above, the runtime system automatically builds an executable network model. Preferably, the network model construction adopts a hierarchical assembly strategy. First, the basic layer components are built. Specifically, for ANN layers, the corresponding PyTorch modules are instantiated according to the layer type and parameter configuration. For SNN layers, SNN linear layers or SNN convolutional layers are built according to the input / output dimensions, neuron models, and synapse configurations. Each SNN layer contains weight parameters, neuron instances, and an optional STDP learner instance.

[0064] Next, the boundary transformation component is constructed. Based on the boundary transformation specifications, the encoder and decoder are instantiated. The encoder supports various pulse coding methods, including rate coding, direct coding, and Poisson coding. The decoder supports pulse counting, time averaging, and membrane potential readout. The boundary transformation component implements a pass-through estimator, performing discretization coding during forward propagation and transmitting continuous gradients during backward propagation.

[0065] Finally, the complete network model is assembled. Based on the network type, the runtime system selects the appropriate network container class. For sequential hybrid networks (e.g., no SNN layer between two ANN layers), a serial container is used to assemble the layers according to the execution plan. For parallel branch networks (i.e., multiple parallel paths exist), a parallel container is used to manage these parallel paths. For sandwich-structured networks (e.g., an SNN layer between two ANN layers), a dedicated container is used to manage the ANN-SNN-ANN data flow.

[0066] Please continue to refer to this. Figure 2 In step S220, a network execution plan is generated based on the network topology. The network execution plan includes multiple network execution stages arranged in sequence, including an artificial neural network stage, a spiking neural network stage, or a boundary transition stage.

[0067] In this implementation, the unified execution scheduler parses the network topology, understands the physical connections and data dependencies between computing nodes, and then generates a corresponding network execution plan. This network execution plan includes multiple network execution stages arranged in sequence, including an artificial neural network stage, a spiking neural network stage, or a boundary transition stage.

[0068] In some embodiments of this disclosure, step S220, generating a network execution plan based on the network topology, preferably includes steps S221 to S224. Please refer to [reference needed]. Figure 3 .

[0069] In step S221, computing nodes and the connection relationships between computing nodes are extracted from the network topology to construct a directed acyclic graph. The computing nodes include artificial neural network layer nodes, spiking neural network neuron group nodes, and boundary transition nodes set between artificial neural network layers and spiking neural network neuron groups.

[0070] In step S222, a topological sort is performed on the directed acyclic graph to obtain the execution order of nodes that satisfy the data dependencies.

[0071] In step S223, the execution order of the nodes is traversed, and multiple consecutive artificial neural network layer nodes are merged into an artificial neural network stage, multiple consecutive spiking neural network neuron group nodes are merged into a spiking neural network stage, and each boundary transition node becomes an independent boundary transition stage.

[0072] In step S224, a time step configuration is associated with each spiking neural network stage, the time step configuration being used to specify the number of time steps required for that spiking neural network stage to iterate.

[0073] In this implementation, the unified execution scheduler extracts all computing nodes and their connections from the parsed network topology, constructing a directed acyclic graph (DAG). Nodes in the DAG include ANN layer nodes, SNN neuron group nodes, and boundary transition nodes positioned between ANN layer nodes and spiking neural network neuron group nodes. Edges in the DAG represent data dependencies.

[0074] Next, the unified execution scheduler performs topological sorting on the directed acyclic graph to obtain the execution order of nodes that satisfy data dependencies. Topological sorting ensures that each settlement node is executed only after all its predecessor compute nodes have completed their execution.

[0075] The unified execution scheduler merges consecutive compute nodes of the same type into execution phases. Specifically, consecutive ANN layers are merged into ANN phases, consecutive SNN layers are merged into SNN phases, and boundary transition nodes form independent boundary transition phases. Phase merging reduces scheduling overhead and provides opportunities for intra-phase optimization.

[0076] In addition, the unified execution scheduler is configured with time steps associated with each SNN stage, specifying the number of time steps required for that stage to be executed iteratively. Preferably, the number of time steps can be specified globally in the intermediate representation, or it can be configured individually for each stage.

[0077] In this way, by extracting computing nodes and constructing a directed acyclic graph, the unified execution scheduler automatically transforms heterogeneous neural networks into a structured and analyzable graph model. This explicit representation of data dependencies makes subsequent topology sorting and dependency checking fully automated, eliminating the need to manually sort out the input-output relationships of each layer in the network. This completely eliminates the logical errors that may be caused by manually specifying the execution order, and significantly improves the reliability and development efficiency of heterogeneous network operation.

[0078] Please continue to refer to this. Figure 2 In step S230, each network execution stage is executed sequentially according to the execution plan. In the artificial neural network stage, forward propagation is performed. In the boundary conversion stage, data format conversion between the artificial neural network and the spiking neural network is performed. In the spiking neural network stage, a time step iteration loop is entered, and synaptic transmission calculation, neuron dynamic state update, pulse firing judgment, and state reset operation are performed sequentially in each time step.

[0079] In this implementation, the unified execution scheduler employs a hierarchical execution strategy to handle the forward propagation of heterogeneous neural networks. This hierarchical execution strategy comprises three nested execution loops. The outermost loop traverses each stage in the network execution plan, and for each stage, the unified execution scheduler selects the appropriate execution logic based on the stage type.

[0080] Preferably, for the ANN phase, the unified execution scheduler directly calls the sequence of PyTorch modules included in that ANN phase for forward computation. The computation in the ANN phase is instantaneous and does not involve time-step iteration. After computation, the output tensor is passed to the next phase or stored in an intermediate result buffer.

[0081] During the boundary transition phase, the unified execution scheduler invokes the boundary transition executor to perform data format conversion. For a transition from an ANN layer to a SNN layer, the executor encodes continuous-value tensors as impulse inputs. For a transition from an SNN layer to an ANN layer, the executor decodes accumulated impulse outputs as continuous-value tensors.

[0082] For the SNN stage, the unified execution scheduler enters the middle loop of the time step iteration. Before entering the loop, the unified execution scheduler first resets the internal state of all neurons in this SNN stage and pre-allocates the output buffer for accumulating output. This pre-allocation strategy avoids frequent memory allocation during iteration, significantly reducing the overhead of Python object creation.

[0083] The middle-level loop iterates through the time steps. Within each time step, the scheduler executes the inner loop, processing each layer within the SNN stage sequentially. For each SNN layer, the execution process includes: synaptic transmission calculation, linearly transforming the input pulses or currents through a weight matrix; neuron dynamics update, updating state variables such as membrane potential according to the discretized equations of the neuron model; pulse firing judgment, comparing the membrane potential with a threshold to determine which neurons fire pulses (firing when the membrane potential is greater than the threshold); and state reset, executing reset logic for neurons that fired pulses. The output pulses of each time step are accumulated into a pre-allocated output buffer.

[0084] After each time step iteration, a unified scheduler performs post-processing on the accumulated output. The post-processing method is configurable; the default is direct summation, which accumulates the pulse counts from each time step as the output of that SNN stage. Other optional methods include time averaging and taking the value at the last moment.

[0085] In some embodiments of this disclosure, to improve the execution efficiency of the SNN stage, the unified execution scheduler employs a pre-allocated memory optimization strategy. Specifically, before the SNN stage execution begins, the unified execution scheduler calculates the total memory required for the output buffer based on the batch size, the number of neurons, and the number of time steps, and allocates the complete tensor space at once. The shape of the buffer is (time steps, batch size, number of neurons) or an equivalent flattened shape.

[0086] During time-step iteration, the output of each time step is written directly to the corresponding position in the pre-allocated output buffer via indexing operations, instead of using list appending or tensor concatenation operations. This approach avoids the following overheads: (1) memory allocation overhead for creating a new tensor object at each time step; (2) overhead of dynamic expansion of Python lists; and (3) concatenation overhead of ultimately converting the list into a tensor.

[0087] In addition, for scenarios that require saving intermediate states for training, the unified execution scheduler also employs a pre-allocated memory optimization strategy to manage intermediate data such as membrane potential history and pulse history. The pre-allocated buffer is reset at the beginning of each new sample batch, filled during time step iterations within the batch, and can be selectively released after training updates to save memory.

[0088] To address extreme scenarios where processing high-resolution multimodal data or ultra-long sequences causes pre-allocated tensors to exceed device memory limits (OOM risk), the unified execution scheduler further supports a combination of time-step block execution and gradient checkpointing techniques. Specifically, the unified execution scheduler can automatically divide the total time steps into multiple sub-blocks for sequential execution, selectively releasing unnecessary intermediate membrane potential tensors between blocks, and retaining only the boundary states required across blocks, thereby achieving a flexible trade-off between memory and computational efficiency in the time-step dimension.

[0089] Please continue to refer to this. Figure 2 In step S240, according to the training method configuration, when it is detected that pulse time-dependent plasticity training and gradient training based on backpropagation coexist, an accumulation-delay application mechanism is executed. The accumulation-delay application mechanism only calculates and accumulates the weight update amount to an independent accumulation update buffer during the time step iteration of forward propagation, keeping the weight parameters unchanged. After forward propagation is completed, loss function calculation is completed, backpropagation is completed, and the parameters of the artificial neural network are updated, the weight update amount accumulated in the accumulation update buffer is uniformly applied to the weight parameters corresponding to the spiking neural network part.

[0090] In this implementation, when both impulse-time-dependent plasticity training and backpropagation-based gradient training are detected simultaneously in a heterogeneous network, the runtime system automatically switches to the cumulative-delay application training process. In this mode, during the forward propagation time step iterations, the STDP learner calculates weight updates only based on the current impulse time information and accumulates them in an independent cumulative update buffer, keeping the weight parameters unchanged. Then, standard forward propagation completion, loss calculation, and backpropagation are performed. Since the weight parameters are unchanged, backpropagation can obtain a complete computational graph and correctly calculate the gradient. After backpropagation, the parameters of the artificial neural network part are updated first, and finally, the accumulated weight updates in the cumulative update buffer are applied all at once to the corresponding weight parameters of the spiking neural network part, achieving a harmonious coexistence of STDP local learning and global gradient learning.

[0091] In some embodiments of this disclosure, the multi-paradigm unified execution and training scheduling method for heterogeneous neural networks further includes: determining the specified training method type for each sub-network based on the training method configuration corresponding to each sub-network, wherein the training method type includes backpropagation, surrogate gradient, impulsive temporal dependent plasticity, Heb learning, evolutionary policy, or parameter freezing; if any sub-network has an impulsive temporal dependent plasticity training method, then the impulsive temporal dependent plasticity training process based on the cumulative-delay application mechanism is invoked; if there is no impulsive temporal dependent plasticity but there is an evolutionary policy, then the evolutionary policy training process is invoked; if there is no impulsive temporal dependent plasticity and an evolutionary policy but there is Heb learning, then the Heb learning training process is invoked; if there are no impulsive temporal dependent plasticity, evolutionary policy, or Heb learning, then the surrogate gradient training process is invoked.

[0092] In this implementation, the multi-paradigm training coordinator uses a registration and distribution mechanism to manage different training methods, thereby providing a unified training interface while supporting the specific implementation of each training method.

[0093] Specifically, the multi-paradigm training coordinator maintains a training method registry, pre-registering six training methods: backpropagation, surrogate gradient, STDP, Heb learning, evolutionary strategy, and parameter freezing. Each training method registers a trainer class, which implements a unified interface, including initialization methods, forward hook methods, update methods, and state reset methods.

[0094] During the runtime initialization phase, the multi-paradigm training coordinator instantiates a corresponding trainer for each sub-network based on its configuration. Upon instantiation, the trainer receives parameter references and training configurations from the sub-network and completes the initialization of its internal state. For the STDP trainer, initialization includes creating synaptic trace tensors, setting time constants, and configuring weight boundaries. For the evolutionary strategy trainer, initialization includes creating the population and setting mutation parameters.

[0095] During training, the training coordinator selects the training flow based on the detected primary training methods. The detection logic traverses all sub-network configurations, determining the presence of a specific training method in priority order. Specifically, STDP has the highest priority, followed by evolutionary strategies, then Heb learning, and finally surrogate gradients (a special case of backpropagation). This priority mechanism ensures that when multiple training methods exist simultaneously in the network, the training loop adopts an execution order compatible with all methods.

[0096] If the STDP method is detected, the multi-paradigm training coordinator invokes the STDP training procedure, which coordinates STDP and gradient training through a cumulative-delay application mechanism. If the evolutionary policy method is detected, the training coordinator invokes the evolutionary policy training procedure, which performs gradient-free optimization through population evaluation and selection-mutation operations. If the Heb learning method is detected, the training coordinator invokes the Heb learning training procedure. Otherwise (i.e., no impulse-time-dependent plasticity training method, evolutionary policy training method, or Heb learning training method is detected), the multi-paradigm training coordinator invokes the default surrogate gradient training procedure, which uses the standard backpropagation mechanism.

[0097] In some embodiments of this disclosure, the core of the surrogate gradient method is to replace the non-differentiable step portion of the impulse function with a smooth, differentiable function. The firing process of a spiking neuron can be represented as a step function. ,in The function is the Heaviside step function, whose derivative is zero at non-zero points and undefined at zero points, which makes it impossible for standard backpropagation to calculate gradients through the pulse layer.

[0098] This disclosure uses the ATan function as the default proxy function, and its derivative during backpropagation is defined as: in membrane potential With threshold The difference, This is a hyperparameter used to control the steepness of the gradient; a typical value is 2.0. A larger value... This makes the surrogate function closer to the real step function, with gradients concentrated near the threshold, but may cause gradient vanishing far from the threshold; smaller... Making the gradient distribution smoother is beneficial for gradient propagation, but it results in a larger approximation error.

[0099] The forward propagation of the ATan surrogate function still uses the real step function to generate discrete impulses, only using the derivative of the surrogate function during backpropagation. This design ensures the biological realism of the forward propagation while allowing the network to be trained using the standard gradient descent algorithm.

[0100] In addition to ATan, this disclosure also supports other surrogate function options, such as the Sigmoid surrogate function or the FastSigmoid surrogate function, which offer higher computational efficiency. Users can select the desired surrogate function type through configuration.

[0101] In some embodiments of this disclosure, the execution of the cumulative-delay application mechanism preferably includes steps S410 to S450, please refer to... Figure 4 .

[0102] In step S410, at the beginning of each training batch, the cumulative update buffer is initialized as a zero tensor with the same shape as the synaptic weight matrix of the spiking neural network part, and the presynaptic trace variable and postsynaptic trace variable are reset to zero.

[0103] In step S420, forward propagation time step iteration is performed. In each time step, based on the presynaptic pulse firing sequence and postsynaptic pulse firing sequence at the current time, and combined with the exponentially decaying trace variable, long-term enhancement update term and long-term suppression update term are calculated respectively. The difference between the long-term enhancement update term and the long-term suppression update term is accumulated as the weight update amount into the cumulative update buffer.

[0104] In step S430, after the forward propagation is completed, the loss function is calculated and backpropagation is performed to obtain the gradient values ​​of the parameters that need to be updated.

[0105] In step S440, the parameters of the artificial neural network are updated based on the gradient value.

[0106] In step S450, the accumulated weight update amount in the cumulative update buffer is multiplied by the learning rate and then added to the synaptic weight matrix, and weight boundary clipping is performed.

[0107] In this implementation, the core idea of ​​the cumulative-delayed application mechanism is to separate the weight update calculation and update application of STDP: only the update amount is calculated and accumulated during the forward propagation process, and the accumulated update is applied uniformly after the back propagation is completed.

[0108] The mathematical basis of the STDP learning rule is as follows. Suppose that the presynaptic neuron at time t... Firing impulses, postsynaptic neurons at time Pulse delivery, time difference The classic pairwise STDP rule defines the weight change as two parts: when... When the postsynaptic pulse lags behind the presynaptic pulse, indicating a causal relationship, the weight increases, a condition known as long-term enhancement, with an increment of [value missing]. ;when When the postsynaptic pulse precedes the presynaptic pulse, it indicates an inverse causal relationship, the weight decreases, and this is called long-term suppression, with an increment of [value missing]. .in and To learn the amplitude parameter, and It is a time constant, typically on the order of 20 milliseconds.

[0109] To efficiently compute STDP updates, this disclosure employs a synaptic trace-based implementation. A synaptic trace is an exponentially decaying local variable that records the history of recent impulse activity. Presynaptic trace It decays exponentially at each time step and increases upon arrival of the presynaptic pulse: ,in This represents the presynaptic pulse (0 or 1) at the current time step. Postsynaptic trace Similar definition. Based on synaptic traces, the STDP update amount at each time step can be calculated efficiently: the LTP term is... The LTD item is .

[0110] Preferably, the execution flow of the cumulative-delay application mechanism is as follows: At the start of each training batch, the STDP trainer resets the cumulative update buffer to a zero tensor with the same shape as the synaptic weight matrix of the spiking neural network part. Simultaneously, the presynaptic and postsynaptic traces are reset to zero.

[0111] Perform forward propagation. During forward propagation, each stage is executed sequentially according to the network execution plan. For SNN layers with STDP enabled, the following operations are performed at each time step: First, standard synaptic transmission and neuron dynamics calculations are performed; then, the synaptic traces are updated, incorporating the impulse information of the current time step into the trace variables. Next, the STDP update amount (i.e., the weight update amount) is calculated, but it is not applied to the weights; instead, it is accumulated in the cumulative update buffer. Finally, the next time step continues. The key is that the parameters in the synaptic weight matrix remain unchanged throughout the entire forward propagation process, ensuring the integrity of the computational graph.

[0112] Calculate the loss function. After forward propagation, calculate the loss value using the network output and labels. The loss function can be a standard loss function such as cross-entropy loss or mean squared error loss.

[0113] Perform backpropagation. Calling the `backward` method of the loss tensor triggers backpropagation, calculating the gradients of all trainable parameters. Since the weights were not modified during forward propagation, backpropagation correctly calculates the gradients. For the parts of the SNN layer that use surrogate gradients, the gradient of the impulse function is approximated by the surrogate function.

[0114] Update the parameters of the ANN part. Use the ANN optimizer to perform gradient descent updates on the parameters of the ANN part.

[0115] Apply STDP cumulative updates. Multiply the accumulated updates in the STDP trainer by the learning rate and add it to the corresponding SNN weight parameters. After applying the update, perform weight pruning to ensure that the weights remain within the configured boundaries.

[0116] Clear the gradient and prepare for the next batch.

[0117] Thus, this mechanism resolves the conflict between STDP and backpropagation. The integrity of the computational graph is guaranteed because the weights remain unchanged during forward propagation, and backpropagation can correctly track the computational history. The two update methods no longer interfere with each other; gradient updates and STDP updates are applied at different times. The training process is stable and controllable; the relative strength of the two learning signals can be controlled by adjusting the ratio of the STDP learning rate to the gradient learning rate.

[0118] In some embodiments of this disclosure, the difference between the long-term enhancement update term and the long-term suppression update term is accumulated as a weight update amount into the cumulative update buffer. Preferably, this includes steps S510 to S530. Please refer to [link / reference needed]. Figure 5 .

[0119] In step S510, the long-term enhancement scaling factor and the long-term suppression scaling factor are determined based on the current synaptic weight matrix value, the preset upper weight threshold, and the lower weight threshold.

[0120] In step S520, the long-term enhancement update term is multiplied element-wise by the long-term enhancement scaling factor, and the long-term suppression update term is multiplied element-wise by the long-term suppression scaling factor to achieve a scaling of the update amount that smoothly decays as the weight approaches the boundary.

[0121] In step S530, the difference between the scaled long-term enhancement update term and the long-term suppression update term is accumulated as a weight update amount in the cumulative update buffer.

[0122] In this implementation, traditional STDP implementations use hard boundary constraints after weight updates, that is, they directly prune the weights to... Within the interval, where, This is the lower limit threshold for the weight. This represents the upper limit threshold for weights. Hard boundary constraints present a learning stagnation problem: when weights approach the boundary, the update amount calculated by STDP may be completely truncated, causing the synapse to be unable to continue learning.

[0123] To address this, this disclosure proposes a soft boundary constraint mechanism that dynamically scales the update amount based on the distance between the weights and the boundaries (i.e., the upper and lower weight thresholds). Specifically, for long-term augmentation updates, the long-term augmentation scaling factor is... , This represents the current synaptic weight matrix values. The scaling factor approaches 0 when the weights are close to the upper bound and approaches 1 when the weights are close to the lower bound. For long-term suppression updates, the long-term suppression scaling factor is... When the weights are close to the lower bound, the scaling factor approaches 0; when the weights are close to the upper bound, the scaling factor approaches 1.

[0124] Therefore, through the soft boundary constraint mechanism, the closer the weights are to the boundary, the smaller the updates in the same direction, but without complete truncation. This allows the synapse to maintain its learning ability throughout the entire weight range, while naturally constraining the weights within a reasonable range and avoiding divergence.

[0125] In some embodiments of this disclosure, the multi-paradigm unified execution and training scheduling method for heterogeneous neural networks preferably further includes an execution reward modulation pulse time-dependent plasticity training mechanism, wherein the reward modulation pulse time-dependent plasticity training mechanism preferably includes steps S610 to S630. Please refer to [link / reference]. Figure 6 .

[0126] In step S610, after each training batch completes forward propagation, the classification accuracy of the current batch of samples is calculated based on the network output and the real labels, and the dynamic baseline accuracy is determined based on the total number of task categories, wherein the dynamic baseline accuracy is the reciprocal of the total number of task categories.

[0127] In step S620, the classification accuracy and the dynamic benchmark accuracy are compared, and the corresponding reward modulation signal is determined based on the comparison result.

[0128] In step S630, the weight update amount accumulated in the cumulative update buffer is multiplied by the reward modulation signal and then applied to the weight parameters corresponding to the spiking neural network part.

[0129] In this implementation, the standard STDP is an unsupervised learning rule whose learning direction is determined by the local impulse timing and may not necessarily align with the task objective. To combine the local learning of STDP with the task objective, this disclosure proposes a reward-modulated STDP mechanism. The core idea of ​​reward modulation is to dynamically adjust the intensity and direction of STDP updates based on task performance.

[0130] Specifically, a dynamic baseline strategy is used to calculate the reward signal. Let the classification accuracy of the current batch be... The total number of task categories is Dynamic benchmark accuracy That is, the expected accuracy of random guessing. Preferably, the reward modulation signal. The calculation rules are as follows: When When the network performs better than random guessing, a positive reward is given. Strengthen current learning direction; when When this occurs, it indicates that the network performance is significantly worse than random guessing, and a negative reward is given, such as... In other cases, a neutral reward is given, such as reversing the learning direction. Maintain standard STDP learning.

[0131] The advantage of the dynamic baseline strategy lies in its adaptability. The accuracy of the dynamic baseline is automatically adjusted according to the number of task categories. For binary classification tasks, the baseline is 50%, and for ten-category tasks, the baseline is 10%. This allows the reward modulation mechanism to adapt to tasks of varying difficulty.

[0132] Furthermore, to address the issue of drastic fluctuations in single-batch accuracy caused by random network initialization in the early stages of training (e.g., extremely low single-batch accuracy in a 100-class classification task, leading to frequent triggering of negative rewards for errors), this disclosure extends the dynamic benchmark strategy in two ways: First, it supports a moving average benchmark mode based on a historical sliding window, thereby increasing the dynamic benchmark accuracy... First, the accuracy is smoothly updated to the average of the most recent batches; second, a reward modulation warm-up mechanism is introduced, which forces the application of neutral rewards (such as...) during a set warm-up period. To maintain pure STDP feature extraction, full-amplitude positive and negative reward modulation is smoothly introduced after the network feature expression has initially stabilized.

[0133] The reward modulation signal is applied to STDP updates by multiplying the accumulated weight update amount by the reward modulation signal and then applying it to the corresponding weight. When the reward modulation signal is positive, the correct synaptic connection pattern is enhanced, and when the reward modulation signal is negative, the incorrect connection pattern is weakened or reversed.

[0134] Thus, unsupervised STDP learning was successfully combined with supervised task objectives, enabling STDP, which originally relied solely on local impulse time-series information, to evolve towards improving classification accuracy.

[0135] In some embodiments of this disclosure, the multi-paradigm unified execution and training scheduling method for heterogeneous neural networks also supports Hebbian learning. Hebbian learning, as another local learning paradigm, is based on the principle of establishing stronger connections through simultaneously activated neurons, and its basic form is... ,in Indicates from the first The input neuron or input channel to the first Synaptic weights between output neurons or output channels; This indicates the amount of change in the synaptic weight during a single learning update; Indicates the learning rate; Indicates the first A presynaptic input activity value; Indicates the first Each synapse outputs an activity value. However, this basic form leads to an infinite growth of weights, therefore this disclosure uses the Oja rule for weight normalization: in, Represents the input activity vector The Middle One input component, Indicates the output activity vector The Middle Each output component Represents the weight matrix The Middle Line number Column weight parameters, This indicates the update amount of the corresponding weight parameter. This represents the learning rate that controls the update step size. In the formula, This is an enhancement term based on the correlation between presynaptic and postsynaptic activities. This is a weight normalization suppression term, used to limit the continuous increase of weights.

[0136] The Oja rule can be proven to make the weight vector converge to the direction of the principal eigenvectors of the input data covariance matrix, achieving a dimensionality reduction effect similar to principal component analysis. This property makes Heb learning particularly suitable for unsupervised pre-training of feature extraction layers.

[0137] For efficient implementation of batch data, let's assume... The input activation matrix has the following shape: ;set up The output activation matrix has the following shape: ;set up The weight matrix has the following shape: .in, This indicates the number of samples in the current training batch. This indicates the input dimension or the number of input neurons. This represents the output dimension or the number of output neurons. The update formula for batch Oja rules is then: in, Represents the weight matrix Batch update volume; Indicates the learning rate; Represents the activation matrix of the input Activate the input mean obtained by averaging across the batch dimension; This indicates the output activation matrix. The output mean activation is obtained by averaging the values ​​over the batch dimension; express Transpose of; The correlation term representing the average activity before and after synapse; This indicates the autocorrelation terms of the output activity; This represents the operation of constructing a diagonal matrix from the diagonal elements of a vector or matrix; This represents the normalization suppression term associated with the current weights. Further processing is required after the update. Normalization is used to maintain the unit length of the weight vector, ensuring learning stability. The normalization formula is: in, This represents the normalized weight matrix. This represents the weight matrix before normalization. Represents the weight matrix The L2 norm is calculated along the input dimension.

[0138] The Hebbian learning training process is similar to the STDP training process, also employing a cumulative-delay application mechanism in conjunction with backpropagation. The difference lies in that the Hebbian learning training process calculates based on activation values ​​rather than impulses, making it more suitable for layers in heterogeneous neural networks that fall between pure ANNs and pure SNNs, or for pre-training weights in SNN layers. Users can configure which layers use Hebbian learning, while the remaining layers use backpropagation for supervised training.

[0139] In some embodiments of this disclosure, for scenarios where training using gradient methods is difficult, this disclosure supports an evolutionary strategy training process as an alternative training method. An evolutionary strategy is a gradient-free optimization method that iteratively optimizes network parameters by maintaining a parameter population, evaluating fitness, and performing selection and mutation. This method is particularly suitable for scenarios where the loss function is non-differentiable or the gradient signal is weak.

[0140] Preferably, this disclosure achieves Evolutionary strategy, where the population size is Preserved in each generation An elite individual. The specific process is as follows: The first step is to initialize the population. The first individual uses the current network parameters. ,the remaining Each individual is generated by adding Gaussian random perturbations to the basic parameters, i.e. ,in For the intensity of variation, It follows a standard normal distribution. The parameters of each individual are stored using a deep copy, ensuring complete independence between individuals in the population.

[0141] The second step is fitness assessment. For each individual... The parameters are loaded into the model, forward propagation is performed on a subset of the training data, and performance metrics (such as classification accuracy) are calculated as the fitness of that individual. Fitness evaluation is performed in gradient-free mode to improve computational efficiency.

[0142] The third step is selection. The population is sorted in descending order of fitness, and the optimal population is selected. Each individual serves as the parent generation. Calculated using the elite ratio parameter, i.e. ,in This represents the total number of individuals in the current population. This indicates the percentage of elite individuals retained. Elite retention strategies ensure that the genes of the best individuals are not lost.

[0143] The fourth step is reproduction. New individuals are produced from the parents to populate the population. The reproduction process includes two operations: crossover and mutation. The crossover operation randomly selects two parents. and Each parameter tensor of the new individual is selected from [a specific source] with a probability of 0.5. or This achieves uniform crossover at the parameter level. The mutation operation adds Gaussian noise to the parameters of the new individual, i.e. Mutations are expressed as probabilities occur.

[0144] The fifth step is population update. The parent generation and newly generated offspring are merged, and the best offspring are retained based on their fitness. Individuals form a new population.

[0145] Repeat steps two through five until the maximum number of generations is reached or the fitness converges. After training, load the parameters of the optimal individual into the model as the final result.

[0146] Key parameters of the evolutionary strategy include population size (default 20), mutation rate (default 0.1), mutation scale (default 0.02), and elite ratio (default 0.2). This invention provides reasonable default values ​​for these parameters and allows users to adjust them through configuration.

[0147] To avoid memory leaks, the evolutionary strategy explicitly releases the parameter tensors of eliminated individuals during each generation's population update. Furthermore, the fitness evaluation process uses the `torch.no_grad()` context manager to disable gradient computation and reduce memory consumption.

[0148] In some embodiments of this disclosure, this disclosure supports a multi-stage training strategy, allowing users to define multiple consecutive training stages for the same network, each training stage using different training configurations. This mechanism supports complex training strategies, such as "STDP pre-training + supervised fine-tuning" or "layer-by-layer greedy training".

[0149] Specifically, the multi-stage training configuration adopts a stage list structure, with each stage containing the following fields: stage number (stage), used to identify the stage order; subnetwork_config, which specifies the training method and parameters for each subnetwork; training parameters (epochs, batch_size, time_steps, etc.), which control the training scale of the stage; and an optional stage end callback function, used to perform special processing between stages.

[0150] During multi-stage training, the runtime system executes the training process for each stage sequentially. At the start of each stage, the model parameters from the previous stage are loaded as the initial state, and at the end of the stage, a checkpoint is saved. Parameter passing between stages ensures the continuity of training.

[0151] This allows for the support of the following typical training strategies: The first strategy is STDP pre-training followed by supervised fine-tuning. In the first stage, STDP is used to perform unsupervised feature learning on the SNN part. STDP can automatically form meaningful feature representations based on the statistical characteristics of the input data. In the second stage, the weights of the SNN feature layer are frozen, and surrogate gradients are used to perform supervised training on the output layer, mapping the unsupervised learned features to the task objective.

[0152] The second strategy is layer-by-layer training. Starting from the input layer, each layer is trained sequentially, unfreezing only the parameters of the current layer at a time while freezing the parameters of the remaining layers. This strategy avoids the gradient problem in deep networks and gradually builds the network's representational capabilities.

[0153] The third strategy is lesson learning. The first stage uses simple samples for training, allowing the network to learn basic classification boundaries. Subsequent stages gradually introduce difficult samples, enabling the network to master more complex patterns. Lesson learning can be achieved by using different subsets of data at different stages.

[0154] In some embodiments of this disclosure, since ANN layers and SNN layers in heterogeneous neural networks have different computational characteristics, different implementation strategies are required. Preferably, the network layer module design of the runtime system of this disclosure is as follows: For the ANN part, the runtime system directly reuses the standard layer implementations provided by deep learning frameworks such as PyTorch, including convolutional layers (Conv2d), fully connected layers (Linear), batch normalization layers (BatchNorm), pooling layers (MaxPool2d, AvgPool2d), and activation function layers (ReLU, Sigmoid, etc.). These standard layers have been highly optimized, supporting GPU acceleration and automatic differentiation, and do not need to be reimplemented.

[0155] Therefore, it fully leverages the optimization results of mature frameworks to ensure the computational efficiency of the ANN part; it is seamlessly compatible with the deep learning ecosystem, allowing users to directly use pre-trained models; and it simplifies implementation complexity, with the runtime system focusing only on the runtime characteristics unique to SNNs.

[0156] In hybrid networks, the output of the ANN layer is passed to the SNN layer through a boundary transformation module, and the gradient is backpropagated through a pass-through estimator. The forward and backward propagation of the ANN layer itself follows the standard deep learning process.

[0157] In addition, the runtime system provides two SNN fully connected layer implementations, each suitable for different training modes.

[0158] The base SNN fully connected layer (SNNLinear) is used for surrogate gradient training. This layer contains two components: a standard PyTorch linear layer (nn.Linear) responsible for synaptic transmission, and a neuron model responsible for membrane potential dynamics and impulse firing. During forward propagation, the input is first weighted and summed through the linear layer, then fed into the neuron model to update the membrane potential and determine impulse firing. The neuron model is created using a factory function and supports four types: LIF, IF, Izhikevich, and AdEx. The surrogate gradient is implemented through a pass-through estimator within the neuron model, allowing the gradient to propagate backward through the impulse layer.

[0159] Fully Connected Layer with STDP (STDPLinearLayer): Used for STDP training mode. This layer integrates an STDP learner on top of the basic SNN fully connected layer. Its components include: a linear layer (without bias, facilitating STDP updates), a neuron model, an STDP learner instance, and an accumulated update buffer. During forward propagation, in addition to performing standard synaptic transmission and neuron dynamics calculations, the STDP learner is invoked to calculate the weight updates for the current time step and accumulate them in the accumulated buffer. The key design is that the weights remain unchanged during forward propagation, and the accumulated updates are applied all at once through the `apply_stdp_updates` method after the entire forward propagation is completed. This cumulative-delayed application mechanism ensures compatibility between STDP and backpropagation.

[0160] The weights of STDPLinearLayer are initialized using a uniform distribution. This ensures that the weights are within the effective range of STDP learning, avoiding sparse impulses due to excessively small initial weights or over-firing due to excessively large initial weights. This layer provides the `enable_stdp` method to control the enabling and disabling of STDP learning, facilitating switching between training and inference phases.

[0161] In some embodiments of this disclosure, the runtime system provides a unified interface for creating various neuron models through a neuron factory function (create_neuron). The factory function receives the neuron type name and parameter configuration, and returns the corresponding neuron module instance.

[0162] The neuron type mapping table supports case-insensitive lookups; for example, "LIF" and "lif" both map to LIF neuron implementations. When the SpikingJelly framework is available, the factory function preferentially uses the optimized implementation provided by SpikingJelly; when SpikingJelly is unavailable, it falls back to the simplified implementation built into the runtime system (SimpleLIFNode, SimpleIFNode, SimpleIzhikevichNode, SimpleAdExNode).

[0163] Common features of built-in neuron implementations include: membrane potential state is maintained between time steps and gradient map is truncated at each time step using a detach operation to avoid gradient accumulation between time steps; pulse firing is implemented using a pass-through estimator, forward propagation uses hard thresholding to generate discrete pulses, and backpropagation uses gradient approximation of the sigmoid function; membrane potential reset is conditional reset, and the reset operation is performed only on neurons that fire pulses.

[0164] Preferably, the runtime system provides three hybrid network container classes for assembling ANN layers, SNN layers, and boundary transformation layers to form a complete executable network.

[0165] HybridNet, a general-purpose hybrid network container, is the most commonly used hybrid network architecture. This container divides the network into three parts: an ANN encoder, a boundary transformation module, and an SNN classifier. During forward propagation, the input first extracts features through the ANN encoder, then the boundary transformation module converts continuous features into a pulse sequence, and finally, the SNN classifier performs iterative processing over time steps. The container automatically calculates the ANN output dimension; when the ANN output dimension does not match the SNN input dimension, it automatically inserts a dimension-adapting layer (a linear layer with ReLU activation). The container provides the `get_ann_parameters` and `get_snn_parameters` methods, supporting a separate optimizer mechanism.

[0166] HybridSandwichNet is a container specifically designed for handling ANN-SNN-ANN three-layer structures. This structure adds an ANN decoder to HybridNet; the pulse output of the SNN is converted back to continuous values ​​through decoding before being fed into the ANN decoder. The container supports multiple decoding methods, including pulse counting and membrane potential readout. The sandwich structure is suitable for scenarios that require processing temporal features using SNNs while simultaneously requiring post-processing by ANNs.

[0167] HybridParallelNet: This container supports the parallel execution of multiple processing branches. It allows the same input to be fed into multiple ANN or SNN branches simultaneously, with each branch processing independently and then fusing the outputs. Fusion methods include concatenation and summation. The parallel branch structure is suitable for scenarios requiring feature extraction from different perspectives, such as one branch extracting spatial features and another extracting temporal features.

[0168] All hybrid network containers implement a unified state management interface. At the start of each training batch, the container is responsible for resetting the membrane potential states of all SNN neurons and the synaptic traces of the STDP learner. The container also provides methods such as `enable_stdp` and `reset_stdp_accumulators` to support control over STDP training modes.

[0169] In some embodiments of this disclosure, the boundary transformation actuator implements various pulse coding strategies to convert the continuous-value tensors output by the ANN into pulse sequences that can be processed by the SNN. Each coding method has different characteristics and is suitable for different application scenarios.

[0170] The first method is rate encoding. Rate encoding maps continuous values ​​to pulse firing probabilities, and then generates a pulse sequence through Bernoulli sampling. In its implementation, the sigmoid function and scaling operation are first applied to the ANN output to calculate the firing probability. ,in This is an adjustable scaling factor, with a default value of 1.0. The sigmoid function maps any real number to... The interval is naturally interpreted as a probability. Then, Bernoulli sampling is performed independently at each time step to generate discrete impulses. To support gradient backpropagation, the sampling operation is implemented using a pass-through estimator (STE). Rate coding has the advantages of being simple to implement and corresponding to the firing rate concept in neuroscience; its disadvantages include the introduction of noise due to randomness and the need for a sufficient number of time steps to accurately transmit information.

[0171] The second method is direct encoding. Direct encoding maps continuous values ​​to the [0,1] interval using the sigmoid function, and then repeatedly feeds them into the SNN at each time step. In implementation, the input first undergoes a sigmoid transformation, then is expanded by a time dimension and copied. This process generates an input sequence of shape [T, B, N], where... For time steps, For batch size, The number of neurons is denoted by . Direct encoding has the advantages of strong determinism, no sampling noise, and high computational efficiency, making it suitable for applications requiring deterministic behavior.

[0172] In some embodiments of this disclosure, pulse coding involves discretization operations, which are Bernoulli sampling in rate coding and threshold comparisons in the direct coding-to-pulse transformation. The gradients of these discretization operations are mathematically zero or undefined, which can block the gradient flow during backpropagation. To support end-to-end training, the boundary transformation actuator implements the Straight-Through Estimator (STE) technique.

[0173] The core idea of ​​the pass-through estimator is: forward propagation performs the actual discretization operation to maintain the correctness of the network behavior, while backpropagation bypasses the discretization operation and directly transmits the gradient to maintain the connectivity of the gradient flow.

[0174] The mathematical expression of STE is as follows. Let... The probability of distribution (continuous value). Uniformly distributed random numbers, The sampled pulses (discrete values, 0 or 1). Forward propagation performs discrete sampling, i.e. ,in The indicator function. Backpropagation uses an approximate gradient, i.e. The gradient of the pulse with respect to the input is approximated as an identity mapping.

[0175] In the code implementation, STE is implemented in the following way: Based on the above expression: during forward propagation, The value is equal to ,because return The value is not included in the gradient calculation. Similarly, and Numerically Cancel out. During backpropagation, and No gradient contribution, only the last one. It participates in gradient calculation, therefore .

[0176] This STE implementation makes the boundary transformation gradient-penetrating, and the parameters of the ANN part can receive gradient signals from the SNN part, thereby achieving end-to-end joint optimization.

[0177] The STE implementation ensures compatibility between STE and the STDP accumulation-delay application mechanism. Gradients can be correctly propagated to the ANN part through the boundary without affecting the STDP pulse timing learning in the SNN part. The two learning signals are correctly split at the boundary: the gradient signal propagates towards the ANN, while the pulse timing signal is used for STDP calculation inside the SNN.

[0178] Preferably, this disclosure also proposes a "computation graph decoupling and gradient penetration" mechanism. When a certain SNN layer in a heterogeneous neural network is configured in STDP training mode, this layer is still forcibly bound to a surrogate gradient function during the backpropagation stage. During loss backpropagation, the surrogate gradient of the STDP layer is only used as a "wire" to calculate the gradient and pass it to the upstream ANN encoder or predecessor layer, and is absolutely not used to update the synaptic weights of the STDP layer itself. The weight update of the STDP layer itself strictly depends on the increment accumulated based on the pulse timing (the real discrete pulses of the STE forward propagation) during forward propagation. This design enables the error signal to penetrate the SNN layer performing unsupervised local learning without loss in end-to-end joint training, solving the topological blocking problem between local plasticity and global gradient optimization.

[0179] In some embodiments of this disclosure, at the boundary between the SNN and ANN, or at the network output, the impulse decoder converts the impulse output of the SNN into a continuous-value tensor for use by subsequent ANN layers or loss functions.

[0180] The first decoding method is spike counting. It counts the cumulative number of spikes for each neuron across all time steps and uses this as the continuous output value. In implementation, the spike tensor of shape [T, B, N] is summed along the time dimension to obtain the output tensor of shape [B, N]. Spike counting is the simplest and most commonly used decoding method, preserving the emission intensity information but losing temporal information.

[0181] The second decoding method is temporal averaging. It calculates the average firing rate of each neuron, which is the total number of pulses divided by the number of time steps. In implementation, this is done by dividing the pulse count by the number of time steps. The output of time-averaged decoding is independent of the number of time steps, which facilitates comparison between different time step configurations, and the output value is naturally normalized to the [0,1] interval.

[0182] The third decoding method is membrane potential readout. It directly uses the membrane potential value from the last time step as the output, without pulse counting. In implementation, it takes a slice of the membrane potential tensor maintained by the neuron's state manager at the last time step. Membrane potential readout retains more continuous value information and avoids the information loss caused by pulse quantization, but it may be affected by the randomness of the state at the last moment.

[0183] The decoder selection can be specified in the intermediate network configuration; pulse counting decoding is used by default. Different decoding methods have different impacts on network performance, and users can select and optimize them according to specific tasks.

[0184] In some embodiments of this disclosure, the neuron state manager is responsible for maintaining the internal state of SNN neurons and supports multiple neuron models. Different neuron models have different dynamic equations, sets of state variables, and parameter configurations. Preferably, the neuron state manager implements runtime support for the following four commonly used neuron models.

[0185] The first type is the LIF neuron (Leaky Integrate-and-Fire). LIF is the most commonly used spiking neuron model, and its continuous-time dynamic equation is: ,in The membrane time constant is This is the resting potential. For membrane resistance, The input current is used. The compiler discretizes it into difference equations. When the membrane potential Exceeding the threshold At this time, the neuron fires a pulse, and the membrane potential is reset to [value missing]. The state variables of LIF neurons include only membrane potential. Typical parameter values ​​are , , .

[0186] The second type is the IF neuron (Integrate-and-Fire). The IF neuron is a simplified version of the LIF, without leakage terms, and its membrane potential dynamics are as follows: Discretization IF neurons maintain a constant membrane potential even without input, making them suitable for studying purely integral behavior. The state variables of IF neurons also consist solely of membrane potential. .

[0187] The third type is the Izhikevich neuron. The Izhikevich neuron is a bivariate model capable of reproducing the firing patterns of various biological neurons, achieving a good balance between computational efficiency and biological realism. Its dynamic equation is: in For membrane potential, To restore the variable, , Parameters for controlling the recovery kinetics. When Time neurons fire impulses, after firing Reset to parameters (Typical value -65mV) Add parameters (Typical value 8). Adjust the parameters... , , , Izhikevich neurons can reproduce various firing patterns of biological neurons, including regular firing, rapid firing, cluster firing, and delayed firing. The state variables of Izhikevich neurons include... and two.

[0188] The fourth type is the AdEx neuron (Adaptive Exponential Integrate-and-Fire). AdEx neurons add an exponential current term and adaptive current to the LIF (Limited-Intensity Fiber) neuron, enabling them to more accurately simulate the subthreshold behavior and adaptive characteristics of biological neurons. Its kinetic equation is: in For film capacitors, For leakage conductivity, This is the leakage reversal potential. Threshold slope factor, Threshold potential, To adapt to the current, To adapt to the time constant, This is the subthreshold adaptation parameter. When When the cutoff potential is exceeded, the neuron fires a pulse. Reset to , Add parameters The state variables of AdEx neurons include and .

[0189] In some embodiments of this disclosure, the multi-paradigm unified execution and training scheduling method for heterogeneous neural networks further includes an execution neuron state management mechanism, which preferably includes steps S710 to S740. Please refer to [link / reference needed]. Figure 7 .

[0190] In step S710, for each spiking neural network stage, a state tensor is maintained for each spiking neuron model therein, the state tensor including the membrane potential tensor.

[0191] In step S720, before the spiking neural network stage begins execution, the state tensor is allocated according to the batch size and the number of neurons, and initialized to the initial values ​​defined by the spiking neuron model.

[0192] In step S730, during the forward propagation at each time step, a new state value is calculated based on the current input current and the discretized dynamic equation of the spiking neuron model. After the calculation is completed, a gradient cutoff operation is performed on the new state value to disconnect the gradient connection between it and the old state value.

[0193] In step S740, for a spiking neuron model that has pulse firing, a corresponding reset strategy is executed on the state value of the spiking neuron model.

[0194] In this implementation, the neuron state manager provides complete state lifecycle management functions, including three stages: initialization, update, and reset.

[0195] State initialization occurs at the start of processing each batch. The neuron state manager allocates state tensors based on the batch size and the number of neurons. The state tensors have a shape of [B, N], where... For batch size, This represents the number of neurons. The state tensor is initialized to the initial values ​​defined in the model. For LIF and IF neurons, the membrane potential is initialized to the resting potential. Or zero. For Izhikevich neurons, Initialized to -65mV (typical resting potential). Initialize to For AdEx neurons, Initialized to leakage potential , Initialize to zero. The state tensor is assigned to the same computational device as the model parameters.

[0196] State updates occur during the forward propagation at each time step. The neuron state manager calculates the new state value based on the discretized dynamic equations of the neuron model. The inputs to the state update include the current state, input current, and model parameters, and the output is the updated state. To avoid gradient accumulation between time steps, a detach strategy (i.e., gradient truncation strategy) is used for state updates: after the new state value is calculated, a gradient truncation operation is performed, severing the gradient connection with the old state value. This ensures that gradient calculations at each time step are relatively independent, avoiding the gradient vanishing or exploding problems caused by backpropagation through time, while maintaining the validity of the surrogate gradient within a single time step.

[0197] State reset occurs after the neuron fires a pulse. The neuron state manager updates the state according to the reset rules of the neuron model. For hard reset models (which can be specified in the reset logic), the membrane potential is directly set to... For the soft reset model, the membrane potential is subtracted from the threshold. The portion exceeding the threshold is retained. The reset operation is implemented through a masking mechanism: generating and issuing masks. Then execute (Hard reset) or (Soft reset). The reset operation also uses the detach strategy to ensure stable gradient propagation.

[0198] In some embodiments of this disclosure, in addition to neuron states, the neuron state manager is also responsible for maintaining the synaptic traces required for STDP. Presynaptic traces Records the pulse history of presynaptic neurons, postsynaptic trace Record the pulse history of postsynaptic neurons. Both types of synaptic traces decay exponentially at each time step and increase when the corresponding neuron fires a pulse.

[0199] Preferably, the update equation for the synaptic trace is: ,in As the attenuation factor, For time constant (previous trace used) , traces used ), The pulse (0 or 1) represents the current time step. This update equation causes the trace variable to decay exponentially, with the most recent pulse contributing the most and earlier pulses contributing less, which aligns with the temporal characteristics of the STDP learning window.

[0200] Synaptic trace updates are implemented using efficient tensor operations, supporting batch computation and GPU acceleration. In the implementation, the decay factor... During state manager initialization, the values ​​are pre-calculated based on the time constant and cached on the current device using the register_buffer mechanism to avoid redundant calculations and device transitions during time step iterations. When the model migrates to a different device (e.g., from CPU to GPU), the cached tensors automatically migrate along with the model.

[0201] The shape of the synaptic trace tensor depends on the scale of the synaptic connections. For fully connected layers, the shape of the foretrace is... The shape of the trace is ,in and These represent the number of neurons before and after the synapse. The synaptic trace is reset to zero at the start of each new batch, and the pulse history is accumulated during the time step iterations within the batch.

[0202] In some embodiments of this disclosure, to support unified management and dynamic creation of multiple neuron models, the multi-paradigm unified execution and training scheduling method for heterogeneous neural networks also includes a neuron type factory mechanism. The neuron type factory dynamically creates corresponding neuron model instances based on the neuron type name specified in the configuration. This design decouples the configuration and implementation of neuron types, allowing users to switch between different neuron models through simple string configuration.

[0203] Specifically, the neuron type factory maintains a registry mapping type names to implementation classes. To improve configuration flexibility and fault tolerance, the registry supports case-insensitive mappings: LIF and lif both map to the LIF neuron implementation class; IF and lif both map to the IF neuron implementation class; Izhikevich and izhikevich both map to the Izhikevich neuron implementation class; and AdEx, adex, and ADEX all map to the AdEx neuron implementation class.

[0204] The neuron creation interface receives the neuron type name and parameter configuration, searches for the corresponding implementation class in the registry, instantiates a neuron object using the configuration parameters, and returns it. If the type name is not found in the registry, the neuron type factory returns a default LIF neuron and prints a warning message. This fault-tolerant design ensures that the system can still run even with incorrect configuration, facilitating debugging and development.

[0205] The neuron type factory also handles compatibility between different SNN frameworks. When the system detects that the SpikingJelly framework is available, it prioritizes using the highly optimized neuron implementations provided by SpikingJelly, which typically include CUDA acceleration and memory optimizations. When SpikingJelly is unavailable, it automatically falls back to the simplified neuron implementation provided by this invention, ensuring that the runtime system can operate normally in various environments.

[0206] In some embodiments of this disclosure, the multi-paradigm unified execution and training scheduling method for heterogeneous neural networks further includes an execution separation optimizer management mechanism, which preferably includes steps S810 to S840. Please refer to [link to relevant documentation]. Figure 8 .

[0207] In step S810, based on the training method configuration of each sub-network, the sub-network that needs to be trained by gradient based on backpropagation, as well as the optimizer type and learning rate parameter corresponding to that sub-network, are identified.

[0208] In step S820, for each subnetwork that needs to be trained by gradients, all trainable parameters contained in the subnetwork are collected and formed into a parameter set.

[0209] In step S830, based on the optimizer type and the learning rate parameter, an independent optimizer instance is created for each parameter group, and a mapping relationship is established between the sub-network identifier and the optimizer instance.

[0210] In step S840, in each training iteration, after performing backpropagation to calculate the gradients of all parameters, the mapping relationship is traversed, and the parameter update method of each optimizer instance is called in turn to update their respective parameter groups.

[0211] In this implementation, the adaptive optimization controller in the runtime system supports configuring independent optimizers for different parts of the heterogeneous neural network, enabling differentiated learning rates and optimization strategies.

[0212] Specifically, in the separate optimizer management mechanism, optimizer instances are created for the ANN and SNN parts respectively, based on the training method configuration of the sub-networks. The ANN optimizer manages the parameters of the ANN layers, including convolutional layer weights, fully connected layer weights, batch normalization parameters, etc. The SNN optimizer manages the parameters of the SNN layers, primarily synaptic weights. The two optimizers can use different learning rates, different optimization algorithms, and different learning rate scheduling strategies.

[0213] Preferably, when creating the separate optimizer, the adaptive optimization controller iterates through the training method configurations of each sub-network, identifies the sub-networks requiring gradient training, and their optimizer configurations. The optimizer configuration includes the optimizer type (e.g., Adam, SGD, AdamW, etc.) and the learning rate. Then, for each sub-network requiring gradient training based on backpropagation, the adaptive optimization controller collects all trainable parameters of that sub-network and forms a parameter set. Based on the configured optimizer type and hyperparameters (e.g., learning rate), an independent optimizer instance is created for that parameter set. Finally, the adaptive optimization controller maintains the mapping relationship between sub-network identifiers and optimizer instances for parameter update scheduling during training.

[0214] In each training iteration, after backpropagation is performed to calculate the gradients of all parameters, the adaptive optimization controller traverses the mapping relationship and calls the parameter update method of each optimizer instance in turn to update their respective parameter groups.

[0215] Specifically, the split optimizer management mechanism works collaboratively during training as follows: First, the loss value is calculated after forward propagation. Second, the ANN optimizer executes `zero_grad` to clear the gradient buffer of the ANN parameters. Third, the SNN optimizer executes `zero_grad` to clear the gradient buffer of the SNN parameters. Fourth, backpropagation is performed to calculate the gradients of all parameters. Fifth, the ANN optimizer executes the `step` method, updating the ANN parameters using the calculated gradients. Sixth, the SNN optimizer executes the `step` method to update the SNN parameters (if using surrogate gradient training), or applies STDP for cumulative updates (if using STDP training).

[0216] This allows users to select the most suitable optimization configuration based on the characteristics of each part of the network. For example, a small learning rate (such as 0.0001) can be used to fine-tune a pre-trained ANN encoder to preserve learned features, while a large learning rate (such as 0.01) can be used to quickly learn and adapt to new tasks for a newly added SNN classifier.

[0217] In some embodiments of this disclosure, the adaptive optimization controller also supports freezing specified network layers, keeping their parameters unchanged during training. Preferably, the freezing function is implemented by setting the required_grad attribute of the specified layer to False; frozen layers do not participate in gradient calculations and are not updated by the optimizer.

[0218] Furthermore, the freeze configuration supports the gradient flow option (gradient_flow). When gradient_flow is set to False (the default), the gradient stops propagating at the frozen layer and does not continue forward. When gradient_flow is set to True, the gradient can continue to propagate backward through the frozen layer to the preceding trainable layers, and the parameters of the frozen layer itself are not updated. This design supports more flexible training strategies, such as freezing intermediate layers but still allowing gradients to propagate to earlier layers at the input.

[0219] The freeze function is particularly useful in the following scenarios. The first is transfer learning: using a pre-trained ANN encoder to extract features, freezing its parameters, and training only the newly added SNN classifier. The second is staged training: training a portion of the network to converge, freezing it, and then training the remaining parts. The third is ablation experiments: freezing specific layers to study their impact on network performance.

[0220] In some embodiments of this disclosure, the adaptive optimization controller also manages learning rate scheduling during the training process. The adaptive optimization controller supports various learning rate scheduling strategies, including fixed learning rate, step decay, cosine annealing, and warm-up linear decay.

[0221] For the separate optimizer mechanism, learning rate scheduling can be configured independently for different sub-networks. For example, the ANN part uses cosine annealing scheduling, where the learning rate smoothly decreases from its initial value to near zero; the SNN part uses a fixed learning rate to maintain a stable learning speed. After each training cycle or batch, the controller updates the learning rate of each optimizer according to its respective scheduling strategy.

[0222] The adaptive optimization controller also supports scheduling of the STDP learning rate. The scheduling of the STDP learning rate is independent of the gradient learning rate and can be customized according to the characteristics of STDP learning. For example, a larger STDP learning rate (e.g., 0.01) can be used in the early stages of training to promote rapid feature formation, and then gradually reduced (e.g., reduced to 0.001) in the later stages to stabilize the learned synaptic connection patterns.

[0223] In some embodiments of this disclosure, the adaptive optimization controller also provides monitoring and early stopping mechanisms for the training process. At the end of each training cycle, the controller calculates and records metrics such as training loss, training accuracy, validation loss, and validation accuracy. These metrics are saved to the training history for analysis of the training process and model selection.

[0224] The early stopping mechanism determines whether to terminate training prematurely based on the changing trend of the validation metric. The controller maintains the optimal validation accuracy and its corresponding model parameter checkpoints. When the validation accuracy no longer improves within a certain number of consecutive epochs (controlled by the patience parameter, which defaults to 5 epochs), the controller determines that the training has converged or begun to overfit, terminates the training early, and restores the optimal model parameters as the final result.

[0225] After training is complete, the controller automatically saves the training information to a file, including the training timestamp, training method used, number of training epochs, best epoch number, best accuracy, and detailed metric sequences for each epoch. This information facilitates subsequent model analysis, comparison, and reproduction.

[0226] In a specific application scenario, based on the multi-paradigm unified execution and training scheduling method for heterogeneous neural networks provided in this disclosure, it is assumed that a user constructs an ANN-SNN hybrid network for image classification tasks. The ANN part is a CNN encoder, containing convolutional layers and pooling layers, responsible for extracting spatial features of the image. The SNN part is a LIF fully connected classifier, responsible for processing temporal information and outputting classification results. The user configures the ANN part to be trained using backpropagation (learning rate 0.001, Adam optimizer) and the SNN part to be trained using STDP (learning rate 0.01, reward modulation enabled).

[0227] One iteration of this training process includes the following steps: The first step is the data preparation phase. The data loader retrieves a batch of images and labels from the training set, with the image tensor shape being [B, C, H, W] and the label tensor shape being [B]. The data is then transferred to the computing device.

[0228] The second step is the ANN forward propagation stage. The unified execution scheduler executes the forward propagation of the ANN encoder. The input is the original image tensor, which is processed sequentially through convolutional layers, activation functions, and pooling layers. The output is a feature vector with the shape... PyTorch automatically constructs a computation graph to support subsequent backpropagation.

[0229] The third step is the boundary transformation stage. The boundary transformation actuator converts the continuous feature vector output by the ANN into a pulse sequence. First, a flattening operation is applied to ensure that the features are one-dimensional vectors, and then rate encoding is applied to generate... A pulse sequence with n time steps, output shape is The STE technique ensures that gradients can propagate through this boundary.

[0230] The fourth step is the SNN forward propagation phase. The unified execution scheduler enters the time-step iteration loop. First, the states of all SNN neurons and the STDP accumulator are reset. Then, the output buffer is pre-allocated, with the shape... Then execute. In each time-step iteration: the neuron state manager calculates a new membrane potential based on the input impulse and the current membrane potential; the firing detector determines whether the membrane potential exceeds a threshold and generates an output impulse tensor; the STDP learner calculates the weight update increment based on the presynaptic trace, postsynaptic trace, and the current impulse, and accumulates it in the accumulation buffer (not applied immediately); the neuron state manager resets the membrane potential of neurons that fire impulses. After each time-step iteration, the output buffer is summed along the time dimension to obtain the final output, which has the following shape: .

[0231] The fifth step is the loss calculation stage. The SNN output and the true labels are fed into the cross-entropy loss function to calculate the loss value for the current batch. The loss value is a scalar tensor that participates in subsequent backpropagation.

[0232] The sixth step is the backpropagation phase. The ANN optimizer zeroes the gradients of the parameters it manages. Calling `loss.backward()` triggers automatic differentiation, and the gradient propagates back from the loss function, through the SNN layer (where approximate gradients for the spiking layer are calculated via surrogate functions), through boundary transformations (where gradients are passed via STE), and finally to the ANN layer. Since the SNN part is trained using STDP, its weights do not require gradient updates, but the gradients still need to be passed through the SNN layer to train the ANN part. After backpropagation is complete, the parameters of the ANN part have gradient values.

[0233] The seventh step is the ANN parameter update phase. The ANN optimizer executes the step method, using the Adam algorithm to update the parameters of the ANN part based on the calculated gradients.

[0234] Step 8 is the STDP update and application phase. The STDP trainer obtains the classification accuracy of the current batch and calculates the reward signal. The accumulated STDP weights during the forward propagation are updated, multiplied by the reward signal and the learning rate, and applied to the synaptic weights of the SNN layer all at once. Soft boundary constraints are applied to ensure that the weights remain within an effective range.

[0235] Step nine is the monitoring and recording phase. The adaptive optimization controller records the loss value and accuracy of the current iteration. If this is the last batch of the cycle, a validation set evaluation is performed to check whether the best model checkpoint needs to be saved or early stopping should be triggered.

[0236] Through the above process, the multi-paradigm unified execution and training scheduling method for heterogeneous neural networks disclosed herein achieves collaborative training of ANN and SNN: the ANN part optimizes feature extraction capabilities through backpropagation, while the SNN part learns a temporal pattern consistent with the task objective through reward-modulated STDP. Both work together to optimize and complete the classification task. The cumulative-delay application mechanism ensures that STDP updates do not disrupt the computation graph of backpropagation, enabling the two training methods to coexist harmoniously.

[0237] Figure 9 This is a schematic structural block diagram of an electronic device according to one embodiment of the present disclosure.

[0238] like Figure 9As shown, the hardware structure of electronic device 1000 can be implemented using a bus architecture. The bus architecture can include any number of interconnect buses and bridges, depending on the specific application and overall design constraints of the hardware. Bus 1100 connects various circuits including one or more processors 1200, memory 1300, and / or hardware modules. Bus 1100 can also connect various other circuits 1400 such as peripherals, voltage regulators, power management circuits, external antennas, etc. Bus 1100 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 illustration, only one connection line is used in this figure, but this does not indicate that there is only one bus or one type of bus.

[0239] This disclosure also provides a readable storage medium storing a computer program that, when executed by a processor, is used to implement the methods described above. A "readable storage medium" can be any means that can contain a program for storage, communication, propagation, or transmission for use by or in conjunction with an instruction execution system, apparatus, or device. More specific examples of a readable storage medium include: an electrical connection with one or more wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and programmable read-only memory (EPROM or flash memory), fiber optic devices, and portable read-only memory (CDROM), etc.

[0240] This disclosure also provides a computer program product, the methods of which can be implemented wholly or partially through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented wholly or partially as a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instructions are loaded and executed, all or part of the processes or functions of this disclosure are performed.

[0241] Computer programs or instructions can be stored in a readable storage medium or transferred from one readable storage medium to another. For example, the computer program or instructions can be transferred from one website, computer, server, or data center to another website, computer, server, or data center via wired or wireless means. The readable storage medium can be any available medium capable of access, or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium, such as a floppy disk, hard disk, or magnetic tape; an optical medium, such as a digital video optical disc; or a semiconductor medium, such as a solid-state drive. The computer-readable storage medium can be a volatile or non-volatile storage medium, or it can include both volatile and non-volatile types of storage media.

[0242] Those skilled in the art will understand that embodiments of this disclosure can be provided as methods, systems, or computer program products. Therefore, this disclosure can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this disclosure can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0243] This disclosure is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus, and computer program products according to this disclosure. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0244] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0245] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0246] In the description of this specification, the references to terms such as "one embodiment / mode," "some embodiments / modes," "example," "specific example," or "some examples," etc., refer to specific features, structures, or characteristics described in connection with that embodiment / mode or example, which are included in at least one embodiment / mode or example of this disclosure. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment / mode or example. Moreover, the specific features, structures, or characteristics described may be combined in any suitable manner in one or more embodiments / modes or examples. Furthermore, without contradiction, those skilled in the art can combine and integrate the different embodiments / modes or examples described in this specification, as well as the features of different embodiments / modes or examples.

[0247] Those skilled in the art should understand that the above embodiments are merely for illustrating the present disclosure and are not intended to limit the scope of the disclosure. Those skilled in the art can make other changes or modifications based on the above disclosure, and these changes or modifications still fall within the scope of the present disclosure.

Claims

1. A unified execution and training scheduling method for heterogeneous neural networks across multiple paradigms, characterized in that, include: The intermediate representation file output by the compilation system is parsed, and the network topology, sub-network partitioning information, and training method configurations corresponding to each sub-network are extracted from the intermediate representation file. Based on the network topology, a network execution plan is generated, which includes multiple network execution stages arranged in sequence, including an artificial neural network stage, a spiking neural network stage, or a boundary transition stage. The network execution phases are executed sequentially according to the execution plan. In the artificial neural network phase, forward propagation is performed. In the boundary transition phase, data format conversion between the artificial neural network and the spiking neural network is performed. In the spiking neural network phase, the time step iteration loop is entered, and synaptic transmission calculation, neuron dynamic state update, pulse firing judgment, and state reset operation are performed sequentially in each time step. as well as According to the training method configuration, when the coexistence of pulse time-dependent plasticity training and gradient training based on backpropagation is detected, an accumulation-delay application mechanism is executed. During the time step iteration of forward propagation, the accumulation-delay application mechanism only calculates and accumulates the weight update amount to an independent accumulation update buffer, keeping the weight parameters unchanged. After forward propagation is completed, loss function calculation is completed, backpropagation is completed, and the parameters of the artificial neural network are updated, the weight update amount accumulated in the accumulation update buffer is uniformly applied to the weight parameters corresponding to the spiking neural network part.

2. The multi-paradigm unified execution and training scheduling method for heterogeneous neural networks as described in claim 1, characterized in that, Based on the network topology, a network execution plan is generated, including: The computing nodes and their connections are extracted from the network topology to construct a directed acyclic graph. The computing nodes include artificial neural network layer nodes, spiking neural network neuron group nodes, and boundary transition nodes set between the artificial neural network layer and the spiking neural network neuron group. Perform a topological sort on the directed acyclic graph to obtain the execution order of nodes that satisfy data dependencies; The execution order of the nodes is traversed, merging consecutive artificial neural network layer nodes into an artificial neural network stage, merging consecutive spiking neural network neuron group nodes into a spiking neural network stage, and making each boundary transition node an independent boundary transition stage; and A time step configuration is associated with each spiking neural network stage, which specifies the number of time steps required for that spiking neural network stage to be iterated.

3. The multi-paradigm unified execution and training scheduling method for heterogeneous neural networks as described in claim 1, characterized in that, Implement a cumulative-delayed application mechanism, including: At the beginning of each training batch, the cumulative update buffer is initialized as a zero tensor with the same shape as the synaptic weight matrix of the spiking neural network part, and the presynaptic trace variables and postsynaptic trace variables are reset to zero; The forward propagation time step iteration is performed. In each time step, based on the presynaptic pulse firing sequence and postsynaptic pulse firing sequence at the current time, and combined with the exponentially decaying trace variable, the long-term enhancement update term and the long-term suppression update term are calculated respectively. The difference between the long-term enhancement update term and the long-term suppression update term is used as the weight update amount and accumulated into the cumulative update buffer. After completing the forward propagation, the loss function is calculated and back propagation is performed to obtain the gradient values ​​of the parameters that need to be updated. Update the parameters of the artificial neural network part based on the gradient value; and The accumulated weight update amount in the cumulative update buffer is multiplied by the learning rate and then added to the synaptic weight matrix, and weight boundary clipping is performed.

4. The multi-paradigm unified execution and training scheduling method for heterogeneous neural networks as described in claim 3, characterized in that, The difference between the long-term enhancement update term and the long-term suppression update term is used as the weight update amount and accumulated into the cumulative update buffer, including: Based on the current values ​​of the synaptic weight matrix, the preset upper and lower weight thresholds, determine the long-term enhancement scaling factor and the long-term suppression scaling factor. The long-term enhancement update term is multiplied element-wise by the long-term enhancement scaling factor, and the long-term suppression update term is multiplied element-wise by the long-term suppression scaling factor to achieve a scaling of the update amount that smoothly decays as the weights approach the boundary; and The difference between the scaled long-term enhancement update term and the long-term suppression update term is used as the weight update amount and accumulated into the cumulative update buffer.

5. The multi-paradigm unified execution and training scheduling method for heterogeneous neural networks as described in claim 1, characterized in that, It also includes implementing a reward-modulated pulse timing-dependent plasticity training mechanism, wherein the reward-modulated pulse timing-dependent plasticity training mechanism includes: After each training batch completes forward propagation, the classification accuracy of the current batch of samples is calculated based on the network output and the true labels, and the dynamic baseline accuracy is determined based on the total number of task categories, wherein the dynamic baseline accuracy is the reciprocal of the total number of task categories. The classification accuracy is compared with the dynamic benchmark accuracy, and the corresponding reward modulation signal is determined based on the comparison result; and The accumulated weight update amount in the cumulative update buffer is multiplied by the reward modulation signal and then applied to the weight parameters corresponding to the spiking neural network part.

6. The multi-paradigm unified execution and training scheduling method for heterogeneous neural networks as described in claim 1, characterized in that, It also includes a separation optimizer management mechanism, which includes: Based on the training method configuration of each sub-network, identify the sub-network that needs to be trained by gradient based on backpropagation, as well as the corresponding optimizer type and learning rate parameter of the sub-network; For each subnetwork that needs gradient training, collect all trainable parameters contained in that subnetwork and form a parameter set; Based on the optimizer type and the learning rate parameter, create an independent optimizer instance for each parameter group, and establish a mapping relationship between the sub-network identifier and the optimizer instance; and In each training iteration, after performing backpropagation to calculate the gradients of all parameters, the mapping relationship is traversed, and the parameter update method of each optimizer instance is called in turn to update their respective parameter groups.

7. The multi-paradigm unified execution and training scheduling method for heterogeneous neural networks as described in claim 1, characterized in that, The multi-paradigm unified execution and training scheduling method for heterogeneous neural networks also includes: Based on the training method configuration corresponding to each sub-network, the training method type specified for each sub-network is determined. The training method type includes backpropagation, surrogate gradient, impulsive temporal dependent plasticity, Heb learning, evolutionary strategy, or parameter freezing. If any subnetwork has a training method type of spurious temporal dependent plasticity, then the spurious temporal dependent plasticity training process based on the cumulative-delay application mechanism is invoked; if there is no spurious temporal dependent plasticity but there is an evolutionary policy, then the evolutionary policy training process is invoked; if there is no spurious temporal dependent plasticity and an evolutionary policy but there is Heb learning, then the Heb learning training process is invoked; if there is no spurious temporal dependent plasticity, an evolutionary policy, or Heb learning, then the surrogate gradient training process is invoked.

8. The multi-paradigm unified execution and training scheduling method for heterogeneous neural networks as described in claim 1, characterized in that, It also includes a neuron state management mechanism, which includes: For each spiking neural network stage, a state tensor is maintained for each spiking neuron model therein, the state tensor including the membrane potential tensor; Before the spiking neural network phase begins execution, the state tensor is allocated according to the batch size and the number of neurons, and initialized to the initial values ​​defined by the spiking neuron model. In the forward propagation at each time step, a new state value is calculated based on the current input current and the discretized dynamic equations of the spiking neuron model. After calculation, a gradient cutoff operation is performed on the new state value to disconnect the gradient connection between it and the old state value. For a spiking neuron model that emits pulses, a corresponding reset strategy is executed on the state value of the spiking neuron model.

9. An electronic device, characterized in that, include: The memory stores execution instructions; as well as A processor that executes the execution instructions stored in the memory, causing the processor to execute the multi-paradigm unified execution and training scheduling method for heterogeneous neural networks as described in any one of claims 1 to 8.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the multi-paradigm unified execution and training scheduling method for heterogeneous neural networks as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Neural network training method and device based on biological self-organizing back propagation

    CN113837380A

  • Adaptive pulse parallel method and system for efficient training of pulse neural network

    CN121562703A