pykan
pykan copied to clipboard
RuntimeError. Problems with dimensions.
Hello! We are trying to plot KAN at initialization:
and get error, (where 88 - is length of my set):
RuntimeError Traceback (most recent call last)
[<ipython-input-43-31a261174e74>](https://localhost:8080/#) in <cell line: 1>()
----> 1 model(dataset['train_input'])
2 model.plot(beta=100)
5 frames
[/usr/local/lib/python3.10/dist-packages/kan/KANLayer.py](https://localhost:8080/#) in forward(self, x)
170 batch = x.shape[0]
171 # x: shape (batch, in_dim) => shape (size, batch) (size = out_dim * in_dim)
--> 172 x = torch.einsum('ij,k->ikj', x, torch.ones(self.out_dim,).to(self.device)).reshape(batch, self.size).permute(1,0)
173 preacts = x.permute(1,0).clone().reshape(batch, self.out_dim, self.in_dim)
174 base = self.base_fun(x).permute(1,0) # shape (batch, size)
RuntimeError: shape '[88, 10]' is invalid for input of size 1320
What could be the problem?
dimension of first layer needs adjusting to match dimension of data ingested
dimension of first layer needs adjusting to match dimension of data ingested
I actually had this same exact issue yesterday (mixture of this as well as some fat-fingering or .iloc
slicing...)
To error-proof this I recommend just making that first dimension dynamic by doing this (using train_input.shape[1]
as the first dimension: