1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | import { CustomCallback } from '@tensorflow/tfjs';
|
18 | export declare const progressBarHelper: {
|
19 | ProgressBar: any;
|
20 | log: Function;
|
21 | };
|
22 |
|
23 |
|
24 |
|
25 | export declare class ProgbarLogger extends CustomCallback {
|
26 | private numTrainBatchesPerEpoch;
|
27 | private progressBar;
|
28 | private currentEpochBegin;
|
29 | private epochDurationMillis;
|
30 | private usPerStep;
|
31 | private batchesInLatestEpoch;
|
32 | private terminalWidth;
|
33 | private readonly RENDER_THROTTLE_MS;
|
34 | |
35 |
|
36 |
|
37 | constructor();
|
38 | private formatLogsAsMetricsContent;
|
39 | private isFieldRelevant;
|
40 | }
|
41 | /**
|
42 | * Get a succint string representation of a number.
|
43 | *
|
44 | * Uses decimal notation if the number isn't too small.
|
45 | * Otherwise, use engineering notation.
|
46 | *
|
47 | * @param x Input number.
|
48 | * @return Succinct string representing `x`.
|
49 | */
|
50 | export declare function getSuccinctNumberDisplay(x: number): string;
|
51 | /**
|
52 | * Determine the number of decimal places to display.
|
53 | *
|
54 | * @param x Number to display.
|
55 | * @return Number of decimal places to display for `x`.
|
56 | */
|
57 | export declare function getDisplayDecimalPlaces(x: number): number;
|
58 | export interface TensorBoardCallbackArgs {
|
59 | |
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 | updateFreq?: 'batch' | 'epoch';
|
73 | }
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 | export declare class TensorBoardCallback extends CustomCallback {
|
81 | readonly logdir: string;
|
82 | private trainWriter;
|
83 | private valWriter;
|
84 | private batchesSeen;
|
85 | private epochsSeen;
|
86 | private readonly args;
|
87 | constructor(logdir?: string, args?: TensorBoardCallbackArgs);
|
88 | private logMetrics;
|
89 | private ensureTrainWriterCreated;
|
90 | private ensureValWriterCreated;
|
91 | }
|
92 | /**
|
93 | * Callback for logging to TensorBoard during training.
|
94 | *
|
95 | * Writes the loss and metric values (if any) to the specified log directory
|
96 | * (`logdir`) which can be ingested and visualized by TensorBoard.
|
97 | * This callback is usually passed as a callback to `tf.Model.fit()` or
|
98 | * `tf.Model.fitDataset()` calls during model training. The frequency at which
|
99 | * the values are logged can be controlled with the `updateFreq` field of the
|
100 | * configuration object (2nd argument).
|
101 | *
|
102 | * Usage example:
|
103 | * ```js
|
104 | * // Constructor a toy multilayer-perceptron regressor for demo purpose.
|
105 | * const model = tf.sequential();
|
106 | * model.add(
|
107 | * tf.layers.dense({units: 100, activation: 'relu', inputShape: [200]}));
|
108 | * model.add(tf.layers.dense({units: 1}));
|
109 | * model.compile({
|
110 | * loss: 'meanSquaredError',
|
111 | * optimizer: 'sgd',
|
112 | * metrics: ['MAE']
|
113 | * });
|
114 | *
|
115 | * // Generate some random fake data for demo purpose.
|
116 | * const xs = tf.randomUniform([10000, 200]);
|
117 | * const ys = tf.randomUniform([10000, 1]);
|
118 | * const valXs = tf.randomUniform([1000, 200]);
|
119 | * const valYs = tf.randomUniform([1000, 1]);
|
120 | *
|
121 | * // Start model training process.
|
122 | * await model.fit(xs, ys, {
|
123 | * epochs: 100,
|
124 | * validationData: [valXs, valYs],
|
125 | *
|
126 | * callbacks: tf.node.tensorBoard('/tmp/fit_logs_1')
|
127 | * });
|
128 | * ```
|
129 | *
|
130 | * Then you can use the following commands to point tensorboard
|
131 | * to the logdir:
|
132 | *
|
133 | * ```sh
|
134 | * pip install tensorboard # Unless you've already installed it.
|
135 | * tensorboard --logdir /tmp/fit_logs_1
|
136 | * ```
|
137 | *
|
138 | * @param logdir Directory to which the logs will be written.
|
139 | * @param args Optional configuration arguments.
|
140 | * @returns An instance of `TensorBoardCallback`, which is a subclass of
|
141 | * `tf.CustomCallback`.
|
142 | */
|
143 | /**
|
144 | * @doc {heading: 'TensorBoard', namespace: 'node'}
|
145 | */
|
146 | export declare function tensorBoard(logdir?: string, args?: TensorBoardCallbackArgs): TensorBoardCallback;
|