Tikz : Plot a function inside a node











up vote
4
down vote

favorite












I am using tikz to reproduce a Matlab picturization of a neural network. The original figure that I need to reproduce is this :



enter image description here



I am stuck at plotting the tanh function and the linear function inside the node.
I have tried two methods as of now : pgfplots and tikz plot function but I am unable to move the plot inside the rectangle.



documentclass[class=minimal,border=0pt]{standalone}
usepackage{ifthen}
usepackage{pgf,tikz}
usepackage{pgfplots}
pgfplotsset{compat=1.15}
usepackage{tikz-3dplot}
usepackage{mathrsfs}
usetikzlibrary{arrows}
usepackage{tkz-euclide}
usetkzobj{all}
pagestyle{empty}

begin{document}

definecolor{bg_deepred}{RGB}{150,0,24}

begin{tikzpicture}
[grid/.style={very thin,gray},
conn/.style={->,blue,very thick},
inp/.style={opacity=.5,very thick,black,fill=red},
oup/.style={opacity=.5,very thick,black,fill=blue},
int/.style={opacity=.5,very thick,black,fill=gray},
int1/.style={opacity=.5, thick, black, fill=yellow},
plane/.style={opacity=.6,draw=none,fill=yellow!80!black},
line/.style={very thick}]

% input layer
draw[inp,rounded corners] (-1, 2.5) rectangle (1, -3.8) {};

% scalar values (only internal circles)
shade[ball color=green] (0,.5) circle (.5cm);
draw (0,0.5) node[scale=2]{2};
shade[ball color=green] (0,1.7) circle (.5cm);
draw (0,1.7) node[scale=2]{1};

draw (0,-0.4) node[circle,fill,inner sep=1pt](a){};
draw (0,-0.7) node[circle,fill,inner sep=1pt](b){};
draw (0,-1.0) node[circle,fill,inner sep=1pt](c){};


shade[ball color=green] (0,-1.8) circle (.5cm);
draw (0,-1.8) node[scale=2]{26};
shade[ball color=green] (0,-3) circle (.5cm);
draw (0,-3) node[scale=2]{27};
%draw [fill=bg_deepred](0,y) circle (2.5mm);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% input layer
draw[int,rounded corners] (3, 2) rectangle (8, -3) {};

draw[int1] (3.5, 1.5) rectangle (5, 0) {};
draw[int1] (3.5, -1) rectangle (5, -2.5) {};

draw[int1] (6.0, 1.5) rectangle (7.5, -2.5) {};

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% output layer
draw[int,rounded corners] (10, 2) rectangle (15, -3) {};

draw[int1] (10.5, 1.5) rectangle (12, 0) {};
draw[int1] (10.5, -1) rectangle (12, -2.5) {};
draw[int1] (13.0, 1.5) rectangle (14.5, -2.5) {};

%tikz version not working
begin{scope}[x=1pt,y=10pt,shift={(100,0)}]
draw (5,5) plot[domain=-8:8] (x,{1/(1 + exp(-x))-0.5});
end{scope}

%pgfplots version not working
begin{axis}[width=5.5cm,height=4cm,ymin=-1.25,ymax=1.25,xmin=-5,xmax=5]
addplot[blue,smooth] {tanh(x)};
end{axis}


end{tikzpicture}

end{document}


This gives me the followin with the blue curve provided using pgfplots package and the black one provided by the tikzplot package.



enter image description here










share|improve this question







New contributor




