diff --git a/assets/demo/demo.css b/assets/demo/demo.css index b0f260a..184677c 100644 --- a/assets/demo/demo.css +++ b/assets/demo/demo.css @@ -88,7 +88,7 @@ h2 { label { display: block; - margin-bottom: 5px; + margin-bottom: 3px; font-weight: bold; } @@ -96,7 +96,7 @@ input[type="number"], input[type="text"] { width: 50%; padding: 8px; - margin-bottom: 10px; + margin-bottom: 6px; border: 1px solid #ccc; border-radius: 5px; box-sizing: border-box; @@ -216,6 +216,24 @@ input { color:#1b1b1b; } +#device-showcase { + margin-left: 50px; + font-size: 16px; + color:#1b1b1b; +} + +#epoch { + margin-left: 50px; + font-size: 16px; + color:#1b1b1b; +} + +#acc { + margin-left: 50px; + font-size: 16px; + color:#1b1b1b; +} + ul { display: inline-block; width: 50%; diff --git a/assets/demo/demo.html b/assets/demo/demo.html index 89d7442..024da51 100644 --- a/assets/demo/demo.html +++ b/assets/demo/demo.html @@ -31,10 +31,10 @@
Welcome to JS-PyTorch's Web Demo! You can choose the Model Hyperparameters on the left, set the Model Layers on the right (number of layers and hidden dimension on each).
+Welcome to JS-PyTorch's Web Demo! You can set the Model Layers on the right (number of layers and hidden dimension of each layer), and choose the Model Hyperparameters in real time.
Validation Loss:
+Validation Accuracy:
Iteration:
-Total Training Examples:
-Loss:
Epoch:
+Total Training Examples:
Device:
diff --git a/assets/demo/index.js b/assets/demo/index.js
index 03aaa5c..2b5a955 100755
--- a/assets/demo/index.js
+++ b/assets/demo/index.js
@@ -1871,6 +1871,13 @@ class CrossEntropyLoss extends Module {
const logits = logitsExp.div(logitsSum);
const y_array = _reshape(y.data, [B]);
const at_logits = logits.at([...Array(B).keys()], y_array);
+ // const myz = torch.tensor(z.data,false)
+ // console.log('logits')
+ // console.log(at_logits.data)
+ // const softmax = new torch.nn.Softmax()
+ // const mylogits2 = softmax.forward(myz).at([...Array(B).keys()], y_array);
+ // console.log('>>.>>>>>')
+ // console.log(mylogits2.data)
const log_losses = log(at_logits);
let loss = log_losses.sum(-1).neg();
loss = loss.div(B);
diff --git a/docs/icon.png b/docs/icon.png
new file mode 100644
index 0000000..a2963af
Binary files /dev/null and b/docs/icon.png differ
diff --git a/docs/index.md b/docs/index.md
index a2d359a..40675a7 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -1,10 +1,3 @@
-
-
-
-
-
-
-
# Welcome to JS-Pytorch's documentation
For access to the source code, visit The GitHub repo.
diff --git a/docs/layers.md b/docs/layers.md
index 90932f1..30c9dc4 100644
--- a/docs/layers.md
+++ b/docs/layers.md
@@ -1,11 +1,4 @@
-
-
-
-
-
-
-
-# Layers
+# Layers
In this section are listed all of the **Layers** and **Modules**.
@@ -22,18 +15,20 @@ new nn.Linear(in_size,
Applies a linear transformation to the input tensor.
Input is matrix-multiplied by a `w` tensor and added to a `b` tensor.
-#### Parameters
+Parameters
+
* **in_size (number)** - Size of the last dimension of the input data.
* **out_size (number)** - Size of the last dimension of the output data.
* **device (string)** - Device on which the model's calculations will run. Either `'cpu'` or `'gpu'`.
* **bias (boolean)** - Whether to use a bias term `b`.
* **xavier (boolean)** - Whether to use Xavier initialization on the weights.
-#### Learnable Variables
+Learnable Variables
+
* **w** - *[input_size, output_size]* Tensor.
* **b** - *[output_size]* Tensor.
-#### Example
+Example
```javascript
>>> let linear = new nn.Linear(10,15,'gpu');
@@ -64,7 +59,8 @@ Applies a self-attention layer on the input tensor.
* Multiplies result by `residual_proj`.
* Applies final Dropout.
-#### Parameters
+Parameters
+
* **in_size (number)** - Size of the last dimension of the input data.
* **out_size (number)** - Size of the last dimension of the output data.
* **n_heads (boolean)** - Number of parallel attention heads the data is divided into. In_size must be divided evenly by n_heads.
@@ -72,13 +68,14 @@ Applies a self-attention layer on the input tensor.
* **dropout_prob (boolean)** - probability of randomly dropping an activation during training (to improve regularization).
* **device (string)** - Device on which the model's calculations will run. Either `'cpu'` or `'gpu'`.
-#### Learnable Variables
+Learnable Variables
+
* **Wk** - *[input_size, input_size]* Tensor.
* **Wq** - *[input_size, input_size]* Tensor.
* **Wv** - *[input_size, input_size]* Tensor.
* **residual_proj** - *[input_size, output_size]* Tensor.
-#### Example
+Example
```javascript
>>> let att = new nn.MultiHeadSelfAttention(10, 15, 2, 32, 0.2, 'gpu');
@@ -115,18 +112,20 @@ forward(x: Tensor): Tensor {
}
```
-#### Parameters
+Parameters
+
* **in_size (number)** - Size of the last dimension of the input data.
* **out_size (number)** - Size of the last dimension of the output data.
* **dropout_prob (boolean)** - probability of randomly dropping an activation during training (to improve regularization).
* **device (string)** - Device on which the model's calculations will run. Either `'cpu'` or `'gpu'`.
* **bias (boolean)** - Whether to use a bias term `b`.
-#### Learnable Variables
+Learnable Variables
+
* **l1** - *[input_size, 4*input_size]* Tensor.
* **l2** - *[4*input_size, input_size]* Tensor.
-#### Example
+Example
```javascript
>>> let fc = new nn.FullyConnected(10, 15, 0.2, 'gpu');
@@ -160,7 +159,8 @@ forward(x: Tensor): Tensor {
}
```
-#### Parameters
+Parameters
+
* **in_size (number)** - Size of the last dimension of the input data.
* **out_size (number)** - Size of the last dimension of the output data.
* **n_heads (boolean)** - Number of parallel attention heads the data is divided into. In_size must be divided evenly by n_heads.
@@ -168,7 +168,8 @@ forward(x: Tensor): Tensor {
* **dropout_prob (boolean)** - probability of randomly dropping an activation during training (to improve regularization).
* **device (string)** - Device on which the model's calculations will run. Either `'cpu'` or `'gpu'`.
-#### Learnable Modules
+Learnable Modules
+
* **nn.MultiHeadSelfAttention** - `Wk`, `Wq`, `Wv`, `residual_proj`.
* **nn.LayerNorm** - `gamma`, `beta`.
* **nn.FullyConnecyed** - `l1`, `l2`.
diff --git a/docs/logo.png b/docs/logo.png
new file mode 100644
index 0000000..769cb40
Binary files /dev/null and b/docs/logo.png differ
diff --git a/docs/operations.md b/docs/operations.md
index 5cefd98..8ebe869 100644
--- a/docs/operations.md
+++ b/docs/operations.md
@@ -1,11 +1,4 @@
-
-
-
-
-
-
-
-# Tensor Operations
+# Tensor Operations
In this section are listed all of the **Tensor Operation** methods.
@@ -20,11 +13,13 @@ torch.add(a,
* If one tensor is a scalar, the element-wise sum of the scalar and the tensor is returned.
* If tensors both are n-dimensional tensors, JS-PyTorch will attempt to broadcast their shapes, and add them element-wise.
-#### Parameters
+Parameters
+
* **a (Tensor | number)** - Input Tensor or number.
* **b (Tensor | number)** - Other Tensor or number.
-#### Example
+Example
+
```javascript
>>> let a = torch.tensor([[1,1,2,3],
[6,7,8,9]]);
@@ -48,7 +43,8 @@ torch.add(a,
```
> **Note:** `torch.add(a, b)` is the same as `a.add(b)`.
-
+
+
## torch.sub
@@ -61,11 +57,13 @@ torch.sub(a,
* If one tensor is a scalar, the element-wise subtraction of the scalar and the tensor is returned.
* If tensors both are n-dimensional tensors, JS-PyTorch will attempt to broadcast their shapes, and subtract them element-wise.
-#### Parameters
+Parameters
+
* **a (Tensor | number)** - Input Tensor or number.
* **b (Tensor | number)** - Other Tensor or number.
-#### Example
+Example
+
```javascript
>>> let a = torch.tensor([[1,1,2,3],
[6,7,8,9]]);
@@ -89,7 +87,8 @@ torch.sub(a,
```
> **Note:** `torch.sub(a, b)` is the same as `a.sub(b)`.
-
+
+
## torch.neg
@@ -99,10 +98,12 @@ torch.neg(a) → Tensor
Returns the element-wise opposite of the given Tensor.
-#### Parameters
+Parameters
+
* **a (Tensor | number)** - Input Tensor or number.
-#### Example
+Example
+
```javascript
>>> let a = torch.tensor([1]);
>>> let b = torch.neg(a);
@@ -121,7 +122,8 @@ Returns the element-wise opposite of the given Tensor.
```
> **Note:** `torch.neg(a)` is the same as `a.neg()`.
-
+
+
## torch.mul
@@ -134,11 +136,13 @@ torch.mul(a,
* If one tensor is a scalar, the element-wise product of the scalar and the tensor is returned.
* If tensors both are n-dimensional tensors, JS-PyTorch will attempt to broadcast their shapes, and multiply them element-wise.
-#### Parameters
+Parameters
+
* **a (Tensor | number)** - Input Tensor or number.
* **b (Tensor | number)** - Other Tensor or number.
-#### Example
+Example
+
```javascript
>>> let a = torch.tensor([[1,1,2,3],
[6,7,8,9]]);
@@ -162,7 +166,8 @@ torch.mul(a,
```
> **Note:** `torch.mul(a, b)` is the same as `a.mul(b)`.
-
+
+
## torch.div
@@ -175,11 +180,13 @@ torch.div(a,
* If one tensor is a scalar, the element-wise division of the scalar and the tensor is returned.
* If tensors both are n-dimensional tensors, JS-PyTorch will attempt to broadcast their shapes, and divide them element-wise.
-#### Parameters
+Parameters
+
* **a (Tensor | number)** - Input Tensor or number.
* **b (Tensor | number)** - Other Tensor or number.
-#### Example
+Example
+
```javascript
>>> let a = torch.tensor([[2,-2,4,6],
[6,-6,8,8]]);
@@ -203,7 +210,8 @@ torch.div(a,
```
> **Note:** `torch.div(a, b)` is the same as `a.div(b)`.
-
+
+
## torch.matmul
@@ -221,11 +229,13 @@ If the two Tensors have more than two dimensions, they can be **broadcast**:
* `[H,W], [B,N,W,C] => [B,N,H,C]`
* `[B,N,H,W], [1,1,W,C] => [B,N,H,C]`
-#### Parameters
+Parameters
+
* **a (Tensor | number)** - Input Tensor.
* **b (Tensor | number)** - Other Tensor.
-#### Example
+Example
+
```javascript
>>> let a = torch.tensor([[1,1,1,2],
[3,1,0,0]]); // Shape [2,4]
@@ -240,7 +250,10 @@ If the two Tensors have more than two dimensions, they can be **broadcast**:
```
> **Note:** `torch.matmul(a, b)` is the same as `a.matmul(b)`.
-
+
+
+
+
## torch.sum
@@ -252,12 +265,14 @@ torch.sum(a,
Gets the sum of the Tensor over a specified dimension.
-#### Parameters
+Parameters
+
* **a (Tensor)** - Input Tensor.
* **dim (integer)** - Dimension to perform the sum over.
* **keepdims (boolean)** - Whether to keep dimensions of original tensor.
-#### Example
+Example
+
```javascript
>>> let a = torch.ones([4,3], false, 'gpu');
>>> a.data;
@@ -283,7 +298,8 @@ Gets the sum of the Tensor over a specified dimension.
```
> **Note:** `torch.sum(a)` is the same as `a.sum()`.
-
+
+
## torch.mean
@@ -295,12 +311,14 @@ torch.mean(a,
Gets the mean of the Tensor over a specified dimension.
-#### Parameters
+Parameters
+
* **a (Tensor)** - Input Tensor.
* **dim (integer)** - Dimension to get the mean of.
* **keepdims (boolean)** - Whether to keep dimensions of original tensor.
-#### Example
+Example
+
```javascript
>>> let a = torch.randint(0, 2, [2,3], false, 'gpu');
>>> a.data;
@@ -320,7 +338,8 @@ Gets the mean of the Tensor over a specified dimension.
```
> **Note:** `torch.mean(a)` is the same as `a.mean()`.
-
+
+
## torch.variance
@@ -332,12 +351,14 @@ torch.variance(a,
Gets the variance of the Tensor over a specified dimension.
-#### Parameters
+Parameters
+
* **a (Tensor)** - Input Tensor.
* **dim (integer)** - Dimension to get the variance of.
* **keepdims (boolean)** - Whether to keep dimensions of original tensor.
-#### Example
+Example
+
```javascript
>>> let a = torch.randint(0, 3, [3,2], false, 'gpu');
>>> a.data;
@@ -355,7 +376,8 @@ Gets the variance of the Tensor over a specified dimension.
```
> **Note:** `torch.variance(a)` is the same as `a.variance()`.
-
+
+
## torch.transpose
@@ -367,12 +389,14 @@ torch.transpose(a,
Transposes the tensor along two consecutive dimensions.
-#### Parameters
+Parameters
+
* **a (Tensor)** - Input Tensor.
* **dim1 (integer)** - First dimension.
* **dim2 (boolean)** - Second dimension.
-#### Example
+Example
+
```javascript
>>> let a = torch.randint(0, 3, [3,2], false, 'gpu');
>>> a.data;
@@ -386,7 +410,8 @@ Transposes the tensor along two consecutive dimensions.
```
> **Note:** `torch.transpose(a)` is the same as `a.transpose()`.
-
+
+
## torch.at
@@ -399,12 +424,14 @@ torch.at(a,
If a single Array `index1` is passed, returns the elements in the tensor indexed by this Array: `tensor[index1]`.
If a two Arrays `index1` and `index2` are passed, returns the elements in the tensor indexed by `tensor[index1][index2]`.
-#### Parameters
+Parameters
+
* **a (Tensor)** - Input Tensor.
* **index1 (Array)** - Array containing indexes to extract data from in first dimension.
* **index2 (Array)** - Array containing indexes to extract data from in second dimension.
-#### Example
+Example
+
```javascript
>>> let a = torch.tensor([[1,1,2,3],
[6,7,8,9]]);
@@ -419,7 +446,8 @@ If a two Arrays `index1` and `index2` are passed, returns the elements in the te
```
> **Note:** `torch.at(a)` is the same as `a.at()`.
-
+
+
## torch.masked_fill
@@ -432,12 +460,14 @@ torch.masked_fill(a,
A condition function scans the `a` tensor element-wise, returning `true` or `false`.
In places within the `a` tensor where the "condition" function returns True, we set the value to `value`.
-#### Parameters
+Parameters
+
* **a (Tensor)** - Input Tensor.
* **condition (function)** - Function that returns True or False element-wise.
* **value (number)** - Value to fill Tensor when condition is met.
-#### Example
+Example
+
```javascript
>>> let a = torch.tensor([[1,5,2,3],
[6,7,2,9]]);
@@ -448,7 +478,8 @@ In places within the `a` tensor where the "condition" function returns True, we
```
> **Note:** `torch.masked_fill(a)` is the same as `a.masked_fill()`.
-
+
+
## torch.pow
@@ -459,11 +490,13 @@ torch.pow(a,
Returns tensor to element-wise power of n.
-#### Parameters
+Parameters
+
* **a (Tensor)** - Input Tensor.
* **n (function)** - Exponent.
-#### Example
+Example
+
```javascript
>>> let a = torch.tensor([[1,-5],
[6,7]]);
@@ -474,7 +507,8 @@ Returns tensor to element-wise power of n.
```
> **Note:** `torch.pow(a)` is the same as `a.pow()`.
-
+
+
## torch.sqrt
@@ -484,10 +518,12 @@ torch.sqrt(a) → Tensor
Returns element-wise square root of the tensor.
-#### Parameters
+Parameters
+
* **a (Tensor)** - Input Tensor.
-#### Example
+Example
+
```javascript
>>> let a = torch.tensor([[1,9],
[4,16]]);
@@ -498,7 +534,8 @@ Returns element-wise square root of the tensor.
```
> **Note:** `torch.sqrt(a)` is the same as `a.sqrt()`.
-
+
+
## torch.exp
@@ -508,10 +545,12 @@ torch.exp(a) → Tensor
Returns element-wise exponentiation of the tensor.
-#### Parameters
+Parameters
+
* **a (Tensor)** - Input Tensor.
-#### Example
+Example
+
```javascript
>>> let a = torch.tensor([[1,2],
[0,-1]]);
@@ -522,7 +561,8 @@ Returns element-wise exponentiation of the tensor.
```
> **Note:** `torch.exp(a)` is the same as `a.exp()`.
-
+
+
## torch.log
@@ -532,10 +572,12 @@ torch.log(a) → Tensor
Returns element-wise natural log of the tensor.
-#### Parameters
+Parameters
+
* **a (Tensor)** - Input Tensor.
-#### Example
+Example
+
```javascript
>>> let a = torch.tensor([[1,2],
[0.01,3]]);
diff --git a/docs/style.css b/docs/style.css
new file mode 100644
index 0000000..60253fa
--- /dev/null
+++ b/docs/style.css
@@ -0,0 +1,10 @@
+span.md-ellipsis {
+ font-weight: 500;
+ font-size: larger;
+
+}
+h1 {
+ font-weight: 390;
+}
+
+/* In lines "deep-orange", palette file: --md-primary-fg-color:#f74f1b AND --md-accent-fg-color*/
\ No newline at end of file
diff --git a/docs/tensor.md b/docs/tensor.md
index ba4101b..cd12ca4 100644
--- a/docs/tensor.md
+++ b/docs/tensor.md
@@ -1,11 +1,4 @@
-
-
-
-
-
-
-
-# Tensor
+# Tensor
The Tensor is the main object of this library. In this section are listed all of the **Tensor** methods.
@@ -19,12 +12,13 @@ torch.tensor(data,
Returns a tensor filled with the data in the argument `data`.
-#### Parameters
+Parameters
+
* **data (Array)** - Javascript Array containing the data to be stored in the Tensor. This array can have any number of dimensions, but must have a homogenous shape, and only numbers.
* **requires_grad (boolean)** - Whether to keep track of this tensor's gradients. Set this to true if you want to **learn** this parameter in your model. Default: `false`.
* **device (string)** - Device to store Tensor. Either "gpu" or "cpu". If your device has a gpu, large models will train faster on it.
-#### Example
+Example
```javascript
>>> let a = torch.tensor([[1,2,3],[4,5,6]], false, 'gpu');
@@ -33,6 +27,8 @@ Returns a tensor filled with the data in the argument `data`.
// [4,5,6]]
```
+
+
## torch.zeros
```
@@ -43,12 +39,13 @@ torch.zeros(*shape,
Returns a tensor filled with zeros with dimensions like `shape`.
-#### Parameters
+Parameters
+
* **shape (Array)** - Javascript Array containing the shape of the Tensor.
* **requires_grad (boolean)** - Whether to keep track of this tensor's gradients. Set this to true if you want to **learn** this parameter in your model. Default: `false`.
* **device (string)** - Device to store Tensor. Either "gpu" or "cpu". If your device has a gpu, large models will train faster on it.
-#### Example
+Example
```javascript
>>> let a = torch.zeros([3,2], false, 'gpu');
@@ -58,6 +55,8 @@ Returns a tensor filled with zeros with dimensions like `shape`.
// [0, 0]]
```
+
+
## torch.ones
```
@@ -68,12 +67,13 @@ torch.ones(*shape,
Returns a tensor filled with ones with dimensions like `shape`.
-#### Parameters
+Parameters
+
* **shape (Array)** - Javascript Array containing the shape of the Tensor.
* **requires_grad (boolean)** - Whether to keep track of this tensor's gradients. Set this to true if you want to **learn** this parameter in your model. Default: `false`.
* **device (string)** - Device to store Tensor. Either "gpu" or "cpu". If your device has a gpu, large models will train faster on it.
-#### Example
+Example
```javascript
>>> let a = torch.ones([3,2], false, 'gpu');
@@ -83,6 +83,8 @@ Returns a tensor filled with ones with dimensions like `shape`.
// [1, 1]]
```
+
+
## torch.tril
```
@@ -93,12 +95,13 @@ torch.tril(*shape,
Returns a 2D lower triangular tensor.
-#### Parameters
+Parameters
+
* **shape (Array)** - Javascript Array containing the shape of the Tensor.
* **requires_grad (boolean)** - Whether to keep track of this tensor's gradients. Set this to true if you want to **learn** this parameter in your model. Default: `false`.
* **device (string)** - Device to store Tensor. Either "gpu" or "cpu". If your device has a gpu, large models will train faster on it.
-#### Example
+Example
```javascript
>>> let a = torch.tril([4,3], false, 'gpu');
@@ -114,6 +117,8 @@ Returns a 2D lower triangular tensor.
// [1, 1, 1, 0]
```
+
+
## torch.randn
```
@@ -124,12 +129,13 @@ torch.randn(*shape,
Returns a tensor filled with randomly sampled data with dimensions like `shape`. The sample is from a normal distribution.
-#### Parameters
+Parameters
+
* **shape (Array)** - Javascript Array containing the shape of the Tensor.
* **requires_grad (boolean)** - Whether to keep track of this tensor's gradients. Set this to true if you want to **learn** this parameter in your model. Default: `false`.
* **device (string)** - Device to store Tensor. Either "gpu" or "cpu". If your device has a gpu, large models will train faster on it.
-#### Example
+Example
```javascript
>>> let a = torch.randn([3,2], false, 'gpu');
@@ -139,6 +145,8 @@ Returns a tensor filled with randomly sampled data with dimensions like `shape`.
// [0.123,-0.001]]
```
+
+
## torch.rand
```
@@ -149,12 +157,13 @@ torch.rand(*shape,
Creates new instance of the Tensor class filled with numbers in a uniform distribution in ]0,1[.
-#### Parameters
+Parameters
+
* **shape (Array)** - Javascript Array containing the shape of the Tensor.
* **requires_grad (boolean)** - Whether to keep track of this tensor's gradients. Set this to true if you want to **learn** this parameter in your model. Default: `false`.
* **device (string)** - Device to store Tensor. Either "gpu" or "cpu". If your device has a gpu, large models will train faster on it.
-#### Example
+Example
```javascript
>>> let a = torch.rand([3,2], false, 'gpu');
@@ -164,6 +173,8 @@ Creates new instance of the Tensor class filled with numbers in a uniform distri
// [-0.90,-0.202]]
```
+
+
## torch.randint
```
@@ -176,14 +187,15 @@ torch.rand(low,
Creates new instance of the Tensor class filled with random integers between `low` and `high`.
-#### Parameters
+Parameters
+
* **low** - Lowest integer that can be sampled.
* **high** - One above highest integer that can be sampled.
* **shape (Array)** - Javascript Array containing the shape of the Tensor.
* **requires_grad (boolean)** - Whether to keep track of this tensor's gradients. Set this to true if you want to **learn** this parameter in your model. Default: `false`.
* **device (string)** - Device to store Tensor. Either "gpu" or "cpu". If your device has a gpu, large models will train faster on it.
-#### Example
+Example
```javascript
>>> let a = torch.rand([3,2], false, 'gpu');
@@ -193,12 +205,14 @@ Creates new instance of the Tensor class filled with random integers between `lo
// [-0.90,-0.202]]
```
+
+
## tensor.backward
Performs backpropagation from this tensor backwards. It fills the gradients of every tensor that led to this one with gradients relative to **this** tensor.
> **Note:** This only happens to tensors that have `requires_grad` set to true.
-#### Example
+Example
```javascript
>>> let a = torch.randn([3,2], true, 'gpu');
@@ -211,11 +225,13 @@ Performs backpropagation from this tensor backwards. It fills the gradients of e
// [-0.91,-0.044]]
```
+
+
## tensor.zero_grad
Clears the gradients stored in this tensor. Sets the gadients to zero. This is used after the gradients have been used to update the parameters of a model, to set the model up for the next iteration.
-#### Example
+Example
```javascript
>>> let a = torch.randn([3,2], true, 'gpu');
@@ -233,11 +249,13 @@ Clears the gradients stored in this tensor. Sets the gadients to zero. This is u
// [0, 0]]
```
+
+
## tensor.zero_grad_graph
Clears the gradients stored in this tensor, setting the gadients to zero, and does the same for every tensor that led to this one. This is used after the gradients have been used to update the parameters of a model, to set the model up for the next iteration.
-#### Example
+Example
```javascript
>>> let a = torch.randn([3,2], true, 'gpu');
@@ -255,11 +273,13 @@ Clears the gradients stored in this tensor, setting the gadients to zero, and do
// [0, 0]]
```
+
+
## tensor.tolist
Returns an Array with the tensor's data.
-#### Example
+Example
```javascript
>>> let a = torch.randn([3,2], true, 'gpu');
@@ -270,11 +290,13 @@ Returns an Array with the tensor's data.
// [-0.91,-0.044]]
```
+
+
## tensor.data
Returns the tensor's data as a javascript Array.
-#### Example
+Example
```javascript
>>> let a = torch.randn([3,2], true, 'gpu');
@@ -284,11 +306,13 @@ Returns the tensor's data as a javascript Array.
// [-0.91,-0.044]]
```
+
+
## tensor.length
Returns the tensor's length (size of first dimension).
-#### Example
+Example
```javascript
>>> let a = torch.randn([3,2], true, 'gpu');
@@ -296,11 +320,13 @@ Returns the tensor's length (size of first dimension).
// 3
```
+
+
## tensor.ndims
Returns the number of dimensions in the Tensor.
-#### Example
+Example
```javascript
>>> let a = torch.randn([3,2,1,4], true, 'gpu');
@@ -308,11 +334,13 @@ Returns the number of dimensions in the Tensor.
// 4
```
+
+
## tensor.grad
Returns the gradients currently stored in the Tensor.
-#### Example
+Example
```javascript
>>> let a = torch.randn([3,2], true, 'gpu');
diff --git a/docs/tutorials.md b/docs/tutorials.md
index f518663..a61c200 100644
--- a/docs/tutorials.md
+++ b/docs/tutorials.md
@@ -1,12 +1,4 @@
-
-
-
-
-
-
-
-
-# Tutorials
+# Tutorials
This section contains ready-to-use examples of JS-PyTorch in action, with increasing complexity and explainations along the way.
diff --git a/docs/white_icon.png b/docs/white_icon.png
new file mode 100644
index 0000000..74b2aa1
Binary files /dev/null and b/docs/white_icon.png differ
diff --git a/mkdocs.yml b/mkdocs.yml
index 99dc136..d3552ff 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -7,6 +7,48 @@ nav:
- Tutorials: tutorials.md
theme:
- name: readthedocs
+ logo: white_icon.png
+ favicon: icon.png
+ icon:
+ repo: fontawesome/brands/github
+ name: material
palette:
- primary: blue
\ No newline at end of file
+ - scheme: default
+ primary: deep orange
+ accent: deep orange
+ toggle:
+ icon: material/toggle-switch
+ name: Switch to dark mode
+
+ # Palette toggle for dark mode
+ - scheme: slate
+ primary: deep orange
+ accent: deep orange
+ toggle:
+ icon: material/toggle-switch-off-outline
+ name: Switch to light mode
+
+ features:
+ - navigation.tabs
+ - navigation.tabs.sticky
+ - navigation.path
+ - navigation.indexes
+ - toc.integrate
+ - toc.follow
+ - navigation.top
+
+extra:
+ homepage: https://github.com/eduardoleao052/js-pytorch
+ social:
+ - icon: fontawesome/brands/github
+ link: https://github.com/eduardoleao052/js-pytorch
+ - icon: fontawesome/brands/linkedin
+ link: https://www.linkedin.com/in/eduardoleao052/
+
+copyright: Copyright © 2024 Eduardo Leitão da Cunha Opice Leão
+
+repo_url: https://github.com/eduardoleao052/js-pytorch
+repo_name: JS-PyTorch
+
+extra_css:
+ - style.css
\ No newline at end of file
diff --git a/site/404.html b/site/404.html
index 584956b..a7f2457 100644
--- a/site/404.html
+++ b/site/404.html
@@ -1,121 +1,526 @@
-
-
-
- - - - -
- - - - - - - - - -
+