Thank you for sharing the primer.
Everything works except the last code block.
sequence_index = 1999 # You can change this to compute the gradient for a different example. But if so, change the coloring below as well.
sal = compute_salient_bases(model, input_features[sequence_index])
plt.figure(figsize=[16,5])
barlist = plt.bar(np.arange(len(sal)), sal)
[barlist[i].set_color('C1') for i in range(5,17)] # Change the coloring here if you change the sequence index.
plt.xlabel('Bases')
plt.ylabel('Magnitude of saliency values')
plt.xticks(np.arange(len(sal)), list(sequences[sequence_index]));
plt.title('Saliency map for bases in one of the positive sequences'
' (green indicates the actual bases in motif)');
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
[<ipython-input-10-b6400cc2276d>](https://localhost:8080/#) in <cell line: 2>()
1 sequence_index = 1999 # You can change this to compute the gradient for a different example. But if so, change the coloring below as well.
----> 2 sal = compute_salient_bases(model, input_features[sequence_index])
3
4 plt.figure(figsize=[16,5])
5 barlist = plt.bar(np.arange(len(sal)), sal)
[<ipython-input-9-9666bf2dbd7f>](https://localhost:8080/#) in compute_salient_bases(model, x)
3 def compute_salient_bases(model, x):
4 input_tensors = [model.input]
----> 5 gradients = model.optimizer.get_gradients(model.output[0][1], model.input)
6 compute_gradients = K.function(inputs = input_tensors, outputs = gradients)
7
AttributeError: 'Adam' object has no attribute 'get_gradients'