Has any body know how to visualize the newly learned weights in t-sne. I have used keras for lstm with numeric features and also for text classification. I want to plot the newly learned weights in t-sne
I haven't visualized weights in a while, however I do visualize my embeddings for most data. I imagine that it probably is the same thing. Just call the layer and get the weights and then apply manifold learning on it to reduce it to 2 dimensions and then visualize it with a scatter plot.
Resources I often fall back on to are:
Here is some code for visualization to get you started:
def plot_embedding(x, y):
cm = plt.cm.get_cmap('RdYlGn')
f = plt.figure(figsize=(13, 13))
ax = plt.subplot(aspect='equal')
sc = ax.scatter(x[:,0], x[:,1], lw=0, s=40, c=y, cmap=cm)
plt.xlim(-25, 25)
plt.ylim(-25, 25)
ax.axis('off')
ax.axis('tight')
plt.show()
plot_embedding(transformed_weights, weight_labels)
Code to get you started for t-sne with sklearn
weights = model.get_layer(index={your layer index}).get_weights()
tsne = TSNE(n_components=2, random_state=random_seed, verbose=1)
transformed_weights = tsne.fit_transform(weights)
If this helps please close the issue :)
I'm trying to visualize the output of my last dense layer which output is 512. I've applied t-sne in order to reduce the dimensionality and visualize them. However, all the test samples have been place in a big cluster. Should I reduce the dimensionality with some other technique or it's just like that and I cannot do anything?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs, but feel free to re-open a closed issue if needed.
@AritzBi
According to this article in distill, you might want to try different parameter settings.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs, but feel free to re-open a closed issue if needed.
Most helpful comment
I haven't visualized weights in a while, however I do visualize my embeddings for most data. I imagine that it probably is the same thing. Just call the layer and get the weights and then apply manifold learning on it to reduce it to 2 dimensions and then visualize it with a scatter plot.
Resources I often fall back on to are:
Here is some code for visualization to get you started:
Code to get you started for t-sne with sklearn
If this helps please close the issue :)