TENSORE (ML) Let � be a field such as the real numbers � . A tensor � is an � 0 × � 1 × ⋯ � � array over � : � ∈ � � 0 × � 1 × … × � � . Here, � and � 1 , � 2 , … , � � are positive integers, and � is the number of dimensions. One basic approach (not the only way) to using tensors in machine learning is to embed various data types directly. For example, a grayscale image, commonly represented as a discrete 2D function � ( � , � ) with resolution � × � may be embedded in a mode-2 tensor as � ( � , � ) ↦ � ∈ � � × � . A color image with 3 channels for RGB might be embedded in a mode-3 tensor with three elements in an additional dimension: � � � � ( � , � ) ↦ � ∈ � � × � × 3 . In natural language processing, a word might be expressed as a vector � via the Word2vec algorithm. Thus � becomes a mode-1 tensor � ↦ � ∈ � � . The embedd...
Events in c# are designed for multicasting: one publisher for many subscribers. Limiting the number of subscribers may seeem an anti-pattern but in some cases may come in handy. Here is a simple implementation of an event that limits to one the number of subscribers. public class ClassThatFiresEvents { public Action _myAction; public event Action MyUnicastEvent { add { if (_myAction != null) { var invList = _myAction.GetInvocationList(); foreach (var ev in invList) { _myAction -= (Action)ev; } } _myAction += value; } remove { _myAction -= value; } } public void TriggerFromOutside() { if (_myAction != null) _myAction(); } } The code for testing this class: static void Main(string[] args) { ClassThatFiresEv...