vault backup: 2024-11-06 22:02:11

This commit is contained in:
Marco Realacci 2024-11-06 22:02:11 +01:00
commit fb9be058bd
21 changed files with 170 additions and 23 deletions

View file

@ -20,8 +20,23 @@
"icon": "lucide-file",
"title": "q&a"
}
},
{
"id": "8ce91fd3c329ccb6",
"type": "leaf",
"state": {
"type": "markdown",
"state": {
"file": "conflict-files-obsidian-git.md",
"mode": "source",
"source": false
},
"icon": "lucide-file",
"title": "conflict-files-obsidian-git"
}
]
}
],
"currentTab": 1
}
],
"direction": "vertical"
@ -93,7 +108,7 @@
"state": {
"type": "backlink",
"state": {
"file": "Autonomous Networking/notes/q&a.md",
"file": "conflict-files-obsidian-git.md",
"collapseAll": false,
"extraContext": false,
"sortOrder": "alphabetical",
@ -103,7 +118,7 @@
"unlinkedCollapsed": true
},
"icon": "links-coming-in",
"title": "Backlinks for q&a"
"title": "Backlinks for conflict-files-obsidian-git"
}
},
{
@ -112,12 +127,12 @@
"state": {
"type": "outgoing-link",
"state": {
"file": "Autonomous Networking/notes/q&a.md",
"file": "conflict-files-obsidian-git.md",
"linksCollapsed": false,
"unlinkedCollapsed": true
},
"icon": "links-going-out",
"title": "Outgoing links from q&a"
"title": "Outgoing links from conflict-files-obsidian-git"
}
},
{
@ -139,10 +154,10 @@
"state": {
"type": "outline",
"state": {
"file": "Autonomous Networking/notes/q&a.md"
"file": "conflict-files-obsidian-git.md"
},
"icon": "lucide-list",
"title": "Outline of q&a"
"title": "Outline of conflict-files-obsidian-git"
}
},
{
@ -191,8 +206,21 @@
"companion:Toggle completion": false
}
},
"active": "86cc34a714fe2576",
"active": "8ce91fd3c329ccb6",
"lastOpenFiles": [
"Autonomous Networking/notes/q&a.md",
"conflict-files-obsidian-git.md",
"Biometric Systems/slides/LEZIONE7_Face recognition3D.pdf",
"Biometric Systems/images/Pasted image 20241106144314.png",
"Biometric Systems/images/Pasted image 20241106143837.png",
"Biometric Systems/images/Pasted image 20241106142610.png",
"Biometric Systems/images/Pasted image 20241106142539.png",
"Biometric Systems/images/Pasted image 20241106142538.png",
"Biometric Systems/images/Pasted image 20241106142523.png",
"Biometric Systems/images/Pasted image 20241106142503.png",
"Biometric Systems/images/Pasted image 20241106140241.png",
"Biometric Systems/images/Pasted image 20241106140102.png",
"Biometric Systems/images/Pasted image 20241106135900.png",
"Autonomous Networking/notes/2 RFID.md",
"Autonomous Networking/notes/6 Internet of Things.md",
"Autonomous Networking/notes/5 Drones.md",
@ -202,7 +230,6 @@
"Biometric Systems/notes/2. Performance indexes.md",
"Biometric Systems/notes/1. Introduction.md",
"Autonomous Networking/notes/4 WSN Routing.md",
"conflict-files-obsidian-git.md",
"Foundation of data science/notes/4 L1 and L2 normalization.md",
"Autonomous Networking/notes/7.2 10 arm testbed - optimism in face of uncertainty.md",
"Autonomous Networking/notes/7.1 K-Armed bandit problem.md",
@ -218,27 +245,14 @@
"Chats/New Chat.md",
"Foundation of data science/slides/Untitled.md",
"Senza nome.md",
"Autonomous Networking/images/Pasted image 20241031144640.png",
"Biometric Systems/slides/LEZIONE6_Face recognition2D.pdf",
"Biometric Systems/slides/Biometric_System___Notes.pdf",
"Biometric Systems/images/Pasted image 20241031104526.png",
"Biometric Systems/images/Pasted image 20241031104206.png",
"Biometric Systems/images/Pasted image 20241031102640.png",
"Biometric Systems/images/Pasted image 20241031102321.png",
"Biometric Systems/images/Pasted image 20241031100207.png",
"Biometric Systems/images/Pasted image 20241031091853.png",
"Biometric Systems/images/Pasted image 20241031085606.png",
"Biometric Systems/images/Pasted image 20241031084659.png",
"Biometric Systems/images/Pasted image 20241030165705.png",
"Autonomous Networking/slides/AutonomousNet-Class10-2122-Multiarmed_bandit.pdf",
"Autonomous Networking/notes/8.md",
"Autonomous Networking/notes/q&a.md",
"Foundation of data science/notes/1 CV Basics.md",
"Foundation of data science/images",
"Chats",
"Autonomous Networking/notes/3 WSN MAC.md",
"Autonomous Networking/notes/6.1 RL.md",
"Biometric Systems/notes/4. Face recognition.md",
"Senza nome.canvas"
]
}

