Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

QBatchNormalization quantizers

Aperta
#657 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
38/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
machine-learning, python

Direzione di ricerca

Start in hls4ml/converters/keras/qkeras_layers.py around the lines the issue links, to see whether the gamma, beta, mean and variance quantizer attributes are ever set or read. Then check BatchNormalization.initialize in hls4ml/model/layers.py, where scale and bias are computed from the unquantized weights. Done when you can say whether the quantizers are used and whether quantizing before the scale and bias calculation changes the output, with a converter test that shows it. The maintainers have not yet decided the approach, so confirm the direction in the thread first.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug Stale

Hey, I have a question regarding the QBatchNorm implementation. I think I must be overlooking something, but are these used anywhere?

Perhaps the QBN parameters could be directly quantized here before scale and bias calculation?

class BatchNormalization(Layer):
    _expected_attributes = [
        Attribute('n_in'),
        Attribute('n_filt', default=0),

        WeightAttribute('scale'),
        WeightAttribute('bias'),

        TypeAttribute('scale'),
        TypeAttribute('bias'),
    ]

    def initialize(self):
        inp = self.get_input_variable()
        shape = inp.shape
        dims = inp.dim_names
        self.add_output_variable(shape, dims)

        gamma = self.model.get_weights_data(self.name, 'gamma')
        beta = self.model.get_weights_data(self.name, 'beta')
        mean = self.model.get_weights_data(self.name, 'moving_mean')
        var = self.model.get_weights_data(self.name, 'moving_variance')

        if self.get_attr('gamma_quantizer'):
            gamma = self.get_attr('gamma_quantizer')(gamma)
            beta = self.get_attr('beta_quantizer')(beta)
            mean = self.get_attr('mean_quantizer')(mean)
            var = self.get_attr('variance_quantizer')(var)

        scale = gamma / np.sqrt(var + self.get_attr('epsilon'))
        bias = beta - mean * scale
        
        self.add_weights_variable(name='scale', var_name='s{index}', data=scale)
        self.add_weights_variable(name='bias', var_name='b{index}', data=bias)
Lingua principale
Python
Stelle
2.2k
Fork
605
Merge medio
7g 35m
PR unite (30g)
19

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di fastmachinelearning/hls4ml

Tutte le issue di fastmachinelearning/hls4ml

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.