but i copy the solution:
my code: user_NN = tf.keras.models.Sequential([
### START CODE HERE ###
tf.keras.layers.Dense(256, activation=‘relu’),
tf.keras.layers.Dense(128, activation=‘relu’),
tf.keras.layers.Dense(num_outputs),
### END CODE HERE ###
])
item_NN = tf.keras.models.Sequential([
### START CODE HERE ###
tf.keras.layers.Dense(256, activation=‘relu’),
tf.keras.layers.Dense(128, activation=‘relu’),
tf.keras.layers.Dense(num_outputs),
### END CODE HERE ###
])
and then
the next cell ; # Public tests
from public_tests import *
test_tower(user_NN)
test_tower(item_NN)
the error:
AttributeError Traceback (most recent call last)
in
1 # Public tests
2 from public_tests import *
----> 3 test_tower(user_NN)
4 test_tower(item_NN)
~/work/public_tests.py in test_tower(target)
15 assert type(layer) == expected[i][0],
16 f"Wrong type in layer {i}. Expected {expected[i][0]} but got {type(layer)}"
—> 17 assert layer.output.shape.as_list() == expected[i][1],
18 f"Wrong number of units in layer {i}. Expected {expected[i][1]} but got {layer.output.shape.as_list()}"
19 assert layer.activation == expected[i][2], \
/opt/conda/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/base_layer.py in output(self)
1551 “”"
1552 if not self._inbound_nodes:
→ 1553 raise AttributeError(‘Layer ’ + self.name + ’ has no inbound nodes.’)
1554 return self._get_node_attribute_at_index(0, ‘output_tensors’, ‘output’)
1555
AttributeError: Layer dense_257 has no inbound nodes.
C3_W2_RecSysNN_Assignment” notebook yes.
I alright put this number, but the next cell: # Public tests
from public_tests import *
test_tower(user_NN)
test_tower(item_NN)
the error is:
AttributeError Traceback (most recent call last)
in
1 # Public tests
2 from public_tests import *
----> 3 test_tower(user_NN)
4 test_tower(item_NN)
~/work/public_tests.py in test_tower(target)
15 assert type(layer) == expected[i][0],
16 f"Wrong type in layer {i}. Expected {expected[i][0]} but got {type(layer)}"
—> 17 assert layer.output.shape.as_list() == expected[i][1],
18 f"Wrong number of units in layer {i}. Expected {expected[i][1]} but got {layer.output.shape.as_list()}"
19 assert layer.activation == expected[i][2], \
/opt/conda/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/base_layer.py in output(self)
1551 “”"
1552 if not self._inbound_nodes:
→ 1553 raise AttributeError(‘Layer ’ + self.name + ’ has no inbound nodes.’)
1554 return self._get_node_attribute_at_index(0, ‘output_tensors’, ‘output’)
1555
# GRADED_CELL
# UNQ_C1
num_outputs = 32
tf.random.set_seed(1)
user_NN = tf.keras.models.Sequential([
### START CODE HERE ###
tf.keras.layers.Dense(256, activation='relu'),
tf.keras.layers.Dense(128, activation='relu'),
tf.keras.layers.Dense(num_outputs),
### END CODE HERE ###
])
item_NN = tf.keras.models.Sequential([
### START CODE HERE ###
tf.keras.layers.Dense(256, activation='relu'),
tf.keras.layers.Dense(128, activation='relu'),
tf.keras.layers.Dense(num_outputs),
### END CODE HERE ###
])
# create the user input and point to the base network
input_user = tf.keras.layers.Input(shape=(num_user_features))
vu = user_NN(input_user)
vu = tf.linalg.l2_normalize(vu, axis=1)
# create the item input and point to the base network
input_item = tf.keras.layers.Input(shape=(num_item_features))
vm = item_NN(input_item)
vm = tf.linalg.l2_normalize(vm, axis=1)
# compute the dot product of the two vectors vu and vm
output = tf.keras.layers.Dot(axes=1)([vu, vm])
# specify the inputs and output of the model
model = Model([input_user, input_item], output)
model.summary()
I got it, that was my first post here , I will be avoid next time.
Please guide how i can post my question separately instead of commenting on others post. I’m new user
Go to the forum topic for your course. See the “Course Q&A” topic in the left-side menu. You select the course, then the specific course area, then you will see a “New Topic” button.