My network has multiple inputs where one of those inputs is an index that is used in the network to index into other tensors.
I am having issues using the tensor as an index.
class MemoryLayer(tf.keras.layers.Layer):
def __init__(self, memory_size, k, **kwargs):
super().__init__(kwargs)
self.memory_size = memory_size
self.k = k
def build(self,input_shape):
# Set up the memory_var
# Shape of input is [(1,3,6), (1,3)]
def call(self, input):
for i in range(3):
statement = input[0][0,i]
cluster = input[1][0,i]
old_sub_mem = self.memory_var[cluster, :-1] #Error here
# Here should be a bunch of stuff I removed because its not relevant
return tf.expand_dims(self.memory_var, axis=0)
I get a TypeError
saying that <tf.Tensor 'memory_layer_19/strided_slice_2:0' shape=() dtype=float32>
isn't a valid index. I tried calling .numpy()
on input[1]
but this doesn't work as the tensor has no shape. From the data I input cluster
should be a single number.