Skip to content

Commit 0340045

Browse files
Update units.py
1 parent df7b200 commit 0340045

File tree

1 file changed

+1
-25
lines changed

1 file changed

+1
-25
lines changed

cerebros/units/units.py

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,7 @@
1010
simple_sigmoid, \
1111
DenseAutoMlStructuralComponent, DenseLateralConnectivity
1212

13-
class TernaryDenseLayer(tf.keras.layers.Layer):
14-
def __init__(self, units, input_dim, **kwargs):
15-
super(TernaryDenseLayer, self).__init__(**kwargs)
16-
self.units = units
17-
self.input_dim = input_dim
18-
self.ternary_weights = self.add_weight(name='ternary_weights',
19-
shape=(input_dim, units),
20-
initializer='glorot_uniform',
21-
trainable=True)
22-
23-
def build(self, input_shape):
24-
# Create a trainable weight variable for the bias
25-
self.bias = self.add_weight(name='bias',
26-
shape=(self.units,),
27-
initializer='zeros',
28-
trainable=True)
29-
30-
def call(self, inputs):
31-
# Apply ternary weights to the input vector
32-
ternary_inputs = tf.cast(tf.sign(inputs), tf.float32) * tf.abs(inputs)
33-
output = tf.matmul(ternary_inputs, self.ternary_weights)
34-
# Add bias and apply activation function
35-
output = tf.nn.bias_add(output, self.bias)
36-
output = tf.nn.relu(output)
37-
return output
13+
from custom.custom import TernaryDenseLayer
3814

3915
class Unit(NeuralNetworkFutureComponent):
4016
def __init__(self,

0 commit comments

Comments
 (0)