diff --git a/doc/user/algorithms/guide.rst b/doc/user/algorithms/guide.rst index 1bbff62469a8f59f3adc1cbdf993dc0d651826fa..defd1cc07a1427be5480eec8dc5eb9bdf0be1444 100644 --- a/doc/user/algorithms/guide.rst +++ b/doc/user/algorithms/guide.rst @@ -28,7 +28,7 @@ ============ Graphically represented, :ref:`toolchains` look like a set of interconnected -blocks. As illustrated in the figure below, each block can accomodate one +blocks. As illustrated in the figure below, each block can accommodate one *Algorithm*, along with the necessary input and output interfaces. We also refer to the inputs and outputs collectively as *endpoints*. @@ -212,7 +212,7 @@ The example below illustrates how such an algorithm could be implemented: if inputs['in2'].isDataUnitDone(): out = magical_processing(self.objs) outputs['out'].write({'value': out}) - self.images = [] #reset accumulator for next label + self.objs = [] #reset accumulator for next label return True @@ -229,19 +229,20 @@ Unsynchronized Operation ------------------------ Not all inputs for a block need to be synchronized together. In the diagram -shown below, the block is synchronized with the input ``in`` (as indicated by -the green circle which matches the color of the input line connecting ``in``). -The output ``out`` is synchronized with the block. The input ``in2`` is not -synchronized with the endpoint ``in`` and with the block. A processing block +shown below, the block is synchronized with the inputs ``in`` and ``in2`` (as indicated by +the green circle which matches the colour of the input lines connecting ``in`` and ``in2``). +The output ``out`` is synchronized with the block (and as one can notice locking at the code +below, outputs signal after every ``in`` input). The input ``in3`` is not +synchronized with the endpoints ``in``, ``in2`` and with the block. A processing block which receives a previously calculated model and must score test samples is a good example for this condition. In this case, the user is responsible for -reading out the contents of ``in2`` explicitly. +reading out the contents of ``in3`` explicitly. .. image:: img/case-study-4.* In this case the algorithm will include an explicit loop to read the -unsynchronized input (``in2``). +unsynchronized input (``in3``). .. code-block:: python :linenos: @@ -260,12 +261,15 @@ unsynchronized input (``in2``). # Loads the "model" data at the beginning, once if self.models is None: self.models = [] - while inputs['in2'].hasMoreData(): - inputs['in2'].next() - self.models.append(inputs['in2'].data.value) + while inputs['in3'].hasMoreData(): + inputs['in3'].next() + self.models.append(inputs['in3'].data.value) - # Processes the current input in `in', apply the model/models - out = magical_processing(inputs['in'].data.value, self.models) + # Processes the current input in `in' and `in2', apply the + # model/models + out = magical_processing(inputs['in'].data.value, + inputs['in2'].data.value, + self.models) # Writes the output outputs.write({'value': out}) @@ -289,18 +293,20 @@ it is safer to treat inputs using their *group*. For example: def process(self, inputs, outputs): - # N.B.: this will be called for every unit in `in' + # N.B.: this will be called for every unit in `in': # Loads the "model" data at the beginning, once if self.models is None: self.models = [] - group = inputs.groupOf('in2') + group = inputs.groupOf('in3') while group.hasMoreData(): group.next() #synchronously advances the data - self.models.append(group['in2'].data.value) + self.models.append(group['in3'].data.value) - # Processes the current input in `in', apply the model/models - out = magical_processing(inputs['in'].data.value, self.models) + # Processes the current input in `in' and `in2', apply the model/models + out = magical_processing(inputs['in'].data.value, + inputs['in2'].data.value, + self.models) # Writes the output outputs.write({'value': out}) diff --git a/doc/user/algorithms/img/case-study-4.pdf b/doc/user/algorithms/img/case-study-4.pdf index c5933798fb5939cc0a625173fd0e9688221997bf..1383599759ff7cc46de1fb8301dfac30e74f37b1 100644 Binary files a/doc/user/algorithms/img/case-study-4.pdf and b/doc/user/algorithms/img/case-study-4.pdf differ diff --git a/doc/user/algorithms/img/case-study-4.png b/doc/user/algorithms/img/case-study-4.png index 9f4e8809b231dff149a963f2f9030355ad0fd67a..e126cfaf1d263b1d5b3a2fd962aa80868563eca2 100644 Binary files a/doc/user/algorithms/img/case-study-4.png and b/doc/user/algorithms/img/case-study-4.png differ diff --git a/doc/user/algorithms/img/case-study-4.svg b/doc/user/algorithms/img/case-study-4.svg index de45087c15e2a5349e76f80a6cfe7e52381dba87..5f2ef82fc07e96a5b1273bb79c4852c2275b7f5b 100644 --- a/doc/user/algorithms/img/case-study-4.svg +++ b/doc/user/algorithms/img/case-study-4.svg @@ -14,8 +14,8 @@ viewBox="0 0 916.23114 352.40994" id="svg2" version="1.1" - inkscape:version="0.91 r13725" - sodipodi:docname="case-study-4.svg" + inkscape:version="0.48.5 r10040" + sodipodi:docname="case-study-4.png" inkscape:export-filename="/remote/idiap.svm/user.active/aanjos/work/beat/beat.web/doc/user/algorithms/img/case-study-2.png" inkscape:export-xdpi="39.93" inkscape:export-ydpi="39.93"> @@ -26,9 +26,9 @@ borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" - inkscape:zoom="1.1507426" - inkscape:cx="426.85751" - inkscape:cy="143.10754" + inkscape:zoom="1.6273958" + inkscape:cx="443.09969" + inkscape:cy="190.44509" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="false" @@ -36,11 +36,11 @@ fit-margin-left="0" fit-margin-right="0" fit-margin-bottom="0" - inkscape:window-width="1737" - inkscape:window-height="678" - inkscape:window-x="141" - inkscape:window-y="299" - inkscape:window-maximized="0" + inkscape:window-width="1920" + inkscape:window-height="1023" + inkscape:window-x="0" + inkscape:window-y="35" + inkscape:window-maximized="1" showguides="false" /> <defs id="defs4"> @@ -529,17 +529,6 @@ x="759.71167" y="130.29988" ry="0" /> - <text - xml:space="preserve" - style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:12.5px;line-height:125%;font-family:'Bitstream Vera Sans';-inkscape-font-specification:'Bitstream Vera Sans Bold';text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none" - x="807.63184" - y="225.98012" - id="text5121-1" - sodipodi:linespacing="125%"><tspan - sodipodi:role="line" - id="tspan5123-5" - x="807.63184" - y="225.98012">0</tspan></text> <rect style="fill:#0000ff;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" id="rect5021-6-1" @@ -548,17 +537,6 @@ x="694.76788" y="130.29988" ry="0" /> - <text - xml:space="preserve" - style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:12.5px;line-height:125%;font-family:'Bitstream Vera Sans';-inkscape-font-specification:'Bitstream Vera Sans Bold';text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none" - x="694.56702" - y="226.10121" - id="text5133-6" - sodipodi:linespacing="125%"><tspan - sodipodi:role="line" - id="tspan5135-6" - x="694.56702" - y="226.10121">2</tspan></text> <rect style="fill:#0000ff;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" id="rect5021-61" @@ -567,17 +545,6 @@ x="628.89764" y="130.29988" ry="0" /> - <text - xml:space="preserve" - style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:12.5px;line-height:125%;font-family:'Bitstream Vera Sans';-inkscape-font-specification:'Bitstream Vera Sans Bold';text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none" - x="675.45081" - y="226.10121" - id="text5137-9" - sodipodi:linespacing="125%"><tspan - sodipodi:role="line" - id="tspan5139-8" - x="675.45081" - y="226.10121">2</tspan></text> <rect style="fill:#0000ff;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" id="rect5021-61-8" @@ -586,30 +553,14 @@ x="562.78333" y="130.29988" ry="0" /> - <path - id="path5084-2-8" - style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - d="m 562.22585,212.98296 c 0,0 -0.16294,-8.47588 0,-8.47588 m -0.24934,0 113.66455,0 0,8.47588" - inkscape:connector-curvature="0" - sodipodi:nodetypes="ccccc" /> - <text - xml:space="preserve" - style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:12.5px;line-height:125%;font-family:'Bitstream Vera Sans';-inkscape-font-specification:'Bitstream Vera Sans Bold';text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none" - x="561.48877" - y="225.98012" - id="text5141-1-2" - sodipodi:linespacing="125%"><tspan - sodipodi:role="line" - id="tspan5143-5-2" - x="561.48877" - y="225.98012">4</tspan></text> <circle style="fill:#00a700;fill-opacity:1;fill-rule:nonzero;stroke:#00a700;stroke-opacity:1" id="path3084" transform="matrix(0.88950579,0,0,0.88950579,0.40991991,75.333784)" cx="575.2807" cy="66.578423" - r="11.297053" /> + r="11.297053" + d="m 586.57775,66.578423 c 0,6.23919 -5.05786,11.297053 -11.29705,11.297053 -6.23919,0 -11.29705,-5.057863 -11.29705,-11.297053 0,-6.239191 5.05786,-11.297054 11.29705,-11.297054 6.23919,0 11.29705,5.057863 11.29705,11.297054 z" /> <path style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="m 98.769463,197.13924 0,7.92225 113.620307,0 0,-7.92225" @@ -630,12 +581,6 @@ y="-280.11337" ry="0" transform="scale(1,-1)" /> - <path - id="path5084-2-8-7" - style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - d="m 694.25062,212.85716 c 0,0 -0.16294,-8.47588 0,-8.47588 m -0.24934,0 113.66455,0 0,8.47588" - inkscape:connector-curvature="0" - sodipodi:nodetypes="ccccc" /> <rect ry="0" y="256.04727" @@ -741,5 +686,116 @@ id="tspan5068-4-5" x="88.040718" y="418.06717"><user/altdata/1></tspan></text> + <g + id="g3213"> + <path + inkscape:connector-curvature="0" + id="path5084-3" + d="m 628.51185,213.60008 0,-8.47588 47.30086,0 0,8.47588" + style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + inkscape:connector-curvature="0" + id="path5084-6-6" + d="m 694.27888,213.56318 0,-8.47588 47.30085,0 0,8.47588" + style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + inkscape:connector-curvature="0" + id="path5084-6-2-7" + d="m 760.04591,213.56318 0,-8.47588 47.30085,0 0,8.47588" + style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <text + sodipodi:linespacing="125%" + id="text5121-5" + y="226.59724" + x="807.68207" + style="font-size:12.5px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold" + xml:space="preserve"><tspan + y="226.59724" + x="807.68207" + id="tspan5123-3" + sodipodi:role="line">0</tspan></text> + <text + sodipodi:linespacing="125%" + id="text5125-5" + y="226.71834" + x="760.38123" + style="font-size:12.5px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold" + xml:space="preserve"><tspan + y="226.71834" + x="760.38123" + id="tspan5127-6" + sodipodi:role="line">1</tspan></text> + <text + sodipodi:linespacing="125%" + id="text5129-2" + y="226.71834" + x="741.24213" + style="font-size:12.5px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold" + xml:space="preserve"><tspan + y="226.71834" + x="741.24213" + id="tspan5131-9" + sodipodi:role="line">1</tspan></text> + <text + sodipodi:linespacing="125%" + id="text5133-1" + y="226.71834" + x="694.21466" + style="font-size:12.5px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold" + xml:space="preserve"><tspan + y="226.71834" + x="694.21466" + id="tspan5135-2" + sodipodi:role="line">2</tspan></text> + <text + sodipodi:linespacing="125%" + id="text5137-7" + y="226.71834" + x="675.62244" + style="font-size:12.5px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold" + xml:space="preserve"><tspan + y="226.71834" + x="675.62244" + id="tspan5139-0" + sodipodi:role="line">2</tspan></text> + <text + sodipodi:linespacing="125%" + id="text5141-9" + y="226.59724" + x="627.77478" + style="font-size:12.5px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold" + xml:space="preserve"><tspan + y="226.59724" + x="627.77478" + id="tspan5143-3" + sodipodi:role="line">3</tspan></text> + <path + inkscape:connector-curvature="0" + id="path5084-1-6" + d="m 562.02627,213.15339 0,-8.47588 47.30085,0 0,8.47588" + style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <text + sodipodi:linespacing="125%" + id="text5137-0-0" + y="226.27165" + x="609.13684" + style="font-size:12.5px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold" + xml:space="preserve"><tspan + y="226.27165" + x="609.13684" + id="tspan5139-9-6" + sodipodi:role="line">3</tspan></text> + <text + sodipodi:linespacing="125%" + id="text5141-15-2" + y="226.15056" + x="561.28918" + style="font-size:12.5px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold" + xml:space="preserve"><tspan + y="226.15056" + x="561.28918" + id="tspan5143-6-6" + sodipodi:role="line">4</tspan></text> + </g> </g> </svg>