HarisIqbal88 / PlotNeuralNet

Latex code for making neural networks diagrams
MIT License
21.93k stars 2.86k forks source link

Updated to_connection function allowing to draw arrows any direction #83

Closed chrismaliszewski closed 3 years ago

chrismaliszewski commented 4 years ago

I updated to_connection function so it allows drawing an arrow in the same way as it's shown inside examples/VGG16/vgg16.tex file, that's:

\draw [connection]  (softmax-east)   -- node {\midarrow} ++(1.5,0,0);

Previously it was only possible to draw a line from 'east' to 'west' of an element, now it's possible to write ++(1.5,0,0) piece of the code.

Overwrite the existing code:

def to_connection( of, to, of_dir='east', to_dir='west'):
    if of_dir: of = '(' + of + '-' + of_dir + ')'
    if to_dir: to = '(' + to + '-' + to_dir + ')'

    return r"""
\draw [connection]  """+of+"""    -- node {\midarrow} """+to+""";
"""