transform.quantize_methods.channel_quantize
- transform.quantize_methods.channel_quantize(weights_in: ndarray, weights_rec: ndarray, weights_out: ndarray, threshold: ndarray, threshold_out: ndarray, dash_mem: ndarray, dash_mem_out: ndarray, dash_syn: ndarray, dash_syn_2: ndarray, dash_syn_out: ndarray, bias: ndarray | None = None, bias_out: ndarray | None = None, bits_per_weight: int = 8, bits_per_threshold: int = 16, *_, **__)[source]
Quantize a Xylo model for deployment, using per-channel parameter scaling
The figure below illustrates the groups of weights which are considered for quantization. Under this per-channel method, all input weights to a single target neuron are considered together when scaling and quantizing weights and thresholds. Input and recurrent weights are considered together as a group; output weights are considered separately when quantizing. Dashes are rounded and cast to integer.
target ------------------- s ------------------- - o -++- -**- -##- -oo- - u -++- -**- -##- -oo- - r -++- -**- -##- -oo- - c -++- -**- -##- -oo- - e -++- -**- -##- -oo- - -------------------
Examples
>>> specs = xylo.devices.mapper(net.as_graph(), weight_dtype="float", threshold_dtype="float")
>>> specs.update(channel_quantize(**specs, bits_per_weight = 12))
>>> xylo.devices.XyloSim.from_specifications(specs)
- Parameters:
weights_in (np.ndarray) – Input weight matrix
weights_rec (np.ndarray) – Recurrent weight matrix
weights_out (np.ndarray) – Output weight matrix
threshold (np.ndarray) – Firing threshold for hidden neurons
threshold_out (np.ndarray) – Firing threshold for output neurons
dash_mem (np.ndarray) – Dash for membrane potential of hidden neurons
dash_mem_out (np.ndarray) – Dash for membrane potential of output neurons
dash_syn (np.ndarray) – Dash for synaptic current of hidden neurons
dash_syn_2 (np.ndarray) – Dash for second synaptic current of hidden neurons
dash_syn_out (np.ndarray) – Dash for synaptic current of output neurons
bias (np.ndarray) – Bias for hidden neurons
bias_out (np.ndarray) – Bias for output neurons
bits_per_weight (int) – Number of bits per integer signed weight. Default:
8
bits_per_threshold (int) – Number of bits per integer signed threshold. Default:
16
- Returns:
model_quan
which can be used to update a Xylo specification dictionary- Return type:
dict