catniff 0.6.5 → 0.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.js CHANGED
@@ -337,7 +337,12 @@ class Tensor {
337
337
  throw new Error("Can not create view: incompatible metadata");
338
338
  }
339
339
  const outputStrides = Tensor.getStrides(newShape);
340
- const out = new Tensor(this.value, { shape: newShape, strides: outputStrides, numel: outputSize });
340
+ const out = new Tensor(this.value, {
341
+ shape: newShape,
342
+ strides: outputStrides,
343
+ numel: outputSize,
344
+ device: this.device
345
+ });
341
346
  // Gradient reshaped and flow back to the original tensor
342
347
  if (this.requiresGrad) {
343
348
  out.requiresGrad = true;
@@ -357,7 +362,11 @@ class Tensor {
357
362
  }
358
363
  // Create new tensor with forced compatibility (only contiguity for now)
359
364
  const outputStrides = Tensor.getStrides(newShape);
360
- const out = new Tensor(this.contiguous().value, { shape: newShape, strides: outputStrides, numel: outputSize });
365
+ const out = new Tensor(this.contiguous().value, {
366
+ shape: newShape,
367
+ strides: outputStrides,
368
+ numel: outputSize
369
+ });
361
370
  // Gradient reshaped and flow back to the original tensor
362
371
  if (this.requiresGrad) {
363
372
  out.requiresGrad = true;
package/dist/nn.js CHANGED
@@ -191,7 +191,7 @@ class LayerNorm {
191
191
  class Embedding {
192
192
  weight;
193
193
  constructor(numEmbeddings, embeddingDim, device) {
194
- this.weight = core_1.Tensor.randn([numEmbeddings, embeddingDim], { device });
194
+ this.weight = core_1.Tensor.randn([numEmbeddings, embeddingDim], { requiresGrad: true, device });
195
195
  }
196
196
  forward(input) {
197
197
  return this.weight.index(input);
@@ -207,10 +207,10 @@ class MultiheadAttention {
207
207
  headDim;
208
208
  dropout;
209
209
  constructor(embedDim, numHeads, dropout = 0, bias = true, device) {
210
- this.qProjection = new exports.nn.Linear(embedDim, embedDim, bias, device);
211
- this.kProjection = new exports.nn.Linear(embedDim, embedDim, bias, device);
212
- this.vProjection = new exports.nn.Linear(embedDim, embedDim, bias, device);
213
- this.oProjection = new exports.nn.Linear(embedDim, embedDim, bias, device);
210
+ this.qProjection = new Linear(embedDim, embedDim, bias, device);
211
+ this.kProjection = new Linear(embedDim, embedDim, bias, device);
212
+ this.vProjection = new Linear(embedDim, embedDim, bias, device);
213
+ this.oProjection = new Linear(embedDim, embedDim, bias, device);
214
214
  this.embedDim = embedDim;
215
215
  this.numHeads = numHeads;
216
216
  this.headDim = Math.floor(embedDim / numHeads);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "catniff",
3
- "version": "0.6.5",
3
+ "version": "0.6.7",
4
4
  "description": "A small Torch-like deep learning framework for Javascript",
5
5
  "main": "index.js",
6
6
  "scripts": {