Skip to content

Instantly share code, notes, and snippets.

View giuseppefutia's full-sized avatar
🎯
Focusing

Giuseppe Futia giuseppefutia

🎯
Focusing
View GitHub Profile
@giuseppefutia
giuseppefutia / neo4j.md
Last active October 14, 2023 04:24
Neo4j

Set a property only if exists

MATCH (n {name: 'Andy'})
SET (CASE WHEN n.age = 55 THEN n END).worksIn = 'Malmo'
RETURN n.name, n.worksIn

Create and mantain a property list of unique values:

@giuseppefutia
giuseppefutia / 100daysofprobability.md
Last active June 9, 2022 07:39
100DaysOfProbability

Probabilistic models and sample spaces

June 8th, 2022

  • L01.1 Lecture Overview
  • L01.2 Sample Space
  • L01.3 Sample Space Examples

Notes

Probabilistic model.

@giuseppefutia
giuseppefutia / gat_aggr.py
Created January 18, 2021 09:44
Neighborhood aggregation scaled with attention scores
# equation (4)
print('\n\nNeighborhood aggregation (GCN) scaled with attention scores (GAT). Shape(n, emb)\n')
ND_GAT = A_scaled.dot(z1)
print(ND_GAT)
@giuseppefutia
giuseppefutia / gat_att_normalized.py
Created January 18, 2021 09:34
Attention scores normalization
# equation (3)
print('\n\n----- Edge scores as matrix. Shape(n,n)\n')
e_matr = np.zeros(A.shape)
e_matr[edge_coords[0], edge_coords[1]] = e.reshape(-1,)
print(e_matr)
print('\n\n----- For each node, normalize the edge (or neighbor) contributions using softmax\n')
alpha0 = softmax(e_matr[:,0][e_matr[:,0] != 0])
alpha1 = softmax(e_matr[:,1][e_matr[:,1] != 0])
alpha2 = softmax(e_matr[:,2][e_matr[:,2] != 0])
@giuseppefutia
giuseppefutia / gat_att_02.py
Created January 18, 2021 09:32
Attention coefficient for edges
# equation (2) - Second part
print('\n\n----- Attention coefficients. Shape(1, len(emb.concat(emb)))\n')
att = np.random.rand(1, z2.shape[1])
print(att)
print('\n\n----- Edge representations combined with the attention coefficients. Shape(1, number of edges)\n')
z2_att = z2.dot(att.T)
print(z2_att)
print('\n\n----- Leaky Relu. Shape(1, number of edges)')
@giuseppefutia
giuseppefutia / gat_att_01.py
Last active January 18, 2021 09:31
Edge concatenation
# equation (2) - First part
print('\n\n----- Concat hidden features to represent edges. Shape(len(emb.concat(emb)), number of edges)\n')
edge_coords = np.where(A==1)
h_src_nodes = z1[edge_coords[0]]
h_dst_nodes = z1[edge_coords[1]]
z2 = np.concatenate((h_src_nodes, h_dst_nodes), axis=1)
@giuseppefutia
giuseppefutia / gat_linear.py
Created January 18, 2021 09:23
Linear transformation
# equation (1)
print('\n\n----- Linear Transformation. Shape(n, emb)\n')
z1 = X.dot(W.T)
print(z1)
@giuseppefutia
giuseppefutia / gat_graph.py
Created January 18, 2021 09:21
GAT - Graph Generation
print('\n\n----- One-hot vector representation of nodes. Shape(n,n)\n')
X = np.eye(5, 5)
n = X.shape[0]
np.random.shuffle(X)
print(X)
print('\n\n----- Embedding dimension\n')
emb = 3
print(emb)
@giuseppefutia
giuseppefutia / research-scientist-internship.md
Last active December 27, 2020 16:49
Prepare your Curriculum - Research Scientist Internship

This gist includes a curriculum to prepare your application for Research Scientist positions, focusing on Natural Language Understanding (NLU) and Graph Neural Networks (GNNs).

The approach adopted for this curriculum is code-first, teach later, theory in the middle.

Many curricula available on the Web suggest beginning with the theory (a lot of theory) before creating something. However, many books provide details using only math and statistics, which require a lot of time and energy for understanding. Math is fundamental. But after days spent on a few pages of a book, you risk not having a real insight into how things work. Moreover, to internalize some tricky concepts, the best solution is to teach those concepts to someone who does not know much about the topic.

Learning Framework

For this reason, the learning framework adopted in this curriculum will be structured according to the following steps:

  1. Searching articles, tutorials, and videos on the Web help you build intuition and start
@giuseppefutia
giuseppefutia / fork forced sync
Last active April 10, 2019 09:07 — forked from glennblock/fork forced sync
Force your forked repo to be the same as upstream.
Keep your master aligned with the original master
```
git remote add upstream https://github.com/some_user/some_repo
git fetch upstream
git checkout master
git reset --hard upstream/master
git push origin master --force
```