forked from tensorflow/tfjs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
74 lines (64 loc) · 2.29 KB
/
types.ts
File metadata and controls
74 lines (64 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
/** Defines allowable data types for tensors. */
import {NamedTensorMap, Scalar, Tensor} from '@tensorflow/tfjs-core';
import {Shape} from './keras_format/common';
export interface NamedTensor {
name: string;
tensor: Tensor;
}
export type HasShape = {
shape: Shape;
};
/**
* Type for loss a metric function.
*
* Takes a true value and a predicted value, and returns a loss or metric value.
*/
export type LossOrMetricFn = (yTrue: Tensor, yPred: Tensor) => Tensor;
/**
* Type for a regularizer function.
*/
export type RegularizerFn = () => Scalar;
/*
* The type for an RNN step function.
* The arguments are:
* - inputs: Input data, with shape `[sapmles, ...]`.
* The return values are:
* - outputs: tensor with shape `[samples, outputDim]` (no time dimension).
* - newStates: Array of tensors. The `Array` has the same length as `states`
* in the input arguments. Each `tf.Tensor` has the same shape as the
* corresponding element in `states`.
*/
export type RnnStepFunction =
(inputs: Tensor, states: Tensor[]) => [Tensor, Tensor[]];
/**
* A single Tensor or a non-nested collection of Tensors.
*
* An object of this type can always be reduced to `Tensor[]`. A single
* 'Tensor' becomes `[Tensor]`. A `Tensor[]` is unchanged. A `NamedTensorMap`
* can be converted with the help of a list of names, providing the order in
* which the Tensors should appear in the resulting array.
*/
export type TensorOrArrayOrMap = Tensor|Tensor[]|NamedTensorMap;
/**
* Type representing a loosely-typed bundle of keyword arguments.
*
* This is a looser type than PyJsonDict/serialization.ConfigDict as it
* can contain arbitrary objects as its values. It is most appropriate
* for functions that pass through keyword arguments to other functions
* without knowledge of the structure. If the function can place type
* restrictions on the keyword arguments, it should via the Config
* interface convention used throughout.
*/
export type Kwargs = {
// tslint:disable-next-line:no-any
[key: string]: any
};