mirror of
https://github.com/wassname/Ranger21.git
synced 2026-09-10 11:40:27 +08:00
extend agc to any dimension
This commit is contained in:
@@ -379,9 +379,7 @@ class Ranger21(TO.Optimizer):
|
||||
elif xlen == 4: # conv kernels
|
||||
dim = (1, 2, 3)
|
||||
else:
|
||||
raise ValueError(
|
||||
f"unit_norm:: adaptive gclipping: unable to process len of {xlen} - currently must be <= 4"
|
||||
)
|
||||
dim = tuple([x for x in range(1,xlen)]) # create 1,..., xlen-1 tuple, while avoiding last dim ...
|
||||
|
||||
return x.norm(dim=dim, keepdim=keepdim, p=2.0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user