diff --git a/assets/demo/demo.html b/assets/demo/demo.html
index 0152e60..d753532 100644
--- a/assets/demo/demo.html
+++ b/assets/demo/demo.html
@@ -26,7 +26,7 @@
-
Welcome to JS-Torch's Web Demo! You can choose the Model Hyperparameters on the left, set tme Model Layers on the right (number of layers and hidden dimension on each).
+
Welcome to JS-Torch'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).
- This model was trained on a Dummy dataset, composed of randomly generated images.
diff --git a/src/tensor.js b/src/tensor.js
index 29e095f..51509ae 100644
--- a/src/tensor.js
+++ b/src/tensor.js
@@ -4,13 +4,13 @@
var torch = (function(exports){
- // <<< Tensor class, holds n-dimentional tensors, and multiple useful methods >>> //
+ // <<< Tensor class, holds n-dimensional tensors, and multiple useful methods >>> //
class Tensor {
/**
* Creates new instance of the Tensor class.
* @param {object} data - Iterable containing the data to be stored in the Tensor.
- * @param {boolean} requires_grad - Wether to keep track of this tensor's gradients.
+ * @param {boolean} requires_grad - Whether to keep track of this tensor's gradients.
*/
constructor(data, requires_grad=false) {
if (typeof data === 'object') {
@@ -132,9 +132,9 @@ var torch = (function(exports){
};
/**
- * Gets the sum of the Tensor over a specified dimention.
- * @param {number} dim - Dimention to sum over.
- * @param {boolean} keepdims - Wether to keep dimentions of original tensor.
+ * Gets the sum of the Tensor over a specified dimension.
+ * @param {number} dim - Dimension to sum over.
+ * @param {boolean} keepdims - Whether to keep dimensions of original tensor.
* @returns {Tensor} - Final tensor.
*/
sum(dim=-1, keepdims=false) {
@@ -143,9 +143,9 @@ var torch = (function(exports){
};
/**
- * Gets the mean of the Tensor over a specified dimention.
- * @param {number} dim - Dimention to get mean over.
- * @param {boolean} keepdims - Wether to keep dimentions of original tensor.
+ * Gets the mean of the Tensor over a specified dimension.
+ * @param {number} dim - Dimension to get mean over.
+ * @param {boolean} keepdims - Whether to keep dimensions of original tensor.
* @returns {Tensor} - Final tensor.
*/
mean(dim=-1, keepdims=false) {
@@ -154,9 +154,9 @@ var torch = (function(exports){
};
/**
- * Gets the variance of the Tensor over a specified dimention.
- * @param {number} dim - Dimention to get variance over.
- * @param {boolean} keepdims - Wether to keep dimentions of original tensor.
+ * Gets the variance of the Tensor over a specified dimension.
+ * @param {number} dim - Dimension to get variance over.
+ * @param {boolean} keepdims - Whether to keep dimensions of original tensor.
* @returns {Tensor} - Final tensor.
*/
variance(dim=-1, keepdims=false) {
@@ -791,10 +791,10 @@ var torch = (function(exports){
class Sum {
/**
- * Gets the sum of a Tensor over a specified dimention.
+ * Gets the sum of a Tensor over a specified dimension.
* @param {Tensor} a - Tensor to sum.
- * @param {dim} dim - Dimention to sum over.
- * @param {keepdims} keepdims - Wether to keep dimentions of original tensor.
+ * @param {dim} dim - Dimension to sum over.
+ * @param {keepdims} keepdims - Whether to keep dimensions of original tensor.
* @returns {Tensor} - Final tensor.
*/
forward(a, dim, keepdims=false) {
@@ -805,7 +805,7 @@ var torch = (function(exports){
if (dim < 0) {
dim = a.shape.length + dim;
};
- // Return error if dimention is out of bounds:
+ // Return error if dimension is out of bounds:
if (dim >= a.shape.length) {
throw Error('Dimension larger than array.')
};
@@ -845,10 +845,10 @@ var torch = (function(exports){
class Mean {
/**
- * Gets the mean of a Tensor over a specified dimention.
+ * Gets the mean of a Tensor over a specified dimension.
* @param {Tensor} a - Tensor to get mean from.
- * @param {dim} dim - Dimention to get mean over.
- * @param {keepdims} keepdims - Wether to keep dimentions of original tensor.
+ * @param {dim} dim - Dimension to get mean over.
+ * @param {keepdims} keepdims - Whether to keep dimensions of original tensor.
* @returns {Tensor} - Final tensor.
*/
forward(a, dim, keepdims=false) {
@@ -856,7 +856,7 @@ var torch = (function(exports){
if (dim < 0) {
dim = a.shape.length + dim;
};
- // Return error if dimention is out of bounds:
+ // Return error if dimension is out of bounds:
if (dim >= a.shape.length) {
throw Error('Dimension larger than array.')
};
@@ -897,10 +897,10 @@ var torch = (function(exports){
class Variance {
/**
- * Gets the variance of a Tensor over a specified dimention.
+ * Gets the variance of a Tensor over a specified dimension.
* @param {Tensor} a - Tensor to get variance of.
- * @param {dim} dim - Dimention to get variance over.
- * @param {keepdims} keepdims - Wether to keep dimentions of original tensor.
+ * @param {dim} dim - Dimension to get variance over.
+ * @param {keepdims} keepdims - Whether to keep dimensions of original tensor.
* @returns {Tensor} - Final tensor.
*/
forward(a, dim, keepdims=false) {
@@ -908,7 +908,7 @@ var torch = (function(exports){
if (dim < 0) {
dim = a.shape.length + dim;
};
- // Return error if dimention is out of bounds:
+ // Return error if dimension is out of bounds:
if (dim >= a.shape.length) {
throw Error('Dimension larger than array.');
};
@@ -1131,10 +1131,10 @@ var torch = (function(exports){
// <<< Tensor Operation Aliases >>> //
/**
- * Gets the sum of the Tensor over a specified dimention.
+ * Gets the sum of the Tensor over a specified dimension.
* @param {Tensor} a - Original Tensor.
- * @param {number} dim - Dimention to sum over.
- * @param {boolean} keepdims - Wether to keep dimentions of original tensor.
+ * @param {number} dim - Dimension to sum over.
+ * @param {boolean} keepdims - Whether to keep dimensions of original tensor.
* @returns {Tensor} - Final tensor.
*/
function sum(a, dim=-1, keepdims=false) {
@@ -1142,10 +1142,10 @@ var torch = (function(exports){
};
/**
- * Gets the mean of the Tensor over a specified dimention.
+ * Gets the mean of the Tensor over a specified dimension.
* @param {Tensor} a - Original Tensor.
- * @param {number} dim - Dimention to get mean over.
- * @param {boolean} keepdims - Wether to keep dimentions of original tensor.
+ * @param {number} dim - Dimension to get mean over.
+ * @param {boolean} keepdims - Whether to keep dimensions of original tensor.
* @returns {Tensor} - Final tensor.
*/
function mean(a, dim=-1, keepdims=false) {
@@ -1153,10 +1153,10 @@ var torch = (function(exports){
};
/**
- * Gets the variance of the Tensor over a specified dimention.
+ * Gets the variance of the Tensor over a specified dimension.
* @param {Tensor} a - Original Tensor.
- * @param {number} dim - Dimention to get variance over.
- * @param {boolean} keepdims - Wether to keep dimentions of original tensor.
+ * @param {number} dim - Dimension to get variance over.
+ * @param {boolean} keepdims - Whether to keep dimensions of original tensor.
* @returns {Tensor} - Final tensor.
*/
function variance(a, dim=-1, keepdims=false) {
@@ -1328,7 +1328,7 @@ var torch = (function(exports){
function _sum(a, dim, keepdims) {
// In recursive call, when depth increases, subtract one from dim.
- // When we reach the dimention intended (dim === 0),
+ // When we reach the dimension intended (dim === 0),
// we add all elements in this dimension.
if ( dim == 0 ) {
let sum = a.reduce((a,b) => _add(a, b), 0);
@@ -1347,7 +1347,7 @@ var torch = (function(exports){
function _mean(a, dim, keepdims) {
// In recursive call, when depth increases, subtract one from dim.
- // When we reach the dimention intended (dim === 0),
+ // When we reach the dimension intended (dim === 0),
// we add all elements in this dimension.
if ( dim == 0 ) {
let reduced = _div(a.reduce((a,b) => _add(a, b), 0), a.length);
@@ -1366,7 +1366,7 @@ var torch = (function(exports){
function _variance(a, dim, keepdims) {
// In recursive call, when depth increases, subtract one from dim.
- // When we reach the dimention intended (dim === 0),
+ // When we reach the dimension intended (dim === 0),
// we add all elements in this dimension.
if ( dim == 0 ) {
// Get mean over current dim:
@@ -1744,7 +1744,7 @@ var torch = (function(exports){
/**
* Creates new instance of the Tensor class.
* @param {object} data - Iterable containing the data to be stored in the Tensor.
- * @param {boolean} requires_grad - Wether to keep track of this tensor's gradients.
+ * @param {boolean} requires_grad - Whether to keep track of this tensor's gradients.
* @returns {object} New tensor.
*/
function tensor(data, requires_grad=false) {
@@ -1754,7 +1754,7 @@ var torch = (function(exports){
/**
* Creates new instance of the Tensor class filled with only zeros.
* @param {object} shape - List containing the shape of the new tensor Tensor.
- * @param {boolean} requires_grad - Wether to keep track of this tensor's gradients.
+ * @param {boolean} requires_grad - Whether to keep track of this tensor's gradients.
* @returns {object} New tensor.
*/
function zeros(shape, requires_grad=false) {
@@ -1764,7 +1764,7 @@ var torch = (function(exports){
/**
* Creates new instance of the Tensor class filled with only ones.
* @param {object} shape - List containing the shape of the new tensor Tensor.
- * @param {boolean} requires_grad - Wether to keep track of this tensor's gradients.
+ * @param {boolean} requires_grad - Whether to keep track of this tensor's gradients.
* @returns {object} New tensor.
*/
function ones(shape, requires_grad=false) {
@@ -1774,7 +1774,7 @@ var torch = (function(exports){
/**
* Creates new instance of a lower-triangular 2D Tensor.
* @param {object} shape - List containing the shape of the new tensor Tensor.
- * @param {boolean} requires_grad - Wether to keep track of this tensor's gradients.
+ * @param {boolean} requires_grad - Whether to keep track of this tensor's gradients.
* @returns {object} New tensor.
*/
function tril(shape, requires_grad=false) {
@@ -1793,7 +1793,7 @@ var torch = (function(exports){
/**
* Creates new instance of the Tensor class filled with numbers in a uniform distribution in ]0,1[.
* @param {object} shape - List containing the shape of the new tensor Tensor.
- * @param {boolean} requires_grad - Wether to keep track of this tensor's gradients.
+ * @param {boolean} requires_grad - Whether to keep track of this tensor's gradients.
* @returns {object} New tensor.
*/
function rand(shape, requires_grad=false) {
@@ -1803,8 +1803,8 @@ var torch = (function(exports){
/**
* Creates new instance of the Tensor class filled with numbers in a normal distribution.
* @param {object} shape - List containing the shape of the new tensor Tensor.
- * @param {boolean} requires_grad - Wether to keep track of this tensor's gradients.
- * @param {boolean} xavier - Wether to use xavier initialization (divide by square root of first input dimension).
+ * @param {boolean} requires_grad - Whether to keep track of this tensor's gradients.
+ * @param {boolean} xavier - Whether to use xavier initialization (divide by square root of first input dimension).
* @returns {object} New tensor.
*/
function randn(shape, requires_grad=false, xavier=false,) {
@@ -1827,7 +1827,7 @@ var torch = (function(exports){
* @param {number} low - Lowest number that can be sampled.
* @param {number} high - One above highest number that can be sampled.
* @param {object} shape - List containing the shape of the new tensor Tensor.
- * @param {boolean} requires_grad - Wether to keep track of this tensor's gradients.
+ * @param {boolean} requires_grad - Whether to keep track of this tensor's gradients.
* @returns {object} New tensor.
*/
function randint(low=0, high=1, shape=[1,], requires_grad=false) {
@@ -1908,10 +1908,10 @@ var torch = (function(exports){
function _broadcastSideways (out, b) {
if (b.length != out.length) {
if (b.length === 1){
- // Base case, contract existing dimention:
+ // Base case, contract existing dimension:
return [_sum(out, 0),];
} else if (out.length === 1){
- // Base case, expand existing dimention:
+ // Base case, expand existing dimension:
emptyArray = Array(b.length).fill(zeros);
return emptyArray.map(() => out[0]);
} else { Error(`Shapes ${utils.getShape(out)} and ${utils.getShape(b)} not broadcastable.`) };
@@ -1950,7 +1950,7 @@ var torch = (function(exports){
function broadcastUp (inElement, outElement) {
function _broadcastUp (inElement, outElement) {
if (utils.getShape(inElement).length + 1 === utils.getShape(outElement).length) {
- // Base case, create new dimention:
+ // Base case, create new dimension:
emptyArray = Array(outElement.length).fill(zeros);
return emptyArray.map(() => inElement);
} else {