deepbox
Upgrading from 1.0
Deepbox 1.5 is backward compatible with 1.0. No export was removed or renamed. This page lists the places where results or types changed.
Short version
Your 1.0 code still compiles and runs. Check the dtype rules, any tests that pin exact random values, and TypeScript code that annotates the result of forward as Tensor.
Float operations keep the input float dtype. A float32 tensor stays float32 through exp, sqrt, sum, mean, activations and the rest, where 1.0 returned float64 for several of them. Integer input to an operation with a fractional result (mean, div, exp, softmax and similar) gives float32. Integer reductions keep the integer dtype. Index results (argsort, argmax, digitize, searchsorted, nonzero) are int32.
Call t.astype("float64") when you need double precision.
Binary operations on tensors of different dtypes now promote the way PyTorch does, instead of throwing DTypeError. A JavaScript number never changes a tensor's dtype.
import { promoteTypes } from "deepbox/core";import { tensor } from "deepbox/ndarray"; const ints = tensor([1, 2, 3], { dtype: "int32" });const floats = tensor([0.5, 0.5, 0.5], { dtype: "float32" }); console.log(ints.add(floats).dtype); // float32console.log(promoteTypes("float32", "float64")); // float64Data no longer has to be wrapped in parameter(). When gradient tracking is on and the module has trainable parameters, module.forward(tensor) returns a GradTensor that tracks the weights. Inside noGrad() it returns a plain Tensor. Optimizers skip parameters that have no gradient, as PyTorch does. In 1.0 they threw NotFittedError.
Layers without trainable parameters, such as pooling, dropout, activations and normalization without affine parameters, return a plain Tensor for plain input. Read the result directly instead of going through .tensor.
In TypeScript, layer.forward(tensor) is now typed AnyTensor, which is Tensor | GradTensor. Code that annotated the result as Tensor should use AnyTensor. Custom modules can declare a single forward(x: AnyTensor): AnyTensor.
Every public name is now camelCase, for example matrixPower, toDatetime, ttestInd, crossValScore, multivariateNormal and checkXY. The snake_case names from 1.0 keep working and are marked @deprecated in the type declarations. The same holds for methods and options, and when both spellings of an option are given the camelCase one wins.
Several modules replaced weak private generators with the library's seeded generator: trees and forests, bagging, k-means, splitters, QuantileTransformer and DataFrame.sample. The same seed still gives the same result from run to run, but not the same result as 1.0. Layer weight initialization also matches PyTorch now, so seeded models start from different weights. Tests that pin exact random values need new expected values.
Many functions now throw a typed error where 1.0 returned silent garbage: NaN or infinite input to estimators, invalid buffers in readParquet and readXlsx, a truncated CIFAR-10 download, string or complex input to numeric code, and invalid parameters. A few error classes changed to a more precise one. For example, solveBanded throws InvalidParameterError for an invalid band width.
SpectralNormregisters the wrapped module as the childmodule, so state dicts saved from 1.0 models that containSpectralNormdo not load.mannwhitneyuandwilcoxonuse exact p-values for small samples and themannwhitneyustatistic is U1, following current SciPy.- Layers compute in their parameter dtype and cast the input, as
Linearalready did, so recurrent layers accept integer input. parameter(...)keepsrequiresGrad: truewhen you create it insidenoGrad(). Only the operations run insidenoGrad()skip recording.
About 1,500 fixes landed in 1.5.0, and some change numbers you may have stored in tests. Run your numerical tests again before you trust old expected values. The most visible ones:
Trainerpassed plain tensors to the model, so layers returned untracked results and real models did not train. It now trains.OneClassSVMflagged 88 percent of the training rows as outliers withnu = 0.1. It now flags about 10 percent, as scikit-learn does.mannwhitneyu,wilcoxon,kstest,ks2sampandandersonnow match SciPy 1.17, including exact p-values for small samples.cumsumandcumprodwithout an axis returned the wrong shape,floorDivandmoddisagreed with NumPy for large or fractional values, andint32multiplication lost low bits.- Non-symmetric
eignow uses a real double-shift QR algorithm. fetch20NewsgroupsandfetchIMDBused default URLs that returned 404. They now load the official archives.- Plot tick labels (2.5 was drawn as 3), PNG grids and text, and
twinxaxes were corrected.
The complete list of fixes and additions is in the changelog.
Found a mistake? Open an issue.