Skip to content

Commit 9d4bb7d

Browse files
committed
[LAYERS] Format sources and add headers
1 parent 287058c commit 9d4bb7d

22 files changed

+493
-285
lines changed

tfjs-layers/src/main/scala/io/brunk/tfjs/layers/backend/state.scala

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,30 @@
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+
117
package io.brunk.tfjs.layers.backend
218

319
import scala.scalajs.js
420
import js.annotation._
521
import js.|
622

7-
823
@js.native
924
@JSGlobalScope
1025
object State extends js.Object {
11-
def getNextUniqueTensorId(): Double = js.native
12-
def getUid(prefix: String = ???): String = js.native
26+
def getNextUniqueTensorId(): Double = js.native
27+
def getUid(prefix: String = ???): String = js.native
1328
def getScalar(value: Double, dtype: DataType = ???): Scalar = js.native
14-
def disposeScalarCache(): Unit = js.native
29+
def disposeScalarCache(): Unit = js.native
1530
}
16-

tfjs-layers/src/main/scala/io/brunk/tfjs/layers/backend/tfjs_backend.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ object Tfjs_backend extends js.Object {
6060
reference: TensorND,
6161
indices: js.Array[Double] | Tensor1D,
6262
axis: Double = ???
63-
): TensorND = js.native
64-
def square(x: TensorND): TensorND = js.native
65-
def pow(x: TensorND, a: TensorND | Double): TensorND = js.native
63+
): TensorND = js.native
64+
def square(x: TensorND): TensorND = js.native
65+
def pow(x: TensorND, a: TensorND | Double): TensorND = js.native
6666
def biasAdd(x: TensorND, bias: TensorND, dataFormat: DataFormat = ???): TensorND = js.native
6767
def elu(x: TensorND, alpha: Double = ???): TensorND = js.native
6868
def softsign(x: TensorND): TensorND = js.native
@@ -71,8 +71,8 @@ object Tfjs_backend extends js.Object {
7171
level: Scalar,
7272
noiseShape: js.Array[Double] = ???,
7373
seed: Double = ???
74-
): TensorND = js.native
75-
def hardSigmoid(x: TensorND): TensorND = js.native
74+
): TensorND = js.native
75+
def hardSigmoid(x: TensorND): TensorND = js.native
7676
def inTrainPhase[T](x: js.Function0[T], alt: js.Function0[T], training: Boolean = ???): T =
7777
js.native
7878
}

tfjs-layers/src/main/scala/io/brunk/tfjs/layers/base_callbacks.scala

Lines changed: 68 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,123 @@
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+
117
package io.brunk.tfjs.layers
218

319
import scala.scalajs.js
420
import js.annotation._
521
import js.|
622

7-
823
@js.native
924
@JSGlobal
1025
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
1429
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
1631
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
2136
}
2237

2338
@js.native
2439
@JSGlobal
2540
class CallbackList protected () extends js.Object {
2641
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
3247
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
3449
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
3853
}
3954

4055
@js.native
4156
@JSGlobal
4257
class BaseLogger extends BaseCallback {
4358
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
4661
}
4762

4863
@js.native
4964
@JSGlobal
5065
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
5469
def onEpochEnd(epoch: Double, logs: UnresolvedLogs = ???): Promise[Unit] = js.native
55-
def syncData(): Promise[Unit] = js.native
70+
def syncData(): Promise[Unit] = js.native
5671
}
5772

5873
object History {
5974

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+
}
6782
}
6883

6984
@js.native
7085
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
7388
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
7590
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
7792
}
7893

7994
@js.native
8095
@JSGlobal
8196
class CustomCallback protected () extends BaseCallback {
8297
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
89104
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
91106
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
95110
}
96111

97112
@js.native
98113
@JSGlobalScope
99114
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
102123
}
103-

tfjs-layers/src/main/scala/io/brunk/tfjs/layers/callbacks.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ import js.{ Promise, | }
2727
@js.native
2828
@JSImport("@tensorflow/tfjs-layers", "Callback")
2929
abstract class Callback extends js.Object {
30-
var model: Model = js.native
31-
def setModel(model: Model): Unit = js.native
30+
var model: Model = js.native
31+
def setModel(model: Model): Unit = js.native
3232
}

0 commit comments

Comments
 (0)