federer
Version:
Experiments in asynchronous federated learning and decentralized learning
141 lines • 5.55 kB
TypeScript
import * as tf from "@tensorflow/tfjs-node";
/**
* Interface of an object that holds metadata about a {@link Dataset}.
*
* @typeParam T Type of the metadata
*/
export interface DatasetInfo<T> {
train: DataSubsetInfo<T>;
test: DataSubsetInfo<T>;
}
/**
* Interface of an object that holds metadata about a {@link DataSubset}.
*
* @typeParam T Type of the metadata
*/
export interface DataSubsetInfo<T> {
items: T;
labels: T;
}
/** Type of an object holding file paths for a serialized {@link Dataset} */
export declare type DatasetFilepaths = DatasetInfo<string>;
/** Type of an object holding file paths for a serialized {@link DataSubset} */
export declare type DataSubsetFilepaths = DataSubsetInfo<string>;
/**
* A dataset is a collection of data. This data is split into multiple
* {@link DataSubset}s. For now, only one split is possible: splitting into a
* training subset and a test subset.
*
* @typeParam IR The rank of the tensors holding items (IR means "Item Rank")
* @typeParam LR The rank of the tensors holding labels (LR means "Label Rank")
*/
export declare class Dataset<IR extends tf.Rank = tf.Rank, LR extends tf.Rank = tf.Rank> {
readonly data: {
readonly train: DataSubset<IR, LR>;
readonly test: DataSubset<IR, LR>;
};
constructor(data: {
readonly train: DataSubset<IR, LR>;
readonly test: DataSubset<IR, LR>;
});
/** Get the training subset */
get train(): DataSubset<IR, LR>;
/** Get the test subset */
get test(): DataSubset<IR, LR>;
/** Equivalent to `tf.dispose`. */
dispose(): void;
/**
* Counts the number of datapoints present in the {@link Dataset}. Each
* item and its associated label constitutes a single datapoint.
*
* @returns The number of datapoints in the {@link Dataset}
*/
countNumberDatapoints(): number;
concat(that: Dataset<IR, LR>): Dataset<IR, LR>;
/**
* Save the dataset to files.
*
* @param directory Directory to save to
* @param filenamePrefix Prefix of the dataset filenames
* @return A promise of the filepaths that the dataset has been saved to
*/
save(directory: string, filenamePrefix: string): Promise<DatasetFilepaths>;
/**
* Load a dataset from files.
*
* @param filePathsOrUrls Filepaths or URLs to load the dataset from
* @param expectedRanks Expected ranks of the items and labels in the dataset.
* If not provided, the ranks of the loaded data will not be checked.
* @return A promise of the loaded dataset, with the expected ranks.
*/
static load<IR extends tf.Rank = tf.Rank, LR extends tf.Rank = tf.Rank>(filePathsOrUrls: DatasetFilepaths, expectedRanks?: {
items?: IR;
labels?: LR;
}): Promise<Dataset<IR, LR>>;
/** Cast to a {@link Dataset} with given item and label ranks. */
withRanks<OIR extends IR, OLR extends LR>(ranks: {
items?: OIR;
labels?: OLR;
}): Dataset<OIR, OLR>;
}
/**
* A data subset is a subset of the datapoints of a {@link Dataset}.
*
* The {@link https://en.wikipedia.org/wiki/Training,_validation,_and_test_sets |
* standard terminology} for this is "dataset" or "set", but this is confusing
* because the full dataset is also called a "dataset". We therefore call this
* a "data subset", as it is a subset of the full dataset.
*
* @typeParam IR The rank of the tensors holding items (IR means "Item Rank")
* @typeParam LR The rank of the tensors holding labels (LR means "Label Rank")
*/
export declare class DataSubset<IR extends tf.Rank = tf.Rank, LR extends tf.Rank = tf.Rank> {
readonly data: {
readonly items: tf.Tensor<IR>;
readonly labels: tf.Tensor<LR>;
};
constructor(data: {
readonly items: tf.Tensor<IR>;
readonly labels: tf.Tensor<LR>;
});
get items(): tf.Tensor<IR>;
get labels(): tf.Tensor<LR>;
/** Equivalent to `tf.dispose`. */
dispose(): void;
concat(that: DataSubset<IR, LR>): DataSubset<IR, LR>;
/**Splits into two with split ratio */
split(split: number): DataSubset[];
/**
* Counts the number of datapoints present in the {@link DataSubset}. Each
* item and its associated label constitutes a single datapoint.
*
* @returns The number of datapoints in the {@link DataSubset}
*/
countNumberDatapoints(): number;
/**
* Save the data subset to files.
*
* @param directory Directory to save to
* @param filenamePrefix Prefix of the data subset filenames
* @return A promise of the filepaths that the data subset has been saved to
*/
save(directory: string, filenamePrefix: string): Promise<DataSubsetInfo<string>>;
/**
* Load a data subset from files.
*
* @param filepathOrURL Filepaths or URLs to load the data subset from
* @param expectedRanks Expected ranks of the items and labels in the dataset.
* If not provided, the ranks of the loaded data will not be checked.
* @return A promise of the loaded data subset, with the expected ranks.
*/
static load<IR extends tf.Rank, LR extends tf.Rank>(filepathOrURL: DataSubsetInfo<string>, expectedRanks?: {
items?: IR;
labels?: LR;
}): Promise<DataSubset<IR, LR>>;
/** Cast to a {@link DataSubset} with given item and label ranks. */
withRanks<OIR extends IR, OLR extends LR>(ranks: {
items?: OIR;
labels?: OLR;
}): DataSubset<OIR, OLR>;
}
//# sourceMappingURL=dataset.d.ts.map