|
| 1 | +/* |
| 2 | + * Copyright 2017 Sören Brunk |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
1 | 17 | package io.brunk.tfjs.layers
|
2 | 18 |
|
3 | 19 | import scala.scalajs.js
|
4 | 20 | import js.annotation._
|
5 | 21 | import js.|
|
6 | 22 |
|
7 |
| - |
8 | 23 | @js.native
|
9 | 24 | @JSGlobal
|
10 | 25 | abstract class BaseCallback extends js.Object {
|
11 |
| - var validationData: Tensor | js.Array[Tensor] = js.native |
12 |
| - var params: Params = js.native |
13 |
| - def setParams(params: Params): Unit = js.native |
| 26 | + var validationData: Tensor | js.Array[Tensor] = js.native |
| 27 | + var params: Params = js.native |
| 28 | + def setParams(params: Params): Unit = js.native |
14 | 29 | def onEpochBegin(epoch: Double, logs: UnresolvedLogs = ???): Promise[Unit] = js.native
|
15 |
| - def onEpochEnd(epoch: Double, logs: UnresolvedLogs = ???): Promise[Unit] = js.native |
| 30 | + def onEpochEnd(epoch: Double, logs: UnresolvedLogs = ???): Promise[Unit] = js.native |
16 | 31 | def onBatchBegin(batch: Double, logs: UnresolvedLogs = ???): Promise[Unit] = js.native
|
17 |
| - def onBatchEnd(batch: Double, logs: UnresolvedLogs = ???): Promise[Unit] = js.native |
18 |
| - def onTrainBegin(logs: UnresolvedLogs = ???): Promise[Unit] = js.native |
19 |
| - def onTrainEnd(logs: UnresolvedLogs = ???): Promise[Unit] = js.native |
20 |
| - def setModel(model: Container): Unit = js.native |
| 32 | + def onBatchEnd(batch: Double, logs: UnresolvedLogs = ???): Promise[Unit] = js.native |
| 33 | + def onTrainBegin(logs: UnresolvedLogs = ???): Promise[Unit] = js.native |
| 34 | + def onTrainEnd(logs: UnresolvedLogs = ???): Promise[Unit] = js.native |
| 35 | + def setModel(model: Container): Unit = js.native |
21 | 36 | }
|
22 | 37 |
|
23 | 38 | @js.native
|
24 | 39 | @JSGlobal
|
25 | 40 | class CallbackList protected () extends js.Object {
|
26 | 41 | def this(callbacks: js.Array[BaseCallback] = ???, queueLength: Double = ???) = this()
|
27 |
| - var callbacks: js.Array[BaseCallback] = js.native |
28 |
| - var queueLength: Double = js.native |
29 |
| - def append(callback: BaseCallback): Unit = js.native |
30 |
| - def setParams(params: Params): Unit = js.native |
31 |
| - def setModel(model: Container): Unit = js.native |
| 42 | + var callbacks: js.Array[BaseCallback] = js.native |
| 43 | + var queueLength: Double = js.native |
| 44 | + def append(callback: BaseCallback): Unit = js.native |
| 45 | + def setParams(params: Params): Unit = js.native |
| 46 | + def setModel(model: Container): Unit = js.native |
32 | 47 | def onEpochBegin(epoch: Double, logs: UnresolvedLogs = ???): Promise[Unit] = js.native
|
33 |
| - def onEpochEnd(epoch: Double, logs: UnresolvedLogs = ???): Promise[Unit] = js.native |
| 48 | + def onEpochEnd(epoch: Double, logs: UnresolvedLogs = ???): Promise[Unit] = js.native |
34 | 49 | def onBatchBegin(batch: Double, logs: UnresolvedLogs = ???): Promise[Unit] = js.native
|
35 |
| - def onBatchEnd(batch: Double, logs: UnresolvedLogs = ???): Promise[Unit] = js.native |
36 |
| - def onTrainBegin(logs: UnresolvedLogs = ???): Promise[Unit] = js.native |
37 |
| - def onTrainEnd(logs: UnresolvedLogs = ???): Promise[Unit] = js.native |
| 50 | + def onBatchEnd(batch: Double, logs: UnresolvedLogs = ???): Promise[Unit] = js.native |
| 51 | + def onTrainBegin(logs: UnresolvedLogs = ???): Promise[Unit] = js.native |
| 52 | + def onTrainEnd(logs: UnresolvedLogs = ???): Promise[Unit] = js.native |
38 | 53 | }
|
39 | 54 |
|
40 | 55 | @js.native
|
41 | 56 | @JSGlobal
|
42 | 57 | class BaseLogger extends BaseCallback {
|
43 | 58 | def onEpochBegin(epoch: Double, logs: UnresolvedLogs = ???): Promise[Unit] = js.native
|
44 |
| - def onBatchEnd(batch: Double, logs: UnresolvedLogs = ???): Promise[Unit] = js.native |
45 |
| - def onEpochEnd(epoch: Double, logs: UnresolvedLogs = ???): Promise[Unit] = js.native |
| 59 | + def onBatchEnd(batch: Double, logs: UnresolvedLogs = ???): Promise[Unit] = js.native |
| 60 | + def onEpochEnd(epoch: Double, logs: UnresolvedLogs = ???): Promise[Unit] = js.native |
46 | 61 | }
|
47 | 62 |
|
48 | 63 | @js.native
|
49 | 64 | @JSGlobal
|
50 | 65 | class History extends BaseCallback {
|
51 |
| - var epoch: js.Array[Double] = js.native |
52 |
| - var history: History.History = js.native |
53 |
| - def onTrainBegin(logs: UnresolvedLogs = ???): Promise[Unit] = js.native |
| 66 | + var epoch: js.Array[Double] = js.native |
| 67 | + var history: History.History = js.native |
| 68 | + def onTrainBegin(logs: UnresolvedLogs = ???): Promise[Unit] = js.native |
54 | 69 | def onEpochEnd(epoch: Double, logs: UnresolvedLogs = ???): Promise[Unit] = js.native
|
55 |
| - def syncData(): Promise[Unit] = js.native |
| 70 | + def syncData(): Promise[Unit] = js.native |
56 | 71 | }
|
57 | 72 |
|
58 | 73 | object History {
|
59 | 74 |
|
60 |
| -@js.native |
61 |
| -trait History extends js.Object { |
62 |
| - @JSBracketAccess |
63 |
| - def apply(key: String): js.Array[Double | Tensor] = js.native |
64 |
| - @JSBracketAccess |
65 |
| - def update(key: String, v: js.Array[Double | Tensor]): Unit = js.native |
66 |
| -} |
| 75 | + @js.native |
| 76 | + trait History extends js.Object { |
| 77 | + @JSBracketAccess |
| 78 | + def apply(key: String): js.Array[Double | Tensor] = js.native |
| 79 | + @JSBracketAccess |
| 80 | + def update(key: String, v: js.Array[Double | Tensor]): Unit = js.native |
| 81 | + } |
67 | 82 | }
|
68 | 83 |
|
69 | 84 | @js.native
|
70 | 85 | trait CustomCallbackConfig extends js.Object {
|
71 |
| - var onTrainBegin: js.Function1[Logs, Promise[Unit]] = js.native |
72 |
| - var onTrainEnd: js.Function1[Logs, Promise[Unit]] = js.native |
| 86 | + var onTrainBegin: js.Function1[Logs, Promise[Unit]] = js.native |
| 87 | + var onTrainEnd: js.Function1[Logs, Promise[Unit]] = js.native |
73 | 88 | var onEpochBegin: js.Function2[Double, Logs, Promise[Unit]] = js.native
|
74 |
| - var onEpochEnd: js.Function2[Double, Logs, Promise[Unit]] = js.native |
| 89 | + var onEpochEnd: js.Function2[Double, Logs, Promise[Unit]] = js.native |
75 | 90 | var onBatchBegin: js.Function2[Double, Logs, Promise[Unit]] = js.native
|
76 |
| - var onBatchEnd: js.Function2[Double, Logs, Promise[Unit]] = js.native |
| 91 | + var onBatchEnd: js.Function2[Double, Logs, Promise[Unit]] = js.native |
77 | 92 | }
|
78 | 93 |
|
79 | 94 | @js.native
|
80 | 95 | @JSGlobal
|
81 | 96 | class CustomCallback protected () extends BaseCallback {
|
82 | 97 | def this(config: CustomCallbackConfig) = this()
|
83 |
| - protected def trainBegin: js.Function1[Logs, Promise[Unit]] = js.native |
84 |
| - protected def trainEnd: js.Function1[Logs, Promise[Unit]] = js.native |
85 |
| - protected def epochBegin: js.Function2[Double, Logs, Promise[Unit]] = js.native |
86 |
| - protected def epochEnd: js.Function2[Double, Logs, Promise[Unit]] = js.native |
87 |
| - protected def batchBegin: js.Function2[Double, Logs, Promise[Unit]] = js.native |
88 |
| - protected def batchEnd: js.Function2[Double, Logs, Promise[Unit]] = js.native |
| 98 | + protected def trainBegin: js.Function1[Logs, Promise[Unit]] = js.native |
| 99 | + protected def trainEnd: js.Function1[Logs, Promise[Unit]] = js.native |
| 100 | + protected def epochBegin: js.Function2[Double, Logs, Promise[Unit]] = js.native |
| 101 | + protected def epochEnd: js.Function2[Double, Logs, Promise[Unit]] = js.native |
| 102 | + protected def batchBegin: js.Function2[Double, Logs, Promise[Unit]] = js.native |
| 103 | + protected def batchEnd: js.Function2[Double, Logs, Promise[Unit]] = js.native |
89 | 104 | def onEpochBegin(epoch: Double, logs: UnresolvedLogs = ???): Promise[Unit] = js.native
|
90 |
| - def onEpochEnd(epoch: Double, logs: UnresolvedLogs = ???): Promise[Unit] = js.native |
| 105 | + def onEpochEnd(epoch: Double, logs: UnresolvedLogs = ???): Promise[Unit] = js.native |
91 | 106 | def onBatchBegin(batch: Double, logs: UnresolvedLogs = ???): Promise[Unit] = js.native
|
92 |
| - def onBatchEnd(batch: Double, logs: UnresolvedLogs = ???): Promise[Unit] = js.native |
93 |
| - def onTrainBegin(logs: UnresolvedLogs = ???): Promise[Unit] = js.native |
94 |
| - def onTrainEnd(logs: UnresolvedLogs = ???): Promise[Unit] = js.native |
| 107 | + def onBatchEnd(batch: Double, logs: UnresolvedLogs = ???): Promise[Unit] = js.native |
| 108 | + def onTrainBegin(logs: UnresolvedLogs = ???): Promise[Unit] = js.native |
| 109 | + def onTrainEnd(logs: UnresolvedLogs = ???): Promise[Unit] = js.native |
95 | 110 | }
|
96 | 111 |
|
97 | 112 | @js.native
|
98 | 113 | @JSGlobalScope
|
99 | 114 | object Base_callbacks extends js.Object {
|
100 |
| - type Params = js.Dictionary[Double | String | Boolean | js.Array[Double] | js.Array[String] | js.Array[Boolean]] |
101 |
| - def standardizeCallbacks(callbacks: BaseCallback | js.Array[BaseCallback] | CustomCallbackConfig | js.Array[CustomCallbackConfig]): js.Array[BaseCallback] = js.native |
| 115 | + type Params = js.Dictionary[ |
| 116 | + Double | String | Boolean | js.Array[Double] | js.Array[String] | js.Array[Boolean] |
| 117 | + ] |
| 118 | + def standardizeCallbacks( |
| 119 | + callbacks: BaseCallback | js.Array[BaseCallback] | CustomCallbackConfig | js.Array[ |
| 120 | + CustomCallbackConfig |
| 121 | + ] |
| 122 | + ): js.Array[BaseCallback] = js.native |
102 | 123 | }
|
103 |
| - |
|
0 commit comments