Passa ai contenuti principali

Post

My first ONNX Run with .Net

Inspirational Post : Use ONNX Runtime in Flutter  My .net Application Grab the simplest ONNX model on the shelf It's not a model package yet: it's python source, you need to compile it!  To use python in Windows it's better for your health to use WSL (linux subsitem for windows) with any Ubuntu, follow readme for compile instructions. Inspect the resulting .onnx file with netron.app Tweak the model nodes and say "hey mama! I won the machile learning!" graph = helper.make_graph( [ # nodes helper.make_node("Add", ["A", "B"], ["C"], "Add1"), helper.make_node("Add", ["C", "E"], ["F"], "Add2"), ], "SingleAdd", # name [ # inputs helper.make_tensor_value_info('A', TensorProto.FLOAT, [1]), helper.make_tensor_value_info('B', TensorProto.FLOAT, [1]), helper.make_tensor_value_info('E',
Post recenti

My A.I. learning Path

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 embedding of subject-object-verb semantics requires embedding relationships among three words. Because a word is itself a vector, subject-ob

C# Unicast Event: ensure an event has only one subscriber with the use of GetInvocationList

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

Query Linq: master detail table, ottenere risultati in forma tabellare o gerarchica

Forma Gerarchica (un elemento per ogni testata) from testata in context.Testate      join riga in context.Righe.DefaultIfEmpty() on testata.Id equals riga.IdTestata into righeResult select new  { Testata = testata, ListaRighe = righeResult } Forma Tabellare (la testata è ripetuta per ogni elemento: tanti elementi quante sono le righe) from testata in context.Testate join riga in context.Righe on testata.Id equals riga.IdTestata into righeTmp from rigaResult in righeTmp.DefaultIfEmpty() select new  { Testata = testata, Riga = rigaResult }

Material Design, AppCompat, Xamarin

Il video di James Montemagno a Xamarin Evolve 2016 mi ha fatto venire voglia di material design. Siccome mi sono perso un po' nel susseguirsi delle novità mi segno alcuni link utili e i passi da fare per adeguarli all'ultimo sdk. Hello Material Design - Gennaio 2015 In questo post Montemagno illustra come usare AppCompat per portare material su Xamarin.Android (non ancora Xamarin Forms). Ho provato il codice e funziona ancora oggi, è abbastanza moderno perchè parla già di Toolbar e non più di ActionBar.  Unica cosa da cambiare: sostituire ActionBarActivity (deprecata) con AppCompatActivity . Support Design Library - Luglio 2015 Come usare alcuni widget ui in versione material, ancora per progetti specifici Xamarin.Android. Rispetto all'articolo oggi conviene usare il pacchetto di nuget Xamarin.Android.Support.Design (è la 23.3.0) anziché il component.  EditText con Floating Label - ok, funziona (anche se prolisso l'axml da usare) SnackBar - ok,

Xamarin Xaml Reusable Content View, basics

Simply open Xamarin Studio and create a new "Forms ContentView Xaml", name it MyView, that is our UserControl. In the code below we use the UserControl inside a Xaml Page. Without adding any code to the UserControl the page can interact with it setting its content (the label "Hello From the page"). With this approach the page decided to replace the content of the UserControl, any view added within the UserControl by xaml in itself will be ignored. The UserControl can still be extended using it's c# code-behind. <? xml version ="1.0" encoding ="UTF-8" ? > < local:MyPageBase xmlns ="http://xamarin.com/schemas/2014/forms" xmlns:x ="http://schemas.microsoft.com/winfx/2009/xaml" x:Class ="xam0001.MyPage1" xmlns:local ="clr-namespace:xam0001" > < local:MyView > < Label Text ="Hello From the page" ></ Label > </

Xamarin.Forms Reusable XAML Page Base Class

The base class is a normal XAML Page. The derived class comes from a new XAML Page, then we change: In code: public partial class MyPage1 : MyPageBase In xaml: < local:MyPageBase xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"  x:Class="xam0001.MyPage1" xmlns:local="clr-namespace:xam0001" >   </ local:MyPageBase >