Lab Streaming Layer or LSL is a system for measuring, monitoring, and recording time-synchonized data streams during experiments. It is a tool for data acquisition and analysis that is used in neuroscience, psychology, and other fields. It can be used with a large variety of data types, including EEG, fNIRS, EMG, eye-tracking, and MEG.
chmod +x *.deb
sudo dpkg -i liblsl-bin_*.deb
pip3 install pylsl
1.Run the above code to start streaming triggers.: * python3 code.py
* Alter the parameters in the example progam if needed. 2.Open Aurora on Windows and connect with the fNIRS device. 3.On the configuration page, select the desired probmap and click Edit
as shown in the image below.
4.In the Basic parameters
tab, add triggers (ideally, the same number as defined in the python program).
5.Verify that the Data out stream name
and Data in stream name
same as defined in the python program.
6.Now you should be able to see the data with triggers in the Aurora console.
7.The trigger input may be automated to your needs.
]]>This article outlines the vision, goal, and challenges faced in robotics research. It provides a brief overview of the current state of robotics, its research, and the challenges faced by the robotics community. Towards the end, it talks about the exciting future the robotics community as a whole has to offer.
Significant developments in robotics started with the industrial revolution. The early robots very quite simple in function and were employed only for particular purposes. The majority of them were specifically developed for the industrial environment, and other applications we seen in today’s world were either absent or were in infancy. Today, developments in robotics are happening faster than ever, with new ideas and papers popping up at unprecedented rates. To a person unacquainted with the latest research and developments, robotics might appear quite stale and something limited to the factory environment with a repetitive hardcoded task. In reality, the field of robotics is exceptionally vast in itself and requires knowledge from a variety of disciplines. The majority of the current work focuses on one of these subareas: robot learning (tasks such a grasping, walking), navigation (vision, SLAM, LiDARs), design (mechanism, compliant), Human-Robot-Interaction, and more. The earlier notion of robots working in the confined factory environment is rapidly changing, and robotics makes its space in numerous newly envisioned areas.
A major portion of the robotics research at present focuses on building intelligent machines with human-like ability. One of the goals of robotic research is to generalize to the maximum extent possible. For example, instead of creating a robot to grasp a specific object (or type), the focus is on grasping various object types (rigid, deformable, soft). A major challenging task is a sim to real transfer, many a time the research community needs to devise solutions by using physics-based simulators, as real-world experiments are very costly. Such simulators are quite popular now (i.e., PyBullet, OpenAI Gym, etc.) for learning-based tasks as they are fast, cheap, and easily accessible. The major problem arises when the learning is transferred to the real-world system, i.e., the physical robot, due to several potential issues such as inaccurate model representation resulting in undesirable behaviors. At times, research work doesn’t include real-world experiments due to various constraints, severely affecting research reproducibility. Furthermore, due to the dynamic nature of the real-world system and inaccuracies, it might not be possible to accurately replicate the experiments even if they might have been tested previously in the real world. Reproducibility is challenging in this area, and it significantly hampers the research output. Even though there are methods that real experiments have validated, there is a high tendency of failure as often the tests are conducted in a well-designed lab setting which eliminates the harshness and new unseen challenges of the actual environment. This level of generalization is a big challenge and needs to be addressed to unleash the robotics capabilities.
The hardcoded nature of robots and confined workspaces is no longer the optimal solution for many tasks requiring flexibility and agility, and there is a need to develop. More can be achieved by designing unrestrained intelligent machines. Advancements in robotics can significantly transform people’s lives in numerous aspects, including rescue, rehabilitation, security, and social health. Another emerging area is the Human-Robot-Interaction (HRI), which shall help improve the combined system performance by inculcating trust in the two players. At present, there is a myriad of dangerous tasks such as hazardous rescue operations and tasks such as manual scavenging that people are conditioned to perform due to a lack of alternatives. With the ongoing research and advancement, robotics shall transform people’s lives fundamentally and in several aspects. Building robots similar to humans in terms of agility, perception, and motor skills hold significant weight and potential.
References
[1] Zeng, Andy, et al. “Transporter networks: Rearranging the visual world for robotic manipulation.” arXiv preprint arXiv:2010.14406 (2020).
]]>Clustering is a unsupervised Machine Learning algorithm that groups a set of objects in such a way that objects in the same group (called a cluster) are more similar (in some sense) to each other than to those in other groups (clusters). [Suggested introductory reading]. Here, I shall talk about three of them namely EM clustering, k-means and hierarchical clustering.
We have \(N\) data samples (unlabelled) \(D= \{ x_1,x_2,\dots,x_N \}\) spanning \(c\) classes \(w_1,w_2,\dots,w_c\). In order to simplify our analysis let’s assume \(c=3\) and \(N=500\). We can write the prior and likelihood as follows
Prior | Likelihood |
---|---|
\(P(w_1)\) | \(P(x/w_1) \sim \mathcal{N}(\mu_1,\sum_1)\) |
\(P(w_2)\) | \(P(x/w_2) \sim \mathcal{N}(\mu_2,\sum_2)\) |
\(P(w_3)\) | \(P(x/w_3) \sim \mathcal{N}(\mu_3,\sum_3)\) |
The problem can be formulated as a GMM
\[P(x/\theta)=P(w_1)P(x/w_1)+P(w_2)P(x/w_2)+P(w_3)P(x/w_3)\]Given, the data points \(\{ x_1,x_2,\dots,x_N \}\) our goal is to find the parameter \(\theta\) (consists of \(\mu_i \text{, } \sum_i \text{ and } P(w_i)\)) using MLE (ML Estimation).
We can find the parameters using an iterative scheme. We can initialize \((\mu_i,\sum_i)\) with some random values and then iterate over the expectation and maximization steps until convergance is achieved.
Expectation
Assuing \((\mu_1,\sum_1)\) are available, we can perform Bayesian classification on \(\{ x_1,x_2,\dots,x_n \}\) using likelihood at some iteration as
\[x_k \in w_i \text{ iff } P(x_k/w_i)>P(x_k/w_j) \forall j \neq i\]Maximization
Given some \(x_k\), then what are \((\mu_i,\sum_i)\) that maximize for those \(x_k\) to have \(P(x_k/w_i) \sim \mathcal{N}(\mu_i,\sum_i)\)?
\[\{ x_1,x_2,\dots,x_n \} \in w_i\]Using MLE,
\(\mu_i = \frac{1}{N_i} \sum_k x_k \forall x_k \in w_i\) \(\sum_i = \frac{1}{N_i} \sum_k (x_k-\mu_i)(x_k-\mu_i)^T \forall x_k \in w_i\)
Thus, we have the updated values for $(\mu_i,\sum_i)$ and can now again perform expectation step in an iterative way untill convergance.
Let us assume identity covarience matrix i.e. $ | \sum | = 1 $, we can write \(P(x_k/w_i) = \frac{1}{(2\pi)^{d/2}} e^{ \frac{-1}{2} (x_k-\mu_i)^T (x_k-\mu_i)} = \frac{1}{(2\pi)^{d/2}} e^{ \frac{-1}{2} \| x_k-\mu_i \| ^2 }\)
Algorithm
As shown in the above two figures the k-means algorithm correctly clusters the data points into three clusters.
Hierarchical clustering is a clustering method which seeks to build a hierarchy of clusters based on some distance or similarity meteric. This can be further classified as
Based on the distance meteric used the agglomerative clustering can be further classified as
Example: Single Link
Suppose that we have the given points \(x_1,x2,\dots,x7\) with the distances shown below.
x1 ------- x2 ------- x3 ------- x4 ------- x5 ------- x6 ------- x7
1 1.1 1.2 1.3 1.4 1.5
To form clusters, we treat the individual points as clusters and grow them. Find the distance between the clusters using \(d = \min \| X-Y \|^2 \text{ where, } X \in c_1 \text{ and } Y \in c_2\) and merge \(c_i\) with \(c_j\) if \(d(c_i,c_j) \leq d(c_i,c_k) \forall k \neq j\). Finally we can obtain
x1 x2 x3 x4 x5 x6 x7
| | | | | | |
| | | | | | |
------------ 1 | | | | |
| | | | | |
| | | | | |
------------------ 1.1 | | | |
| | | | |
| | | | |
--------------------- 1.2 | | |
| | | |
| | | |
--------------------- 1.3 | |
| | |
| | |
--------------------- 1.4 |
| |
| |
---------------------- 1.5
Example: Complete Link
We can use the same example distances given in single link example. Here, we can find the distance between the clusters using \(d = \max \| X-Y \|^2 \text{ where, } X \in c_1 \text{ and } Y \in c_2\) and merge \(c_i\) with \(c_j\) if \(d(c_i,c_j) \leq d(c_i,c_k) \forall k \neq j\). Finally we can obtain
x1 x2 x3 x4 x5 x6 x7
| | | | | | |
| | | | | | |
------------ 1 | | | | |
| ------------- 1.2 | | |
| | ------------ 1.4 |
| | | |
| | | |
| | ----------------- 2.9
------------------------ 3.3 |
| |
| |
--------------------------------------------- 7.5
In this blog we shall see how to build a Feedforward Neural Network from scratch, we shall use this for performing MNIST digit classification. First, we shall bring out the mathematical framework of the feed-forward neural network. This network shall use sigmoid activation for the hidden layers and softmax for the last layer with multi-class cross entropy loss (see later sections for details). Before proceeding any further we shall now define a few notations and terminologies.
\(l\) indicates a layer in the network, here, \(1 \leq l \leq N\) where $N$ represents the numbers of layers in the network (Note: as per the convention input layer is not counted when we say $N$-layer neural network. Furthermore, for the network shown in Fig.1 $N=2$).
Subscripts $k,j,i,\dots$ usually denotes neuron indices in layers $l=N,N-1,N-2,\dots$
$z_k^l$ represents the weighted sum of activations from the previous layer at layer $l$. That is,
\[z_k^l=\sum_j w_{kj}a_j^{l-1}+b_k\]$a^l_k$ represents the neuron activations at layer $l$, $a^l_k=f(s^l_k)$, where $f(.)$ is the activation function. We shall be using softmax activation for the last layer $(l=N)$
\[a^N_k = \frac{e^{z_k^N}}{\sum_c e^{z_c^N}}\]Here, $c$ is the number of classes. For all other layers $(l\neq N)$ we shall use the sigmoid activation function.
\[a^l_k = \frac{1}{1+e^{-z_k^l}}\]$y_k$ is the ground truth (one-hot encoded) vector for the $k^{th}$ sample.
$\hat{y}_k$ is the predicted vector for the $k^{th}$ sample.
Now let us consider a Neural Network having two layers $(N=2)$ as shown in Fig. [[fig:nn_vis]]. Here, we have $n$ neurons in the input layer (features), $nh$ neurons in the hidden layer and $no$ neurons in the output layer. As an aside, $1\leq i \leq n$, $1\leq j \leq nh$, and $1\leq k \leq no$. We shall now layout the equations for the forward pass through the network. For layer $l=N-1=1$
where, $a_i^{l-1}=a_i^0 = x_i^0$. Now we shall pass this weighted sum $s_j^l$ through the activation function $f_1()$ i.e. sigmoid activation.
\[a_j^l=f_1(z_j^l)\]This output of layer $l=1$ is now fed to layer $l=2$ i.e. the output layer. For layer $l=N=2$
\[z_k^l=\sum_j^{nh} w_{kj}a_j^{l-1}+b_k\]Similarly, we shall fed this weighted sum to another activation function $f_2()$ i.e. softmax activation.
\[a_k^l=f_2(z_k^l)\]The final output vector $a_k^l$ contains the probability for the $k^{th}$ class. This class prediction might not make much sense as they take in weights and biases which are randomly initialized. Our prime goal here is to find the weights such that the predicted class probabilities are consistent with the ground truth labels in the training data. In order to achieve this, we need to come up with a metric to measure the goodness (or badness) of the network, this can be done by constructing a loss function. The loss function can then be used to perform optimization by updating weights. We shall be using the multi-class cross-entropy loss in our approach. The loss for a given sample can be calculated using it’s one hot encoded vector $(y)$ and the prediction $\hat{y}$ (which is essentially $a_k^l$ or $a_k^2$ for $l=2$).
\[L(\hat{a},a) = -\sum^c_{k=1} y_k \log \hat{y_k}\]This can then be used to calculate loss across all samples (total number of samples: $m$) as
\[J(w^1,b^1,\dots) = \frac{1}{m} \sum_{i=1}^mL(\hat{y}^i,y^i)\]One important result that we take directly without any derivation is the gradient of $J$ with respect to $z_k^{l=2}$ (simplified as $z^2$).
\[\frac{\partial J}{\partial z^{2}} = \hat{y} - y\]
In this subsection, we shall bring out the mechanism to update the weights and biases by backpropagating the loss into the network. We shall update the weights using an iterative approach, more precisely using the Stochastic Gradient Descent (SGD). The weights can be updated using
Here, $\eta$ is a hyperparameter called learning rate. Similarly, the biases can also be updated.
\[b_{k}(t+1) = b_{k}(t) - \eta \frac{\partial J}{\partial b_{k}}\] \[b_{j}(t+1) = b_{j}(t) - \eta \frac{\partial J}{\partial b_{j}}\]Now, our goal is to find the gradients. This gradients can be obtained by backpropagating via the network usinf the chain-rule.
\[\frac{\partial J}{\partial w_{kj}} = \frac{\partial J}{\partial z^{2}} \frac{\partial z^{2}}{\partial w_{kj}} = (\hat{y} - y) z_k\] \[\frac{\partial J}{\partial b_{k}} = \frac{\partial J}{\partial b_{k}} \frac{\partial z^{2}}{\partial b_{k}} = (\hat{y} - y)\] \[\frac{\partial J}{\partial w_{ji}} = \frac{\partial J}{\partial z^{2}} \frac{\partial z^{2}}{\partial a_{j}} \frac{\partial a_{j}}{\partial z^{1}} \frac{\partial z^{1}}{\partial w_{ji}}= (\hat{y} - y) w_{kj} f_1(z^1)(1-f_1(z^1)) a_i\] \[\frac{\partial J}{\partial b_{j}} = \frac{\partial J}{\partial z^{2}} \frac{\partial z^{2}}{\partial a_{j}} \frac{\partial a_{j}}{\partial z^{1}} \frac{\partial z^{1}}{\partial b_{j}}= (\hat{y} - y) w_{kj} f_1(z^1)(1-f_1(z^1))\]Hence, by using the above set of equations we can run SGD and update the trainable parameters for this two layered network. The same idea can be extended to build multilayered networks.
The full Python3 impmentation with explaination can be found in this Jupyter notebook. The model was trained using different combinations of activation functions and # of neurons (all models have same learning rate of $0.1$). The test accuracy has been shown in Table 1. The accuracy is highest for the sigmoid activation using $265$ neurons. For the sigmoid activation the accuracy increases with increase in # neurons, while for the ReLU and tanh activation it first increases and then goes stagnant. This can be attributed to the fact that we haven’t applied early stopping in our training process as it is a well known fact that Early stopping is some form of L2 Regularization. We wanted to perform our analysis on same set of parameters. In practice, it is a good idea to use early stopping by choosing some threshold where the validation loss starts increasing by that threshold than the previous validation loss. One important observation here is that performance of ReLU is not as expected. This is attributed to the fact that we required a higher learning rate of 0.1 in SGD for Sigmoid activation function to converge. For lower learning rates the SGD wasn’t converging whereas performance of ReLU was improving significantly improved as expected. Therefore, to test over same parameters we finally chose learning rate to be 0.1.
Activation # Neurons | Sigmoid | ReLU | Tanh |
---|---|---|---|
32 | 89.44 | 39.12 | 71.06 |
64 | 89.98 | 64.16 | 74.40 |
128 | 90.32 | 61.82 | 69.78 |
256 | 91.62 | 31.68 | 55.06 |
Table 1: Test accuracy using different number of hidden neurons and activations
Training time for same set of parameters is shown in Table 3. It can be observed that tanh takes the largest training time whereas ReLU is the fastest. Also training time is increasing with # of neurons as expected.
Activation # Neurons | Sigmoid | ReLU | Tanh |
---|---|---|---|
32 | 133.137 | 116.511 | 145.912 |
64 | 170.921 | 152.531 | 205.702 |
128 | 255.141 | 207.650 | 298.367 |
256 | 371.729 | 288.749 | 448.806 |
Table 2: Training time \((s)\) for different number of hidden neurons and activations
Algorithm
- Insert start point in the tree
- While tree cannot connect to goal
- Sample random point r in the image space
- Find point p in the tree that is closest to r
- Add branch of defined length from p to r
- If new branch intersects with obstacle then either discard or trim it
- Find the path from start to end through the tree
The above figure shows the output path produced by using RRT. Complete python implementation can be found on GitHub. In the future I will be making the path smoother by using splines and make it less convoluted.
]]>Being Lonely
As I determined to stay lonely at home
Except adventure all thoughts of my mind had gone
Soon the day turned dark
And my heart began to throb with fear
By missing my loved ones
I mourn I grief and pain
My life was a bore in the empty house
I even thought of running away
“never fear, never lose” was the quote of my mom
I remembered
Until the night passed I slept fearlessly.
]]>Nature Travel
It is boundless to infinity
It’s lush and green
With crops like
Banana millets and rice
My heart got wings
The time I saw it
Small and large
Flowing through a path full of brooks
Its flow provides me inspiration
That’s hard to explain
Listening natural music
Full of mixtures
My heart throbbed like never before
So peaceful and calm
Can life be?
We people don’t realize it.
My main motive for writing this post is to motivate undergraduate students, especially in the freshman and sophomore year to get involved in cutting edge research. I know some will say this is too early and the students might not have the required skills, knowledge and the know-how, let me tell you that this is an utter excuse, you need to get started first and all the required knowledge will fall in place as you progress.
Pro Tip: Look inside, find your interests however obscure they might seem and find the right person (or the right Professor) in that field and follow along with them.
This complete journey has been a very exciting and thrilling one, it not only helped me learn how research is carried out but also helped me carve out my future endeavours. It all started in my fourth semester when I felt I had some spare time which can be exploited, this combined with my love for Physics led me to meet my Physics professor at the institute - Dr. PC Deshmukh to discuss any possible research opportunities that he might have for me. Luckily, he had one and the rest is history.
]]>After my brief stay of about two months, I can now safely say that the Americans are much more outgoing and friendly than what I had expected. I was welcomed with full enthusiasm and cheerfulness. At no point, I felt excluded from the group or being treated as a foreigner be it the clubhouse, the research group, my roommates, the hackathon team or the skateboard sessions.
I was accommodated in a 4BHK apartment, one of which was empty so I was having two American roommates and it’s no exaggeration that they were super amazing and humble. Oh boy one of them had a cat and I still can’t forget her, she was so adorable and fun to play with. Actually, playing with the cat was a great stress buster after a full day of involved work. I feel that I have so much to talk about the cat that it can make up for a separate blog. One really nice thing in the US is that almost everyone owns a car and is the common mode of transport similar to what motorbikes are to India. Kudos to my roomates who once took me to skatepark which was a completely refreshing experience, it was my first time but they helped me a lot and I was rolling on flat surfaces and turns within an hour.
Some more things which are common in the US but were slightly new for me - Greeting people at work, store etc with phrases like “How’s is it going?” or “Howdy?”, the latter being a more popular and exotic slang in Texas and particularly the university area. One more very interesting thing was that the sun used to set at around 8:30PM and so it would get dark only by 9PM, this grealtly increases the work that you can pull off in a day; to me it felt like having two days at once.I loved the green cover and maintence in almost all places in Texas I went by. My only painpoint was cooking, which I rarely enjoy and ofcourse no one wnats to cook after a full day at work.
To conclude it was a completely different and one of a kind experience which I will cherish my whole life. I got to meet people from various nationalities, including but not limited to - United States, China, Qatar, Pakistan, Cyprus, Mexico. Thank you everyone who directly or indirectly contributed to my make my trip succesful.
Some pictures that I clicked there …
]]>