View file

@ -51,4 +51,64 @@ Every time a collision is generated, rags randomly increments their counter. The
As each time the tags are split into two sets, we can "see" it as a binary tree, so we can count the node of the tree to get an estimation.
$$BS_{tot}(n)=\begin{cases}1,n\le1\\ 1+\sum_{k=0}^{n}\binom{n}{k}\left(\frac12\right)^{k}\left(1-\frac12\right)^{n-k}\left(BS_{tot}\left(k\right)+BS_{tot}\left(n-k\right)\right),n>1\end{cases}$$
<<<<<<< HEAD
#### Q: explain the differences between proactive and reactive routing in sensor networks. Discuss the advantages and disadvantages
=======
#### Q: explain the differences between proactive and reactive routing in sensor networks. Discuss the advantages and disadvantages
#### Q: Define the agent state and the environment state and explain how these two states differ. Give a practical example
The environment state is the actual state of the environment, is the full description of the current situation. It contains everything related to the environment, regardless of whether the agent is able to observe it. Only a small part of the environment may be observable by the agent.
The agent state is the view of the agent on the environment, is a function of history: $S_{t} = f(H_{t})$
The agent state is used by the policy to take the next decision, based on the history.
The distinction is important as the agent has to learn to make good decisions having limited information.
#### Q: Explain the exploitation-exploration dilemma
The exploitation/exploration dilemma is the problem of finding the best compromise between the two. An agent wants to exploit actions that are known to bring positive rewards, but without exploring, it may never learn which actions are the best, so it also wants to explore. If the agent explores too much tho, it may chose some non optimal actions too many times.
#### Q: Mention and briefly explain three different strategies for action selection in reinforcement learning
**greedy:** the agent always exploits the action with the highest action value
**$\epsilon$-greedy:** the greedy action is selected with $1-\epsilon$ probability. While with $\epsilon$ probability a random action is selected. This helps the agent to explore and find the actions with the best values.
**UCB:** this method is based on the "optimism in the face of uncertainty" principle: if we are unsure about something, we should optimistically assume that is good. For this reason actions are choses not only based on the reward, but also based on the uncertainty of the variance of the reward distribution. For each action, the agent will define a confidence window where it thinks the reward's mean value is located. To explore more actions where the agent is not sure about, the window's upper bound is optimistically considered as the action value.
*riformuliamola meglio, vedi slide*
**Higher initial values:** bla bla bla
#### $\lambda=0.5$ and the following sequence of reward is received
$R_{1}=-1$
$R_{2}=2$
$R_{3}=6$
$R_{4}=3$
$R_{5}=2$
with $T=5$. What are $G_{0}, G_{1}, \dots, G_{5}$?
*Hint: work backwards*
$G_{5} = 0$
$G_{4} = 2$
$G_{3} = 3 + \frac{1}{2} 2 = 4$
$G_{2}=6+\frac{1}{2}4 = 8$
$G_{1}=2+\frac{1}{2}8 = 6$
$G_{0}=-1+\frac{1}{2}6=2$
#### Q: Imagine a network of 10 sensor nodes deployed across an area to monitor environmental conditions, such as temperature, humidity, or pollutant levels. Each sensor node has a different, but unknown, data quality score and battery level what fluctuates due to environmental factors and usage over time. Your goal is to design a strategy that balances exploration and exploitation to maximize cumulative data quality while conserving battery resources.
Actions = {query sensor 1, ..., query sensor 10}
Reward should be a function of data quality and battery level. We consider data quality dq and battery level bl as floating points between 0 and 1.
$R_{t}=\alpha *dq-\beta*bl$, with $\alpha$ and $\beta$ being arbitrary parameters that can be set to define the importance of data quality and battery level.
States: one state
Agent: sampling average
Agent's policy: $\epsilon-greedy$
#### Explain Bellman Expectation Equation for the value of a state $V^\pi$
Basic principle: the value of a state is the expected reward I get exiting from that state plus the discounted value of future states.
*add backup diagram*
$$v_{\pi}(s)=\sum_{a \in A}\pi(a|s)q(a, s)=\sum_{a \in A}\pi(a|s)\left( R_{s}^a+\gamma \sum_{s' \in S}P_{ss'}^av_{\pi}(s') \right)$$
>>>>>>> origin/main

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

View file

@ -157,3 +157,76 @@ Questo metodo fa uso di grafi, nello specifico abbiamo per ogni soggetto una col
![[Pasted image 20241031104526.png]]
oggi non lo usa nessuno.
#### LBP Local Binary Pattern
Lavora sempre su un kernel, ma il kernel è "trasparente". Lavora pixel epr pixel e ci aiuta ad estrarre informazioni riguardo le texture all'interno di un'immagine (utile anche per antispoofing). Nella sua prima versione va a considerare una griglia 3x3 dove a ognuno dei quali viene assegnato un valore binario: se il suo valore era maggiore del pixel centrale viene assegnato 1, altrimenti 0. Effettuando questa operazione con un ordine di processo dei vicini (parto dal vicino in alto a sinistra ad es.) si ottiene una stringa binaria, il cui valore convertito in decimale viene assegnato al pixel centrale. Sarà il valore del pixel nella nuova immagine.
È tipo una convoluzione ma molto più semplice.
![[Pasted image 20241106133301.png]]
Possiamo ottenere l'istogramma di questi valori e considerarlo come una feature.
Inoltre possiamo ottenere una misura di contrasto: (media valori dei pixel con valore maggiore del centrale) - (media valori dei pixel con valore minore del centrale)
![[Pasted image 20241106133935.png]]
Ottengo un'immagine LBP (grayscale) e un istogramma LBP.
L'immagine può banalmente poi essere usata come input di una deep network.
Si può estendere per RGB? Beh sì basta che ripeto il processo per ogni immagine e faccio la media dei 3 risultati, ma ci sono strategie migliori.
###### Versione migliorata
In questa versione scelgo io il numero di pixel vicini (P) e il loro raggio di distanza (R), il valore di un pixel $p_{c}$ si calcolerà quindi come:
$$LBP_{R,P}=\sum_{i=0}^{P-1}sign(p_{i}-p_{c})2^P$$
sign torna 1 se >= 0, altrimenti 0.
![[Pasted image 20241106134544.png]]
p.s. la rappresentazione come immagine LBP è possibile solo se P=8.
Un pattern viene detto **uniforme** se nella stringa binaria contiene al massimo due transizioni $0 \to 1$, $1 \to 0$. Questi rappresentano le informazioni essenziali e ci consentono di ridurre notevolmente il numero di punti da considerare riducendo la dimensionalità, dato che sono solo $P(P-1)+2$ su un totale di $P^2$ possibili pattern.
![[Pasted image 20241106135449.png]]
Da questo esempio si dovrebbe capire come le informazioni importanti alla fine siano tutte comprese nei pattern uniformi: ![[Pasted image 20241106135815.png]]
La seconda immagine contiene i pixel associati a pattern **uniformi**, la terza pixel associati a pattern **non uniformi**.
Come possiamo ottenere un vettore di features?
- l'immagine viene suddivisa in sotto-finestre, ottenendo una griglia $k \times k$
- per ogni sotto-finestra calcoliamo un istogramma (ad ogni bin corrisponde un pattern)
- il vettore finale viene costruito concatenando i $k^2$ istogrammi.
![[Pasted image 20241106140102.png]]
![[Pasted image 20241106140241.png]]
Le rotazioni modificano l'LBP.
### Classificazioni di sistemi di riconoscimento facciale
- **Metodi basati sull'apparenza della faccia (global/holistic appearance methods):** PCA, LDA, alcune reti neurali. Utilizzano l'immagine per intero invece di concentrarsi solo su alcune regioni, non perdendo informazioni da subito. Svantaggi: danno la stessa importanza ad ogni pixel, necessitano di alta correlazione tra training e test set, non performano bene su grandi variazioni PIE.
- **Metodi basati su feature locali:** EBGM, LBP. Sono robusti a varianze di posizione in quanto vengono prima individuati i punti da cui estrarre le feature, e inoltre sono computazionalmente veloci. Come principale svantaggio hanno la scelta a priori dei punti da cui estrarre le feature, se non sono molto discriminativi le performance saranno pessime.
- **Sistemi basati su grafi:** a ogni faccia è associato un grafo, dove ogni nodo corrisponde a punti discriminativi della faccia. Ottimi dal punto di vista di variazioni di posizione e illuminazione. Train e test molto lunghi.
- **Sistemi basati su immagini termografiche o a infrarossi:** ottimi per quanto riguarda variazioni di illuminazione, però richiedono attrezzatura adeguata e la temperatura misurata varia in base allo stato del soggetto. Molto sensibili ai movimenti.
- **Reti neurali:** mirano a simulare il modo in cui funzionano i neuroni del cervello. Ogni neurone è rappresentato da una funzione matematica, approccio ideale: usare un neurone per pixel ma richiede tantissimi neuroni. Quindi spesso si usa una rete per estrarre feature dall'immagine / comprimere l'immagine e poi una rete per la recognition effettiva. Sono molto robuste ma richiedono un training set molto grande. Altri possibili problemi: overfitting, overtraining (non generalizza), diventano inefficienti all'aumentare del numero di soggetti nel database.
###### Overfitting
Quando la rete ha troppi parametri rispetto alla dimensione dell'input.
###### Overtraining
Il sistema perde la capacità di generalizzare.
### Approcci Deep Learning: DeepFace di Facebook
Include una fase di allineamento.
- l'obiettivo della fase di allineamento è generale una faccia frontale a partire dall'immagine che può contenere facce con posizioni o angoli differenti. Il metodo proposto si basa dei "fiducial point" (punti estratti dalla faccia) per estrarre la fraccia frontale
- generazione della faccia 2D, che non è altro che la faccia croppata dall'immagine di partenza
- applicazione dei 67 fiducial point sull'immagine. Generazione di un modello 3D
- frontalizzazione della faccia
![[Pasted image 20241106142503.png]]![[Pasted image 20241106142523.png]]![[Pasted image 20241106142539.png]]
Le facce "frontalizzate" saranno l'input della rete neurale:
![[Pasted image 20241106142610.png]]
### Approcci Deep Learning: FaceNet di Google
Raggiunse il miglior risultato sul dataset Labeled Faces in the Wild e Youtube Face Database.
Fa uso di deep architectures come **ZF-Net** e **Inception Network**. Usa poi un metodo chiamato **triplet loss** come funzione loss per il training.
![[Pasted image 20241106143837.png]]
- normalizzazione least squares: riscala i vettori in modo che la loro norma L2 sia 1 (ogni vettore è diviso per la norma L2)
- la norma L2 calcola la distanza delle coordinate del vettore dall'origine dello spazio vettoriale, anche detta norma euclidea.
##### Triplet loss
ha l'obiettivo di rendere piccola la distanza al quadrato (squared distance) tra gli embedding di due immagini corrispondenti alla stessa identità, indipendentemente dalla posa o altre condizioni, e di rendere grande la distanza tra immagini corrispondenti a identità diverse.
![[Pasted image 20241106144314.png]]

View file