Closed rohan-mehta-1024 closed 11 months ago
In general I wanted there to be a "boring" constructor that just takes the fields, which helps making initializing from other sources easier: loading from HF checkpoints, different initialization strategies, etc.
We could revisit, but that's why I did it the way I did
Ah ok, the more I thought about this the more it actually probably seems like the right idea. I'll change my code to be consistent with it. Have not encountered it before in ML libraries, but it does make sense to be able, e.g., to initialize a module with a very specific weight matrix or something like that. Incidentally, this strengthens my belief that haliax could be used to make a really good interpretability library!
I was wondering why it's considered idiomatic in haliax to instantiate new modules with a
@staticmethod init
instead of using the built in object initializer,__init__
? The latter seemed more natural to me so I've been using it instead when defining my own modules. Nothing has broken so far, but now when I try to define a transformer block:and then use stacked with it
self.blocks = hnn.Stacked.init(Layer, TBlock)(key=jr.split(k3, Layer.size))
I get
AttributeError: type object 'TBlock' has no attribute 'init'
presumably because stacked was expecting a
instead of my
Is there any way to get this to work with the typical idiomatic Python initialization? And why was this choice made in the library design (since, as far as I can tell, Equinox also is in keeping with traditional Python here)?