My model is as follows:
embed_dim = 16
vocab_size = vocab.num_words
np_text_tensor = np.array(text_tensor_train)
print(np_text_tensor.shape)
input_img = keras.Input(shape=(np.array(text_tensor).shape[1], np.array(text_tensor).shape[2]))
print(input_img.shape)
list_input =
for i in range(np_text_tensor.shape[1]):
ExpandInputs = layers.Lambda(lambda x: tf.expand_dims(x,axis=1))
x = layers.Embedding(input_dim=vocab_size, output_dim=embed_dim, mask_zero=True)(ExpandInputs(input_img[:,i,:]))
Transpose1 = layers.Lambda(lambda x: tf.transpose(x, perm = [0,1,3,2]))
x = Transpose1(x)
x = layers.Conv2D(16, (1,1), activation=‘relu’, padding=‘same’, name=“name4”+str(i))(x)
x = layers.AveragePooling2D((1,1), padding=‘same’)(x)
x = layers.Conv2D(8, (1,1), activation=‘relu’, padding=‘same’, name=“name5”+str(i))(x)
encoded = x = layers.UpSampling2D((1,1))(x)
x = layers.Conv2D(16, (1,1), activation=‘relu’, padding=‘same’, name=“name6”+str(i))(encoded)
x = layers.UpSampling2D((1,1))(x)
x = layers.Conv2D(np.array(text_tensor).shape[2], (1,1), padding=‘same’, name=“name10”+str(i))(x)
x = layers.Flatten()(x)
ExpandDims =layers.Lambda(lambda x: tf.expand_dims(layers.Dense(np.array(text_tensor).shape[2])(x), 1) )
decoded = layers.Permute((2,1))(ExpandDims(x))
list_input.append(decoded)
print(layers.Concatenate()(list_input).shape)
Transpose = layers.Lambda(lambda x: tf.transpose(x, perm=[0,2,1]), name=“Transpose1”)
autoencoder = keras.Model(input_img, Transpose(layers.Concatenate()(list_input)))
optimiser = Adam(lr=0.01, beta_1=0.9, beta_2=0.999, amsgrad=False, decay=1e-8)
autoencoder.compile(optimizer=optimiser, loss=‘mean_squared_error’)
autoencoder.summary()
But I am getting the following error…any help appreciated
(None, 16, 15)
AttributeError Traceback (most recent call last)
/var/folders/4y/trqfxs_d5x7clsdrtcpdlrrh0000gn/T/ipykernel_6243/1380911180.py in
1 print(layers.Concatenate()(list_input).shape)
2 Transpose = layers.Lambda(lambda x: K.transpose(x), name=“Transpose1”)
----> 3 autoencoder = keras.Model(input_img, Transpose(layers.Concatenate()(list_input)))
4 optimiser = Adam(lr=0.01, beta_1=0.9, beta_2=0.999, amsgrad=False, decay=1e-8)
5 autoencoder.compile(optimizer=optimiser, loss=‘mean_squared_error’)
/opt/anaconda3/envs/tflatest4/lib/python3.7/site-packages/keras/legacy/interfaces.py in wrapper(*args, **kwargs)
89 warnings.warn('Update your ' + object_name + '
call to the ’ +
90 'Keras 2 API: ’ + signature, stacklevel=2)
—> 91 return func(*args, **kwargs)
92 wrapper._original_function = func
93 return wrapper
/opt/anaconda3/envs/tflatest4/lib/python3.7/site-packages/keras/engine/network.py in init(self, *args, **kwargs)
92 ‘inputs’ in kwargs and ‘outputs’ in kwargs):
93 # Graph network
—> 94 self._init_graph_network(*args, **kwargs)
95 else:
96 # Subclassed network
/opt/anaconda3/envs/tflatest4/lib/python3.7/site-packages/keras/engine/network.py in _init_graph_network(self, inputs, outputs, name, **kwargs)
239 # Keep track of the network’s nodes and layers.
240 nodes, nodes_by_depth, layers, layers_by_depth = _map_graph_network(
→ 241 self.inputs, self.outputs)
242 self._network_nodes = nodes
243 self._nodes_by_depth = nodes_by_depth
/opt/anaconda3/envs/tflatest4/lib/python3.7/site-packages/keras/engine/network.py in _map_graph_network(inputs, outputs)
1432 layer=layer,
1433 node_index=node_index,
→ 1434 tensor_index=tensor_index)
1435
1436 for node in reversed(nodes_in_decreasing_depth):
/opt/anaconda3/envs/tflatest4/lib/python3.7/site-packages/keras/engine/network.py in build_map(tensor, finished_nodes, nodes_in_progress, layer, node_index, tensor_index)
1419 tensor_index = node.tensor_indices[i]
1420 build_map(x, finished_nodes, nodes_in_progress, layer,
→ 1421 node_index, tensor_index)
1422
1423 finished_nodes.add(node)
/opt/anaconda3/envs/tflatest4/lib/python3.7/site-packages/keras/engine/network.py in build_map(tensor, finished_nodes, nodes_in_progress, layer, node_index, tensor_index)
1419 tensor_index = node.tensor_indices[i]
1420 build_map(x, finished_nodes, nodes_in_progress, layer,
→ 1421 node_index, tensor_index)
1422
1423 finished_nodes.add(node)
/opt/anaconda3/envs/tflatest4/lib/python3.7/site-packages/keras/engine/network.py in build_map(tensor, finished_nodes, nodes_in_progress, layer, node_index, tensor_index)
1419 tensor_index = node.tensor_indices[i]
1420 build_map(x, finished_nodes, nodes_in_progress, layer,
→ 1421 node_index, tensor_index)
1422
1423 finished_nodes.add(node)
/opt/anaconda3/envs/tflatest4/lib/python3.7/site-packages/keras/engine/network.py in build_map(tensor, finished_nodes, nodes_in_progress, layer, node_index, tensor_index)
1419 tensor_index = node.tensor_indices[i]
1420 build_map(x, finished_nodes, nodes_in_progress, layer,
→ 1421 node_index, tensor_index)
1422
1423 finished_nodes.add(node)
/opt/anaconda3/envs/tflatest4/lib/python3.7/site-packages/keras/engine/network.py in build_map(tensor, finished_nodes, nodes_in_progress, layer, node_index, tensor_index)
1419 tensor_index = node.tensor_indices[i]
1420 build_map(x, finished_nodes, nodes_in_progress, layer,
→ 1421 node_index, tensor_index)
1422
1423 finished_nodes.add(node)
/opt/anaconda3/envs/tflatest4/lib/python3.7/site-packages/keras/engine/network.py in build_map(tensor, finished_nodes, nodes_in_progress, layer, node_index, tensor_index)
1419 tensor_index = node.tensor_indices[i]
1420 build_map(x, finished_nodes, nodes_in_progress, layer,
→ 1421 node_index, tensor_index)
1422
1423 finished_nodes.add(node)
/opt/anaconda3/envs/tflatest4/lib/python3.7/site-packages/keras/engine/network.py in build_map(tensor, finished_nodes, nodes_in_progress, layer, node_index, tensor_index)
1419 tensor_index = node.tensor_indices[i]
1420 build_map(x, finished_nodes, nodes_in_progress, layer,
→ 1421 node_index, tensor_index)
1422
1423 finished_nodes.add(node)
/opt/anaconda3/envs/tflatest4/lib/python3.7/site-packages/keras/engine/network.py in build_map(tensor, finished_nodes, nodes_in_progress, layer, node_index, tensor_index)
1419 tensor_index = node.tensor_indices[i]
1420 build_map(x, finished_nodes, nodes_in_progress, layer,
→ 1421 node_index, tensor_index)
1422
1423 finished_nodes.add(node)
/opt/anaconda3/envs/tflatest4/lib/python3.7/site-packages/keras/engine/network.py in build_map(tensor, finished_nodes, nodes_in_progress, layer, node_index, tensor_index)
1419 tensor_index = node.tensor_indices[i]
1420 build_map(x, finished_nodes, nodes_in_progress, layer,
→ 1421 node_index, tensor_index)
1422
1423 finished_nodes.add(node)
/opt/anaconda3/envs/tflatest4/lib/python3.7/site-packages/keras/engine/network.py in build_map(tensor, finished_nodes, nodes_in_progress, layer, node_index, tensor_index)
1419 tensor_index = node.tensor_indices[i]
1420 build_map(x, finished_nodes, nodes_in_progress, layer,
→ 1421 node_index, tensor_index)
1422
1423 finished_nodes.add(node)
/opt/anaconda3/envs/tflatest4/lib/python3.7/site-packages/keras/engine/network.py in build_map(tensor, finished_nodes, nodes_in_progress, layer, node_index, tensor_index)
1419 tensor_index = node.tensor_indices[i]
1420 build_map(x, finished_nodes, nodes_in_progress, layer,
→ 1421 node_index, tensor_index)
1422
1423 finished_nodes.add(node)
/opt/anaconda3/envs/tflatest4/lib/python3.7/site-packages/keras/engine/network.py in build_map(tensor, finished_nodes, nodes_in_progress, layer, node_index, tensor_index)
1419 tensor_index = node.tensor_indices[i]
1420 build_map(x, finished_nodes, nodes_in_progress, layer,
→ 1421 node_index, tensor_index)
1422
1423 finished_nodes.add(node)
/opt/anaconda3/envs/tflatest4/lib/python3.7/site-packages/keras/engine/network.py in build_map(tensor, finished_nodes, nodes_in_progress, layer, node_index, tensor_index)
1419 tensor_index = node.tensor_indices[i]
1420 build_map(x, finished_nodes, nodes_in_progress, layer,
→ 1421 node_index, tensor_index)
1422
1423 finished_nodes.add(node)
/opt/anaconda3/envs/tflatest4/lib/python3.7/site-packages/keras/engine/network.py in build_map(tensor, finished_nodes, nodes_in_progress, layer, node_index, tensor_index)
1419 tensor_index = node.tensor_indices[i]
1420 build_map(x, finished_nodes, nodes_in_progress, layer,
→ 1421 node_index, tensor_index)
1422
1423 finished_nodes.add(node)
/opt/anaconda3/envs/tflatest4/lib/python3.7/site-packages/keras/engine/network.py in build_map(tensor, finished_nodes, nodes_in_progress, layer, node_index, tensor_index)
1419 tensor_index = node.tensor_indices[i]
1420 build_map(x, finished_nodes, nodes_in_progress, layer,
→ 1421 node_index, tensor_index)
1422
1423 finished_nodes.add(node)
/opt/anaconda3/envs/tflatest4/lib/python3.7/site-packages/keras/engine/network.py in build_map(tensor, finished_nodes, nodes_in_progress, layer, node_index, tensor_index)
1391 ValueError: if a cycle is detected.
1392 “”"
→ 1393 node = layer._inbound_nodes[node_index]
1394
1395 # Prevent cycles.
AttributeError: ‘NoneType’ object has no attribute ‘_inbound_nodes’