Skip to content

Commit 752369e

Browse files
committed
Remove slots field
1 parent 4741e39 commit 752369e

File tree

1 file changed

+1
-27
lines changed
  • tensorflow/src/main/kotlin/org/jetbrains/kotlinx/dl/api/core/optimizer

1 file changed

+1
-27
lines changed

tensorflow/src/main/kotlin/org/jetbrains/kotlinx/dl/api/core/optimizer/Optimizer.kt

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ import org.tensorflow.op.core.Variable
2222
* @property [clipGradient] Strategy of gradient clipping as subclass of [ClipGradientAction].
2323
*/
2424
public abstract class Optimizer(public val clipGradient: ClipGradientAction) {
25-
/**
26-
* Top level map key is the variable name, lower level map key is the slot name.
27-
*/
28-
private lateinit var slots: MutableMap<String, MutableMap<String, Variable<Float>>>
29-
3025
/**
3126
* Prepares targets for optimization process.
3227
*
@@ -43,8 +38,6 @@ public abstract class Optimizer(public val clipGradient: ClipGradientAction) {
4338
tf: Ops,
4439
loss: Operand<Float>
4540
): List<Operand<Float>> {
46-
slots = mutableMapOf()
47-
4841
val gradients: Gradients = computeGradients(tf, loss, weights)
4942
return applyGradients(graph, tf, weights, gradients)
5043
}
@@ -79,7 +72,7 @@ public abstract class Optimizer(public val clipGradient: ClipGradientAction) {
7972

8073
/**
8174
* Creates a slot in the graph for the specified variable with the specified name. Adds the slot's
82-
* initializer to the graph's initializers, and the slot to the optimiser's slot map.
75+
* initializer to the graph's initializers.
8376
*
8477
* @param [graph] KGraph to be updated.
8578
* @param [tf] TensorFlow graph API for building operations.
@@ -103,28 +96,9 @@ public abstract class Optimizer(public val clipGradient: ClipGradientAction) {
10396
graph.addOptimizerVariableInitializer(slotInit)
10497
graph.addOptimizerVariable(slot)
10598

106-
val varName = variable.op().name()
107-
108-
val variables: MutableMap<String, Variable<Float>> = slots.computeIfAbsent(slotName) { mutableMapOf() }
109-
variables[varName] = slot
11099
return slot
111100
}
112101

113-
/**
114-
* Gets the slot associated with the specified variable and slot name.
115-
*
116-
* @param [varName] The variable to lookup.
117-
* @param [slotName] The slot name.
118-
* @return The slot.
119-
*/
120-
protected fun getSlot(
121-
varName: String,
122-
slotName: String
123-
): Variable<Float> {
124-
val variables: MutableMap<String, Variable<Float>> = slots[slotName]!!
125-
return variables[varName]!!
126-
}
127-
128102
/**
129103
* Creates name for [variable] used in slot with name [slotName].
130104
*/

0 commit comments

Comments
 (0)