Say i have a python class Sum()
with a method add()
that can take a list of numbers for manipulation, say
sum = Sum()
sum.add([5, 8, 2])
I want to instead call the .add
method on each list item by 'appending' to itself. How can i achieve this?
sum.add(5).add(8).add(2)
For clarity, i have seen the two implementations in keras
model = tf.keras.Sequential([
hub_layer,
tf.keras.layers.Dense(16, activation='relu'),
tf.keras.layers.Dense(1)
])
Which can also be represented as
model = tf.keras.Sequential()
model.add(hub_layer)
model.add(tf.keras.layers.Dense(16, activation='relu'))
model.add(tf.keras.layers.Dense(1))
I want to achieve the second for the above scenarios, whereby I call the .add
method n
times for each item I have in a list