datapanda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
























    up vote
    4
    down vote

    favorite












    I am using tikz to reproduce a Matlab picturization of a neural network. The original figure that I need to reproduce is this :



    enter image description here



    I am stuck at plotting the tanh function and the linear function inside the node.
    I have tried two methods as of now : pgfplots and tikz plot function but I am unable to move the plot inside the rectangle.



    documentclass[class=minimal,border=0pt]{standalone}
    usepackage{ifthen}
    usepackage{pgf,tikz}
    usepackage{pgfplots}
    pgfplotsset{compat=1.15}
    usepackage{tikz-3dplot}
    usepackage{mathrsfs}
    usetikzlibrary{arrows}
    usepackage{tkz-euclide}
    usetkzobj{all}
    pagestyle{empty}

    begin{document}

    definecolor{bg_deepred}{RGB}{150,0,24}

    begin{tikzpicture}
    [grid/.style={very thin,gray},
    conn/.style={->,blue,very thick},
    inp/.style={opacity=.5,very thick,black,fill=red},
    oup/.style={opacity=.5,very thick,black,fill=blue},
    int/.style={opacity=.5,very thick,black,fill=gray},
    int1/.style={opacity=.5, thick, black, fill=yellow},
    plane/.style={opacity=.6,draw=none,fill=yellow!80!black},
    line/.style={very thick}]

    % input layer
    draw[inp,rounded corners] (-1, 2.5) rectangle (1, -3.8) {};

    % scalar values (only internal circles)
    shade[ball color=green] (0,.5) circle (.5cm);
    draw (0,0.5) node[scale=2]{2};
    shade[ball color=green] (0,1.7) circle (.5cm);
    draw (0,1.7) node[scale=2]{1};

    draw (0,-0.4) node[circle,fill,inner sep=1pt](a){};
    draw (0,-0.7) node[circle,fill,inner sep=1pt](b){};
    draw (0,-1.0) node[circle,fill,inner sep=1pt](c){};


    shade[ball color=green] (0,-1.8) circle (.5cm);
    draw (0,-1.8) node[scale=2]{26};
    shade[ball color=green] (0,-3) circle (.5cm);
    draw (0,-3) node[scale=2]{27};
    %draw [fill=bg_deepred](0,y) circle (2.5mm);

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % input layer
    draw[int,rounded corners] (3, 2) rectangle (8, -3) {};

    draw[int1] (3.5, 1.5) rectangle (5, 0) {};
    draw[int1] (3.5, -1) rectangle (5, -2.5) {};

    draw[int1] (6.0, 1.5) rectangle (7.5, -2.5) {};

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % output layer
    draw[int,rounded corners] (10, 2) rectangle (15, -3) {};

    draw[int1] (10.5, 1.5) rectangle (12, 0) {};
    draw[int1] (10.5, -1) rectangle (12, -2.5) {};
    draw[int1] (13.0, 1.5) rectangle (14.5, -2.5) {};

    %tikz version not working
    begin{scope}[x=1pt,y=10pt,shift={(100,0)}]
    draw (5,5) plot[domain=-8:8] (x,{1/(1 + exp(-x))-0.5});
    end{scope}

    %pgfplots version not working
    begin{axis}[width=5.5cm,height=4cm,ymin=-1.25,ymax=1.25,xmin=-5,xmax=5]
    addplot[blue,smooth] {tanh(x)};
    end{axis}


    end{tikzpicture}

    end{document}


    This gives me the followin with the blue curve provided using pgfplots package and the black one provided by the tikzplot package.



    enter image description here










    share|improve this question







    New contributor




    datapanda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      up vote
      4
      down vote

      favorite









      up vote
      4
      down vote

      favorite











      I am using tikz to reproduce a Matlab picturization of a neural network. The original figure that I need to reproduce is this :



      enter image description here



      I am stuck at plotting the tanh function and the linear function inside the node.
      I have tried two methods as of now : pgfplots and tikz plot function but I am unable to move the plot inside the rectangle.



      documentclass[class=minimal,border=0pt]{standalone}
      usepackage{ifthen}
      usepackage{pgf,tikz}
      usepackage{pgfplots}
      pgfplotsset{compat=1.15}
      usepackage{tikz-3dplot}
      usepackage{mathrsfs}
      usetikzlibrary{arrows}
      usepackage{tkz-euclide}
      usetkzobj{all}
      pagestyle{empty}

      begin{document}

      definecolor{bg_deepred}{RGB}{150,0,24}

      begin{tikzpicture}
      [grid/.style={very thin,gray},
      conn/.style={->,blue,very thick},
      inp/.style={opacity=.5,very thick,black,fill=red},
      oup/.style={opacity=.5,very thick,black,fill=blue},
      int/.style={opacity=.5,very thick,black,fill=gray},
      int1/.style={opacity=.5, thick, black, fill=yellow},
      plane/.style={opacity=.6,draw=none,fill=yellow!80!black},
      line/.style={very thick}]

      % input layer
      draw[inp,rounded corners] (-1, 2.5) rectangle (1, -3.8) {};

      % scalar values (only internal circles)
      shade[ball color=green] (0,.5) circle (.5cm);
      draw (0,0.5) node[scale=2]{2};
      shade[ball color=green] (0,1.7) circle (.5cm);
      draw (0,1.7) node[scale=2]{1};

      draw (0,-0.4) node[circle,fill,inner sep=1pt](a){};
      draw (0,-0.7) node[circle,fill,inner sep=1pt](b){};
      draw (0,-1.0) node[circle,fill,inner sep=1pt](c){};


      shade[ball color=green] (0,-1.8) circle (.5cm);
      draw (0,-1.8) node[scale=2]{26};
      shade[ball color=green] (0,-3) circle (.5cm);
      draw (0,-3) node[scale=2]{27};
      %draw [fill=bg_deepred](0,y) circle (2.5mm);

      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      % input layer
      draw[int,rounded corners] (3, 2) rectangle (8, -3) {};

      draw[int1] (3.5, 1.5) rectangle (5, 0) {};
      draw[int1] (3.5, -1) rectangle (5, -2.5) {};

      draw[int1] (6.0, 1.5) rectangle (7.5, -2.5) {};

      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      % output layer
      draw[int,rounded corners] (10, 2) rectangle (15, -3) {};

      draw[int1] (10.5, 1.5) rectangle (12, 0) {};
      draw[int1] (10.5, -1) rectangle (12, -2.5) {};
      draw[int1] (13.0, 1.5) rectangle (14.5, -2.5) {};

      %tikz version not working
      begin{scope}[x=1pt,y=10pt,shift={(100,0)}]
      draw (5,5) plot[domain=-8:8] (x,{1/(1 + exp(-x))-0.5});
      end{scope}

      %pgfplots version not working
      begin{axis}[width=5.5cm,height=4cm,ymin=-1.25,ymax=1.25,xmin=-5,xmax=5]
      addplot[blue,smooth] {tanh(x)};
      end{axis}


      end{tikzpicture}

      end{document}


      This gives me the followin with the blue curve provided using pgfplots package and the black one provided by the tikzplot package.



      enter image description here










      share|improve this question







      New contributor




      datapanda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      I am using tikz to reproduce a Matlab picturization of a neural network. The original figure that I need to reproduce is this :



      enter image description here



      I am stuck at plotting the tanh function and the linear function inside the node.
      I have tried two methods as of now : pgfplots and tikz plot function but I am unable to move the plot inside the rectangle.



      documentclass[class=minimal,border=0pt]{standalone}
      usepackage{ifthen}
      usepackage{pgf,tikz}
      usepackage{pgfplots}
      pgfplotsset{compat=1.15}
      usepackage{tikz-3dplot}
      usepackage{mathrsfs}
      usetikzlibrary{arrows}
      usepackage{tkz-euclide}
      usetkzobj{all}
      pagestyle{empty}

      begin{document}

      definecolor{bg_deepred}{RGB}{150,0,24}

      begin{tikzpicture}
      [grid/.style={very thin,gray},
      conn/.style={->,blue,very thick},
      inp/.style={opacity=.5,very thick,black,fill=red},
      oup/.style={opacity=.5,very thick,black,fill=blue},
      int/.style={opacity=.5,very thick,black,fill=gray},
      int1/.style={opacity=.5, thick, black, fill=yellow},
      plane/.style={opacity=.6,draw=none,fill=yellow!80!black},
      line/.style={very thick}]

      % input layer
      draw[inp,rounded corners] (-1, 2.5) rectangle (1, -3.8) {};

      % scalar values (only internal circles)
      shade[ball color=green] (0,.5) circle (.5cm);
      draw (0,0.5) node[scale=2]{2};
      shade[ball color=green] (0,1.7) circle (.5cm);
      draw (0,1.7) node[scale=2]{1};

      draw (0,-0.4) node[circle,fill,inner sep=1pt](a){};
      draw (0,-0.7) node[circle,fill,inner sep=1pt](b){};
      draw (0,-1.0) node[circle,fill,inner sep=1pt](c){};


      shade[ball color=green] (0,-1.8) circle (.5cm);
      draw (0,-1.8) node[scale=2]{26};
      shade[ball color=green] (0,-3) circle (.5cm);
      draw (0,-3) node[scale=2]{27};
      %draw [fill=bg_deepred](0,y) circle (2.5mm);

      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      % input layer
      draw[int,rounded corners] (3, 2) rectangle (8, -3) {};

      draw[int1] (3.5, 1.5) rectangle (5, 0) {};
      draw[int1] (3.5, -1) rectangle (5, -2.5) {};

      draw[int1] (6.0, 1.5) rectangle (7.5, -2.5) {};

      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      % output layer
      draw[int,rounded corners] (10, 2) rectangle (15, -3) {};

      draw[int1] (10.5, 1.5) rectangle (12, 0) {};
      draw[int1] (10.5, -1) rectangle (12, -2.5) {};
      draw[int1] (13.0, 1.5) rectangle (14.5, -2.5) {};

      %tikz version not working
      begin{scope}[x=1pt,y=10pt,shift={(100,0)}]
      draw (5,5) plot[domain=-8:8] (x,{1/(1 + exp(-x))-0.5});
      end{scope}

      %pgfplots version not working
      begin{axis}[width=5.5cm,height=4cm,ymin=-1.25,ymax=1.25,xmin=-5,xmax=5]
      addplot[blue,smooth] {tanh(x)};
      end{axis}


      end{tikzpicture}

      end{document}


      This gives me the followin with the blue curve provided using pgfplots package and the black one provided by the tikzplot package.



      enter image description here







      tikz-pgf pgfplots tikz-arrows






      share|improve this question







      New contributor




      datapanda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      datapanda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      datapanda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked Nov 18 at 14:14









      datapanda

      484




      484




      New contributor




      datapanda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      datapanda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      datapanda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          5
          down vote



          accepted










          Like this?



          enter image description here



          You have to adjust the shift of scope so that its placed at the middle of node. Then just scale to required value.



          MWE



          documentclass[class=minimal,border=2mm]{standalone}
          usepackage{tikz}
          begin{document}
          begin{tikzpicture}
          [grid/.style={very thin,gray},
          conn/.style={->,blue,very thick},
          inp/.style={opacity=.5,very thick,black,fill=red},
          oup/.style={opacity=.5,very thick,black,fill=blue},
          int/.style={opacity=.5,very thick,black,fill=gray},
          int1/.style={opacity=.5, thick, black, fill=yellow},
          plane/.style={opacity=.6,draw=none,fill=yellow!80!black},
          line/.style={very thick}]

          % input layer
          draw[inp,rounded corners] (-1, 2.5) rectangle (1, -3.8) {};

          % scalar values (only internal circles)
          shade[ball color=green] (0,.5) circle (.5cm);
          draw (0,0.5) node[scale=2]{2};
          shade[ball color=green] (0,1.7) circle (.5cm);
          draw (0,1.7) node[scale=2]{1};

          draw (0,-0.4) node[circle,fill,inner sep=1pt](a){};
          draw (0,-0.7) node[circle,fill,inner sep=1pt](b){};
          draw (0,-1.0) node[circle,fill,inner sep=1pt](c){};

          shade[ball color=green] (0,-1.8) circle (.5cm);
          draw (0,-1.8) node[scale=2]{26};
          shade[ball color=green] (0,-3) circle (.5cm);
          draw (0,-3) node[scale=2]{27};
          %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
          % input layer
          draw[int,rounded corners] (3, 2) rectangle (8, -3) {};
          draw[int1] (3.5, 1.5) rectangle (5, 0) {};
          draw[int1] (3.5, -1) rectangle (5, -2.5) {};
          draw[int1] (6.0, 1.5) rectangle (7.5, -2.5) {};
          %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
          % output layer
          draw[int,rounded corners] (10, 2) rectangle (15, -3) {};
          draw[int1] (10.5, 1.5) rectangle (12, 0) {};
          draw[int1] (10.5, -1) rectangle (12, -2.5) {};
          draw[int1] (13.0, 1.5) rectangle (14.5, -2.5) {};

          %tikz version working
          begin{scope}[x=2pt,y=2cm,shift={(6.75cm,-0.5cm)}]
          draw[gray!50,thick] (-8,0) -- (8,0);
          draw[gray!50,thick] (0,-1cm) -- (0,1cm);
          draw[thick] (0,0) plot[domain=-8:8] (x,{1/(1 + exp(-x))-0.5});
          end{scope}

          %tikz version working
          begin{scope}[x=2pt,y=2cm,shift={(13.75cm,-0.5cm)}]
          draw[gray!50,thick] (-8,0) -- (8,0);
          draw[gray!50,thick] (0,-1cm) -- (0,1cm);
          draw[thick] (-8,-1cm)--(8,1cm);
          end{scope}
          end{tikzpicture}
          end{document}





          share|improve this answer























          • fabulous .. i was playing with but it wasnt working as I wished. Any pointers as to how to put on those arrows (i will try the default version)
            – datapanda
            Nov 18 at 14:48










          • i was missing the cm in the shift ... oops :)
            – datapanda
            Nov 18 at 14:50










          • @datapanda arrows can be drawn easily. You can find examples here and in texample.net/tikz/examples .
            – nidhin
            Nov 18 at 15:00










          • what if i have to make the function of qual aspect ratio, right now it looks the height is more than the breadth.
            – datapanda
            Nov 18 at 15:35






          • 1




            @datapanda Change the y=2cm value in the scope.
            – nidhin
            Nov 18 at 15:37


















          up vote
          2
          down vote













          an alternative approach:




          • use of small pictures pic for nodes symbols

          • symbols are not needed to be drawn with plot function, it is sufficient to approximate it with controls macro

          • used are relative coordinates


          • shown are only hidden and output node



            documentclass[tikz,margin=3.141529mm]{standalone}
            usetikzlibrary{arrows.meta, backgrounds, calc, fit, positioning}

            begin{document}
            begin{tikzpicture}[
            node distance = 4mm and 4mm,
            arr/.style = {semithick, -{Triangle[width=3pt,length=3pt]}, rounded corners},
            box/.style = {draw, semithick, fill=yellow!40,
            minimum size=6mm, inner sep=1mm, outer sep=0mm},
            circ/.style = {circle, draw,fill=white, inner sep=0.5mm, outer sep=0mm,
            node contents={}},
            FIT/.style = {draw, fill=blue!20, rounded corners, inner sep=2mm, outer sep=0mm,
            fit=#1, node contents={}},
            sum/.style = {circle, draw, fill=yellow!40, inner sep=0mm, outer sep=0mm,
            font=large, node contents={+}},
            lin/.pic = {draw[very thin] (-0.4,0) -- ++ (0.8,0)
            (0,-0.5) -- ++ (0,1.0);
            draw[semithick] (-0.4,-0.4) -- (0.4,0.4);
            },
            sat/.pic = {draw[very thin] (-0.4,0) -- ++ (0.8,0)
            (0,-0.5) -- ++ (0,1.0);
            draw[semithick]
            (-0.4,-0.4) .. controls + (2mm,0mm) and + (-2mm,-4mm) .. (0,0)
            .. controls + (2mm,4mm) and + (-2mm, 0mm) .. (0.4,0.4);
            },
            ]
            % hidden node
            node (a1) [box] {$W$};
            node (a2) [box, below=of a1] {b};
            node (a3) [sum, right=of $(a1.east)!0.5!(a2.east)$];
            path let p1 = ($(a1.north)-(a2.south)$),
            n1 = {veclen(x1,y1)} in
            node (a4) [box, minimum height=n1,
            right=of a3] {};
            pic[scale=0.5] at (a4.center) {sat};
            draw[arr] (a1) -| (a3);
            draw[arr] (a3) edge (a4) (a2) -| (a3);
            scoped[on background layer]
            node (a5) [FIT=(a1) (a4)];
            node (a6) [circ,at=(a5.west |- a1)];
            draw[arr] (a6) -- (a1);
            % output node
            begin{scope}[xshift=33mm]
            node (b1) [box] {$W$};
            node (b2) [box, below = of b1] {b};
            node (b3) [sum, right=of $(b1.east)!0.5!(b2.east)$];
            path let p1 = ($(b1.north)-(b2.south)$),
            n1 = {veclen(x1,y1)} in
            node (b4) [box, minimum height=n1,
            right=of b3] {};
            pic[scale=0.5] at (b4.center) {lin};
            draw[arr] (b1) -| (b3);
            draw[arr] (b3) edge (b4) (b2) -| (b3);
            scoped[on background layer]
            node (b5) [FIT=(b1) (b4)];
            node (b6) [circ,at=(b5.west |- a1)];
            draw[arr] (b6) -- (b1);
            end{scope}
            end{tikzpicture}
            end{document}



          enter image description here






          share|improve this answer





















            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "85"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });






            datapanda is a new contributor. Be nice, and check out our Code of Conduct.










             

            draft saved


            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f460600%2ftikz-plot-a-function-inside-a-node%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            5
            down vote



            accepted










            Like this?



            enter image description here



            You have to adjust the shift of scope so that its placed at the middle of node. Then just scale to required value.



            MWE



            documentclass[class=minimal,border=2mm]{standalone}
            usepackage{tikz}
            begin{document}
            begin{tikzpicture}
            [grid/.style={very thin,gray},
            conn/.style={->,blue,very thick},
            inp/.style={opacity=.5,very thick,black,fill=red},
            oup/.style={opacity=.5,very thick,black,fill=blue},
            int/.style={opacity=.5,very thick,black,fill=gray},
            int1/.style={opacity=.5, thick, black, fill=yellow},
            plane/.style={opacity=.6,draw=none,fill=yellow!80!black},
            line/.style={very thick}]

            % input layer
            draw[inp,rounded corners] (-1, 2.5) rectangle (1, -3.8) {};

            % scalar values (only internal circles)
            shade[ball color=green] (0,.5) circle (.5cm);
            draw (0,0.5) node[scale=2]{2};
            shade[ball color=green] (0,1.7) circle (.5cm);
            draw (0,1.7) node[scale=2]{1};

            draw (0,-0.4) node[circle,fill,inner sep=1pt](a){};
            draw (0,-0.7) node[circle,fill,inner sep=1pt](b){};
            draw (0,-1.0) node[circle,fill,inner sep=1pt](c){};

            shade[ball color=green] (0,-1.8) circle (.5cm);
            draw (0,-1.8) node[scale=2]{26};
            shade[ball color=green] (0,-3) circle (.5cm);
            draw (0,-3) node[scale=2]{27};
            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            % input layer
            draw[int,rounded corners] (3, 2) rectangle (8, -3) {};
            draw[int1] (3.5, 1.5) rectangle (5, 0) {};
            draw[int1] (3.5, -1) rectangle (5, -2.5) {};
            draw[int1] (6.0, 1.5) rectangle (7.5, -2.5) {};
            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            % output layer
            draw[int,rounded corners] (10, 2) rectangle (15, -3) {};
            draw[int1] (10.5, 1.5) rectangle (12, 0) {};
            draw[int1] (10.5, -1) rectangle (12, -2.5) {};
            draw[int1] (13.0, 1.5) rectangle (14.5, -2.5) {};

            %tikz version working
            begin{scope}[x=2pt,y=2cm,shift={(6.75cm,-0.5cm)}]
            draw[gray!50,thick] (-8,0) -- (8,0);
            draw[gray!50,thick] (0,-1cm) -- (0,1cm);
            draw[thick] (0,0) plot[domain=-8:8] (x,{1/(1 + exp(-x))-0.5});
            end{scope}

            %tikz version working
            begin{scope}[x=2pt,y=2cm,shift={(13.75cm,-0.5cm)}]
            draw[gray!50,thick] (-8,0) -- (8,0);
            draw[gray!50,thick] (0,-1cm) -- (0,1cm);
            draw[thick] (-8,-1cm)--(8,1cm);
            end{scope}
            end{tikzpicture}
            end{document}





            share|improve this answer























            • fabulous .. i was playing with but it wasnt working as I wished. Any pointers as to how to put on those arrows (i will try the default version)
              – datapanda
              Nov 18 at 14:48










            • i was missing the cm in the shift ... oops :)
              – datapanda
              Nov 18 at 14:50










            • @datapanda arrows can be drawn easily. You can find examples here and in texample.net/tikz/examples .
              – nidhin
              Nov 18 at 15:00










            • what if i have to make the function of qual aspect ratio, right now it looks the height is more than the breadth.
              – datapanda
              Nov 18 at 15:35






            • 1




              @datapanda Change the y=2cm value in the scope.
              – nidhin
              Nov 18 at 15:37















            up vote
            5
            down vote



            accepted










            Like this?



            enter image description here



            You have to adjust the shift of scope so that its placed at the middle of node. Then just scale to required value.



            MWE



            documentclass[class=minimal,border=2mm]{standalone}
            usepackage{tikz}
            begin{document}
            begin{tikzpicture}
            [grid/.style={very thin,gray},
            conn/.style={->,blue,very thick},
            inp/.style={opacity=.5,very thick,black,fill=red},
            oup/.style={opacity=.5,very thick,black,fill=blue},
            int/.style={opacity=.5,very thick,black,fill=gray},
            int1/.style={opacity=.5, thick, black, fill=yellow},
            plane/.style={opacity=.6,draw=none,fill=yellow!80!black},
            line/.style={very thick}]

            % input layer
            draw[inp,rounded corners] (-1, 2.5) rectangle (1, -3.8) {};

            % scalar values (only internal circles)
            shade[ball color=green] (0,.5) circle (.5cm);
            draw (0,0.5) node[scale=2]{2};
            shade[ball color=green] (0,1.7) circle (.5cm);
            draw (0,1.7) node[scale=2]{1};

            draw (0,-0.4) node[circle,fill,inner sep=1pt](a){};
            draw (0,-0.7) node[circle,fill,inner sep=1pt](b){};
            draw (0,-1.0) node[circle,fill,inner sep=1pt](c){};

            shade[ball color=green] (0,-1.8) circle (.5cm);
            draw (0,-1.8) node[scale=2]{26};
            shade[ball color=green] (0,-3) circle (.5cm);
            draw (0,-3) node[scale=2]{27};
            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            % input layer
            draw[int,rounded corners] (3, 2) rectangle (8, -3) {};
            draw[int1] (3.5, 1.5) rectangle (5, 0) {};
            draw[int1] (3.5, -1) rectangle (5, -2.5) {};
            draw[int1] (6.0, 1.5) rectangle (7.5, -2.5) {};
            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            % output layer
            draw[int,rounded corners] (10, 2) rectangle (15, -3) {};
            draw[int1] (10.5, 1.5) rectangle (12, 0) {};
            draw[int1] (10.5, -1) rectangle (12, -2.5) {};
            draw[int1] (13.0, 1.5) rectangle (14.5, -2.5) {};

            %tikz version working
            begin{scope}[x=2pt,y=2cm,shift={(6.75cm,-0.5cm)}]
            draw[gray!50,thick] (-8,0) -- (8,0);
            draw[gray!50,thick] (0,-1cm) -- (0,1cm);
            draw[thick] (0,0) plot[domain=-8:8] (x,{1/(1 + exp(-x))-0.5});
            end{scope}

            %tikz version working
            begin{scope}[x=2pt,y=2cm,shift={(13.75cm,-0.5cm)}]
            draw[gray!50,thick] (-8,0) -- (8,0);
            draw[gray!50,thick] (0,-1cm) -- (0,1cm);
            draw[thick] (-8,-1cm)--(8,1cm);
            end{scope}
            end{tikzpicture}
            end{document}





            share|improve this answer























            • fabulous .. i was playing with but it wasnt working as I wished. Any pointers as to how to put on those arrows (i will try the default version)
              – datapanda
              Nov 18 at 14:48










            • i was missing the cm in the shift ... oops :)
              – datapanda
              Nov 18 at 14:50










            • @datapanda arrows can be drawn easily. You can find examples here and in texample.net/tikz/examples .
              – nidhin
              Nov 18 at 15:00










            • what if i have to make the function of qual aspect ratio, right now it looks the height is more than the breadth.
              – datapanda
              Nov 18 at 15:35






            • 1




              @datapanda Change the y=2cm value in the scope.
              – nidhin
              Nov 18 at 15:37













            up vote
            5
            down vote



            accepted







            up vote
            5
            down vote



            accepted






            Like this?



            enter image description here



            You have to adjust the shift of scope so that its placed at the middle of node. Then just scale to required value.



            MWE



            documentclass[class=minimal,border=2mm]{standalone}
            usepackage{tikz}
            begin{document}
            begin{tikzpicture}
            [grid/.style={very thin,gray},
            conn/.style={->,blue,very thick},
            inp/.style={opacity=.5,very thick,black,fill=red},
            oup/.style={opacity=.5,very thick,black,fill=blue},
            int/.style={opacity=.5,very thick,black,fill=gray},
            int1/.style={opacity=.5, thick, black, fill=yellow},
            plane/.style={opacity=.6,draw=none,fill=yellow!80!black},
            line/.style={very thick}]

            % input layer
            draw[inp,rounded corners] (-1, 2.5) rectangle (1, -3.8) {};

            % scalar values (only internal circles)
            shade[ball color=green] (0,.5) circle (.5cm);
            draw (0,0.5) node[scale=2]{2};
            shade[ball color=green] (0,1.7) circle (.5cm);
            draw (0,1.7) node[scale=2]{1};

            draw (0,-0.4) node[circle,fill,inner sep=1pt](a){};
            draw (0,-0.7) node[circle,fill,inner sep=1pt](b){};
            draw (0,-1.0) node[circle,fill,inner sep=1pt](c){};

            shade[ball color=green] (0,-1.8) circle (.5cm);
            draw (0,-1.8) node[scale=2]{26};
            shade[ball color=green] (0,-3) circle (.5cm);
            draw (0,-3) node[scale=2]{27};
            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            % input layer
            draw[int,rounded corners] (3, 2) rectangle (8, -3) {};
            draw[int1] (3.5, 1.5) rectangle (5, 0) {};
            draw[int1] (3.5, -1) rectangle (5, -2.5) {};
            draw[int1] (6.0, 1.5) rectangle (7.5, -2.5) {};
            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            % output layer
            draw[int,rounded corners] (10, 2) rectangle (15, -3) {};
            draw[int1] (10.5, 1.5) rectangle (12, 0) {};
            draw[int1] (10.5, -1) rectangle (12, -2.5) {};
            draw[int1] (13.0, 1.5) rectangle (14.5, -2.5) {};

            %tikz version working
            begin{scope}[x=2pt,y=2cm,shift={(6.75cm,-0.5cm)}]
            draw[gray!50,thick] (-8,0) -- (8,0);
            draw[gray!50,thick] (0,-1cm) -- (0,1cm);
            draw[thick] (0,0) plot[domain=-8:8] (x,{1/(1 + exp(-x))-0.5});
            end{scope}

            %tikz version working
            begin{scope}[x=2pt,y=2cm,shift={(13.75cm,-0.5cm)}]
            draw[gray!50,thick] (-8,0) -- (8,0);
            draw[gray!50,thick] (0,-1cm) -- (0,1cm);
            draw[thick] (-8,-1cm)--(8,1cm);
            end{scope}
            end{tikzpicture}
            end{document}





            share|improve this answer














            Like this?



            enter image description here



            You have to adjust the shift of scope so that its placed at the middle of node. Then just scale to required value.



            MWE



            documentclass[class=minimal,border=2mm]{standalone}
            usepackage{tikz}
            begin{document}
            begin{tikzpicture}
            [grid/.style={very thin,gray},
            conn/.style={->,blue,very thick},
            inp/.style={opacity=.5,very thick,black,fill=red},
            oup/.style={opacity=.5,very thick,black,fill=blue},
            int/.style={opacity=.5,very thick,black,fill=gray},
            int1/.style={opacity=.5, thick, black, fill=yellow},
            plane/.style={opacity=.6,draw=none,fill=yellow!80!black},
            line/.style={very thick}]

            % input layer
            draw[inp,rounded corners] (-1, 2.5) rectangle (1, -3.8) {};

            % scalar values (only internal circles)
            shade[ball color=green] (0,.5) circle (.5cm);
            draw (0,0.5) node[scale=2]{2};
            shade[ball color=green] (0,1.7) circle (.5cm);
            draw (0,1.7) node[scale=2]{1};

            draw (0,-0.4) node[circle,fill,inner sep=1pt](a){};
            draw (0,-0.7) node[circle,fill,inner sep=1pt](b){};
            draw (0,-1.0) node[circle,fill,inner sep=1pt](c){};

            shade[ball color=green] (0,-1.8) circle (.5cm);
            draw (0,-1.8) node[scale=2]{26};
            shade[ball color=green] (0,-3) circle (.5cm);
            draw (0,-3) node[scale=2]{27};
            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            % input layer
            draw[int,rounded corners] (3, 2) rectangle (8, -3) {};
            draw[int1] (3.5, 1.5) rectangle (5, 0) {};
            draw[int1] (3.5, -1) rectangle (5, -2.5) {};
            draw[int1] (6.0, 1.5) rectangle (7.5, -2.5) {};
            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            % output layer
            draw[int,rounded corners] (10, 2) rectangle (15, -3) {};
            draw[int1] (10.5, 1.5) rectangle (12, 0) {};
            draw[int1] (10.5, -1) rectangle (12, -2.5) {};
            draw[int1] (13.0, 1.5) rectangle (14.5, -2.5) {};

            %tikz version working
            begin{scope}[x=2pt,y=2cm,shift={(6.75cm,-0.5cm)}]
            draw[gray!50,thick] (-8,0) -- (8,0);
            draw[gray!50,thick] (0,-1cm) -- (0,1cm);
            draw[thick] (0,0) plot[domain=-8:8] (x,{1/(1 + exp(-x))-0.5});
            end{scope}

            %tikz version working
            begin{scope}[x=2pt,y=2cm,shift={(13.75cm,-0.5cm)}]
            draw[gray!50,thick] (-8,0) -- (8,0);
            draw[gray!50,thick] (0,-1cm) -- (0,1cm);
            draw[thick] (-8,-1cm)--(8,1cm);
            end{scope}
            end{tikzpicture}
            end{document}






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 18 at 14:45

























            answered Nov 18 at 14:36









            nidhin

            1,700920




            1,700920












            • fabulous .. i was playing with but it wasnt working as I wished. Any pointers as to how to put on those arrows (i will try the default version)
              – datapanda
              Nov 18 at 14:48










            • i was missing the cm in the shift ... oops :)
              – datapanda
              Nov 18 at 14:50










            • @datapanda arrows can be drawn easily. You can find examples here and in texample.net/tikz/examples .
              – nidhin
              Nov 18 at 15:00










            • what if i have to make the function of qual aspect ratio, right now it looks the height is more than the breadth.
              – datapanda
              Nov 18 at 15:35






            • 1




              @datapanda Change the y=2cm value in the scope.
              – nidhin
              Nov 18 at 15:37


















            • fabulous .. i was playing with but it wasnt working as I wished. Any pointers as to how to put on those arrows (i will try the default version)
              – datapanda
              Nov 18 at 14:48










            • i was missing the cm in the shift ... oops :)
              – datapanda
              Nov 18 at 14:50










            • @datapanda arrows can be drawn easily. You can find examples here and in texample.net/tikz/examples .
              – nidhin
              Nov 18 at 15:00










            • what if i have to make the function of qual aspect ratio, right now it looks the height is more than the breadth.
              – datapanda
              Nov 18 at 15:35






            • 1




              @datapanda Change the y=2cm value in the scope.
              – nidhin
              Nov 18 at 15:37
















            fabulous .. i was playing with but it wasnt working as I wished. Any pointers as to how to put on those arrows (i will try the default version)
            – datapanda
            Nov 18 at 14:48




            fabulous .. i was playing with but it wasnt working as I wished. Any pointers as to how to put on those arrows (i will try the default version)
            – datapanda
            Nov 18 at 14:48












            i was missing the cm in the shift ... oops :)
            – datapanda
            Nov 18 at 14:50




            i was missing the cm in the shift ... oops :)
            – datapanda
            Nov 18 at 14:50












            @datapanda arrows can be drawn easily. You can find examples here and in texample.net/tikz/examples .
            – nidhin
            Nov 18 at 15:00




            @datapanda arrows can be drawn easily. You can find examples here and in texample.net/tikz/examples .
            – nidhin
            Nov 18 at 15:00












            what if i have to make the function of qual aspect ratio, right now it looks the height is more than the breadth.
            – datapanda
            Nov 18 at 15:35




            what if i have to make the function of qual aspect ratio, right now it looks the height is more than the breadth.
            – datapanda
            Nov 18 at 15:35




            1




            1




            @datapanda Change the y=2cm value in the scope.
            – nidhin
            Nov 18 at 15:37




            @datapanda Change the y=2cm value in the scope.
            – nidhin
            Nov 18 at 15:37










            up vote
            2
            down vote













            an alternative approach:




            • use of small pictures pic for nodes symbols

            • symbols are not needed to be drawn with plot function, it is sufficient to approximate it with controls macro

            • used are relative coordinates


            • shown are only hidden and output node



              documentclass[tikz,margin=3.141529mm]{standalone}
              usetikzlibrary{arrows.meta, backgrounds, calc, fit, positioning}

              begin{document}
              begin{tikzpicture}[
              node distance = 4mm and 4mm,
              arr/.style = {semithick, -{Triangle[width=3pt,length=3pt]}, rounded corners},
              box/.style = {draw, semithick, fill=yellow!40,
              minimum size=6mm, inner sep=1mm, outer sep=0mm},
              circ/.style = {circle, draw,fill=white, inner sep=0.5mm, outer sep=0mm,
              node contents={}},
              FIT/.style = {draw, fill=blue!20, rounded corners, inner sep=2mm, outer sep=0mm,
              fit=#1, node contents={}},
              sum/.style = {circle, draw, fill=yellow!40, inner sep=0mm, outer sep=0mm,
              font=large, node contents={+}},
              lin/.pic = {draw[very thin] (-0.4,0) -- ++ (0.8,0)
              (0,-0.5) -- ++ (0,1.0);
              draw[semithick] (-0.4,-0.4) -- (0.4,0.4);
              },
              sat/.pic = {draw[very thin] (-0.4,0) -- ++ (0.8,0)
              (0,-0.5) -- ++ (0,1.0);
              draw[semithick]
              (-0.4,-0.4) .. controls + (2mm,0mm) and + (-2mm,-4mm) .. (0,0)
              .. controls + (2mm,4mm) and + (-2mm, 0mm) .. (0.4,0.4);
              },
              ]
              % hidden node
              node (a1) [box] {$W$};
              node (a2) [box, below=of a1] {b};
              node (a3) [sum, right=of $(a1.east)!0.5!(a2.east)$];
              path let p1 = ($(a1.north)-(a2.south)$),
              n1 = {veclen(x1,y1)} in
              node (a4) [box, minimum height=n1,
              right=of a3] {};
              pic[scale=0.5] at (a4.center) {sat};
              draw[arr] (a1) -| (a3);
              draw[arr] (a3) edge (a4) (a2) -| (a3);
              scoped[on background layer]
              node (a5) [FIT=(a1) (a4)];
              node (a6) [circ,at=(a5.west |- a1)];
              draw[arr] (a6) -- (a1);
              % output node
              begin{scope}[xshift=33mm]
              node (b1) [box] {$W$};
              node (b2) [box, below = of b1] {b};
              node (b3) [sum, right=of $(b1.east)!0.5!(b2.east)$];
              path let p1 = ($(b1.north)-(b2.south)$),
              n1 = {veclen(x1,y1)} in
              node (b4) [box, minimum height=n1,
              right=of b3] {};
              pic[scale=0.5] at (b4.center) {lin};
              draw[arr] (b1) -| (b3);
              draw[arr] (b3) edge (b4) (b2) -| (b3);
              scoped[on background layer]
              node (b5) [FIT=(b1) (b4)];
              node (b6) [circ,at=(b5.west |- a1)];
              draw[arr] (b6) -- (b1);
              end{scope}
              end{tikzpicture}
              end{document}



            enter image description here






            share|improve this answer

























              up vote
              2
              down vote













              an alternative approach:




              • use of small pictures pic for nodes symbols

              • symbols are not needed to be drawn with plot function, it is sufficient to approximate it with controls macro

              • used are relative coordinates


              • shown are only hidden and output node



                documentclass[tikz,margin=3.141529mm]{standalone}
                usetikzlibrary{arrows.meta, backgrounds, calc, fit, positioning}

                begin{document}
                begin{tikzpicture}[
                node distance = 4mm and 4mm,
                arr/.style = {semithick, -{Triangle[width=3pt,length=3pt]}, rounded corners},
                box/.style = {draw, semithick, fill=yellow!40,
                minimum size=6mm, inner sep=1mm, outer sep=0mm},
                circ/.style = {circle, draw,fill=white, inner sep=0.5mm, outer sep=0mm,
                node contents={}},
                FIT/.style = {draw, fill=blue!20, rounded corners, inner sep=2mm, outer sep=0mm,
                fit=#1, node contents={}},
                sum/.style = {circle, draw, fill=yellow!40, inner sep=0mm, outer sep=0mm,
                font=large, node contents={+}},
                lin/.pic = {draw[very thin] (-0.4,0) -- ++ (0.8,0)
                (0,-0.5) -- ++ (0,1.0);
                draw[semithick] (-0.4,-0.4) -- (0.4,0.4);
                },
                sat/.pic = {draw[very thin] (-0.4,0) -- ++ (0.8,0)
                (0,-0.5) -- ++ (0,1.0);
                draw[semithick]
                (-0.4,-0.4) .. controls + (2mm,0mm) and + (-2mm,-4mm) .. (0,0)
                .. controls + (2mm,4mm) and + (-2mm, 0mm) .. (0.4,0.4);
                },
                ]
                % hidden node
                node (a1) [box] {$W$};
                node (a2) [box, below=of a1] {b};
                node (a3) [sum, right=of $(a1.east)!0.5!(a2.east)$];
                path let p1 = ($(a1.north)-(a2.south)$),
                n1 = {veclen(x1,y1)} in
                node (a4) [box, minimum height=n1,
                right=of a3] {};
                pic[scale=0.5] at (a4.center) {sat};
                draw[arr] (a1) -| (a3);
                draw[arr] (a3) edge (a4) (a2) -| (a3);
                scoped[on background layer]
                node (a5) [FIT=(a1) (a4)];
                node (a6) [circ,at=(a5.west |- a1)];
                draw[arr] (a6) -- (a1);
                % output node
                begin{scope}[xshift=33mm]
                node (b1) [box] {$W$};
                node (b2) [box, below = of b1] {b};
                node (b3) [sum, right=of $(b1.east)!0.5!(b2.east)$];
                path let p1 = ($(b1.north)-(b2.south)$),
                n1 = {veclen(x1,y1)} in
                node (b4) [box, minimum height=n1,
                right=of b3] {};
                pic[scale=0.5] at (b4.center) {lin};
                draw[arr] (b1) -| (b3);
                draw[arr] (b3) edge (b4) (b2) -| (b3);
                scoped[on background layer]
                node (b5) [FIT=(b1) (b4)];
                node (b6) [circ,at=(b5.west |- a1)];
                draw[arr] (b6) -- (b1);
                end{scope}
                end{tikzpicture}
                end{document}



              enter image description here






              share|improve this answer























                up vote
                2
                down vote










                up vote
                2
                down vote









                an alternative approach:




                • use of small pictures pic for nodes symbols

                • symbols are not needed to be drawn with plot function, it is sufficient to approximate it with controls macro

                • used are relative coordinates


                • shown are only hidden and output node



                  documentclass[tikz,margin=3.141529mm]{standalone}
                  usetikzlibrary{arrows.meta, backgrounds, calc, fit, positioning}

                  begin{document}
                  begin{tikzpicture}[
                  node distance = 4mm and 4mm,
                  arr/.style = {semithick, -{Triangle[width=3pt,length=3pt]}, rounded corners},
                  box/.style = {draw, semithick, fill=yellow!40,
                  minimum size=6mm, inner sep=1mm, outer sep=0mm},
                  circ/.style = {circle, draw,fill=white, inner sep=0.5mm, outer sep=0mm,
                  node contents={}},
                  FIT/.style = {draw, fill=blue!20, rounded corners, inner sep=2mm, outer sep=0mm,
                  fit=#1, node contents={}},
                  sum/.style = {circle, draw, fill=yellow!40, inner sep=0mm, outer sep=0mm,
                  font=large, node contents={+}},
                  lin/.pic = {draw[very thin] (-0.4,0) -- ++ (0.8,0)
                  (0,-0.5) -- ++ (0,1.0);
                  draw[semithick] (-0.4,-0.4) -- (0.4,0.4);
                  },
                  sat/.pic = {draw[very thin] (-0.4,0) -- ++ (0.8,0)
                  (0,-0.5) -- ++ (0,1.0);
                  draw[semithick]
                  (-0.4,-0.4) .. controls + (2mm,0mm) and + (-2mm,-4mm) .. (0,0)
                  .. controls + (2mm,4mm) and + (-2mm, 0mm) .. (0.4,0.4);
                  },
                  ]
                  % hidden node
                  node (a1) [box] {$W$};
                  node (a2) [box, below=of a1] {b};
                  node (a3) [sum, right=of $(a1.east)!0.5!(a2.east)$];
                  path let p1 = ($(a1.north)-(a2.south)$),
                  n1 = {veclen(x1,y1)} in
                  node (a4) [box, minimum height=n1,
                  right=of a3] {};
                  pic[scale=0.5] at (a4.center) {sat};
                  draw[arr] (a1) -| (a3);
                  draw[arr] (a3) edge (a4) (a2) -| (a3);
                  scoped[on background layer]
                  node (a5) [FIT=(a1) (a4)];
                  node (a6) [circ,at=(a5.west |- a1)];
                  draw[arr] (a6) -- (a1);
                  % output node
                  begin{scope}[xshift=33mm]
                  node (b1) [box] {$W$};
                  node (b2) [box, below = of b1] {b};
                  node (b3) [sum, right=of $(b1.east)!0.5!(b2.east)$];
                  path let p1 = ($(b1.north)-(b2.south)$),
                  n1 = {veclen(x1,y1)} in
                  node (b4) [box, minimum height=n1,
                  right=of b3] {};
                  pic[scale=0.5] at (b4.center) {lin};
                  draw[arr] (b1) -| (b3);
                  draw[arr] (b3) edge (b4) (b2) -| (b3);
                  scoped[on background layer]
                  node (b5) [FIT=(b1) (b4)];
                  node (b6) [circ,at=(b5.west |- a1)];
                  draw[arr] (b6) -- (b1);
                  end{scope}
                  end{tikzpicture}
                  end{document}



                enter image description here






                share|improve this answer












                an alternative approach:




                • use of small pictures pic for nodes symbols

                • symbols are not needed to be drawn with plot function, it is sufficient to approximate it with controls macro

                • used are relative coordinates


                • shown are only hidden and output node



                  documentclass[tikz,margin=3.141529mm]{standalone}
                  usetikzlibrary{arrows.meta, backgrounds, calc, fit, positioning}

                  begin{document}
                  begin{tikzpicture}[
                  node distance = 4mm and 4mm,
                  arr/.style = {semithick, -{Triangle[width=3pt,length=3pt]}, rounded corners},
                  box/.style = {draw, semithick, fill=yellow!40,
                  minimum size=6mm, inner sep=1mm, outer sep=0mm},
                  circ/.style = {circle, draw,fill=white, inner sep=0.5mm, outer sep=0mm,
                  node contents={}},
                  FIT/.style = {draw, fill=blue!20, rounded corners, inner sep=2mm, outer sep=0mm,
                  fit=#1, node contents={}},
                  sum/.style = {circle, draw, fill=yellow!40, inner sep=0mm, outer sep=0mm,
                  font=large, node contents={+}},
                  lin/.pic = {draw[very thin] (-0.4,0) -- ++ (0.8,0)
                  (0,-0.5) -- ++ (0,1.0);
                  draw[semithick] (-0.4,-0.4) -- (0.4,0.4);
                  },
                  sat/.pic = {draw[very thin] (-0.4,0) -- ++ (0.8,0)
                  (0,-0.5) -- ++ (0,1.0);
                  draw[semithick]
                  (-0.4,-0.4) .. controls + (2mm,0mm) and + (-2mm,-4mm) .. (0,0)
                  .. controls + (2mm,4mm) and + (-2mm, 0mm) .. (0.4,0.4);
                  },
                  ]
                  % hidden node
                  node (a1) [box] {$W$};
                  node (a2) [box, below=of a1] {b};
                  node (a3) [sum, right=of $(a1.east)!0.5!(a2.east)$];
                  path let p1 = ($(a1.north)-(a2.south)$),
                  n1 = {veclen(x1,y1)} in
                  node (a4) [box, minimum height=n1,
                  right=of a3] {};
                  pic[scale=0.5] at (a4.center) {sat};
                  draw[arr] (a1) -| (a3);
                  draw[arr] (a3) edge (a4) (a2) -| (a3);
                  scoped[on background layer]
                  node (a5) [FIT=(a1) (a4)];
                  node (a6) [circ,at=(a5.west |- a1)];
                  draw[arr] (a6) -- (a1);
                  % output node
                  begin{scope}[xshift=33mm]
                  node (b1) [box] {$W$};
                  node (b2) [box, below = of b1] {b};
                  node (b3) [sum, right=of $(b1.east)!0.5!(b2.east)$];
                  path let p1 = ($(b1.north)-(b2.south)$),
                  n1 = {veclen(x1,y1)} in
                  node (b4) [box, minimum height=n1,
                  right=of b3] {};
                  pic[scale=0.5] at (b4.center) {lin};
                  draw[arr] (b1) -| (b3);
                  draw[arr] (b3) edge (b4) (b2) -| (b3);
                  scoped[on background layer]
                  node (b5) [FIT=(b1) (b4)];
                  node (b6) [circ,at=(b5.west |- a1)];
                  draw[arr] (b6) -- (b1);
                  end{scope}
                  end{tikzpicture}
                  end{document}



                enter image description here







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 18 at 18:32









                Zarko

                116k865154




                116k865154






















                    datapanda is a new contributor. Be nice, and check out our Code of Conduct.










                     

                    draft saved


                    draft discarded


















                    datapanda is a new contributor. Be nice, and check out our Code of Conduct.













                    datapanda is a new contributor. Be nice, and check out our Code of Conduct.












                    datapanda is a new contributor. Be nice, and check out our Code of Conduct.















                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f460600%2ftikz-plot-a-function-inside-a-node%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    mysqli_query(): Empty query in /home/lucindabrummitt/public_html/blog/wp-includes/wp-db.php on line 1924

                    How to change which sound is reproduced for terminal bell?

                    Can I use Tabulator js library in my java Spring + Thymeleaf project?