Comments (5)
from nn-svg.
Glad you like it!
This is a great feature request, but sadly, I don't have the bandwidth to add features right now. I may circle back and add this some day, but not any day soon. You're also welcome to submit a PR, and we could work through getting this feature added.
from nn-svg.
@alexlenail thank you for the great work.
I support the suggestion. I think being able to upload weights in FCNN can be particularly informative. Maybe just uploading a simple txt that contains the matrices.
from nn-svg.
I succeeded into producing what seems to be a correct graphical representation of the weights. I had to harcode all weights values into the js code so the solution is very ugly code-wise but the result is amazing.
The input layer has some geometrical meaning here and some structure is visible now. Thanks again!
from nn-svg.
I develop a little here the workaround used to obtain that representation.
Suppose you are working with keras and want to train a [16,12,10,1] network (the default in the web interface).
import tensorflow as tf
from tensorflow.keras import layers
from tensorflow.keras import models
from tensorflow.keras import optimizers
#model definition
X_input = layers.Input((16,1))
X = layers.Dense(units=12,activation='relu')(X_input)
X = layers.Dense(units=10,activation='relu')(X)
X = layers.Dense(units=1,activation='sigmoid')(X)
model = models.Model(inputs=X_input,outputs=X)
#model compilation
optimizer = optimizers.Adam()
loss_fn = tf.keras.losses.binary_crossentropy
model.compile(optimizer, loss_fn)
#...
#here you might want to train the model
#...
#weights extraction
all_weights=[]
for layer_name in ['dense','dense_1','dense_2']:
weights=model.get_layer(layer_name).get_weights()
weights=np.abs(weights[0].flatten()) #take the absolute value and flatten
weights=weights/np.max(weights) #weight normalization by layer
all_weights=np.append(all_weights,weights)
#save the values in a txt file
np.savetxt('all_weights.txt',all_weights,newline=',',fmt='%f')
This will be enough to obtain the weight values in a txt file. This weight values are ordered and it can be tested easily this ordenation is the one you require in the next block. Now we are ready to harcode this weight values in the js code. We have to edit the FFCN.js file.
// harcode the weights values into a js array
const myWeigths = [ "HERE YOU SHOULD COPY THE CONTENT OF all_weights.txt" ]
// initialise a "global" counter
var count=0
// define a function that read a weight value and increases the counter
function readWeigth() {
aux = myWeigths[count]
count = count+1
return aux
}
// edit the line in wich the weights of the graph are defined as follows (just look for "randomWeight()" and change to readWeigth()")
graph.links = pairWise(graph.nodes).map((nodes) => nodes[0].map(left => nodes[1].map(right => {return right.node_index >= 0 ? {'id':left.id+'-'+right.id, 'source':left.id,'target':right.id,'weight':readWeigth()} : null })));
It turns out the function is called sequentially in the same order we saved the weights on the txt file. Then you open index.html with your web explorer and play with the interface in order to produce your representation.
Most likely the network arquitecture you want to represent is different to the default, so you have to edit the default arquitecture in index.html. That's straightforward.
Credits to @Jur314 for helping with the js.
from nn-svg.
Related Issues (20)
- Label the edges with weight values HOT 3
- Unicode characters not supported HOT 4
- Instructions to use API to generate and save an SVG file HOT 3
- feature request: "Fully-Connected graph groups mode" HOT 4
- How to create jpeg(300+ dpi)/png publication quality images from NN-SVG HOT 2
- Cannot use the web tool to configure SVGs HOT 7
- Feature request: Scaling for vectors in LeNet HOT 1
- Link to Underscore.js is broken HOT 1
- Tutorial HOT 1
- Multiple outputs? HOT 4
- Bias should be added to input layer HOT 4
- Feature request: Export as PNG HOT 2
- Feature Request: Models with Branches HOT 1
- Cannot remove dense layer on LeNet Style HOT 1
- Font size HOT 1
- Feature request: Color each layer of nodes individually
- Feature request: Export as NN code HOT 1
- Height and width confusion in show dimensions text using AlexNet webGL HOT 2
- Not an issue, but a suggestion/query HOT 5
- Support residual/skip connections HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nn-svg.