Finding postive and negative anchors for RPN (in faster RCNN) - deep-learning

I have been going through Faster RCNN Paper and I am facing a trouble understanding how to find out the positive and negative anchors at the time of training RPN's
As per the paper (Section 3.1.2), for each anchor, authors assign a positive label for
The anchor/anchors with the highest IoU overlap with a ground-truth box
An anchor that has IoU overlap higher than 0.7 with any ground-truth-box
for finding the negative proposal (background proposal), go through the remaining anchors and assign a negative label if
IoU is less than 0.3 for all ground-truth box
The remaining anchors even after this step are ignored while training.
EXAMPLE
G/A
A1
A2
A3
A4
A5
A6
A7
A8
A9
A10
G1
0.54
0.44
0.02
0.03
0
0.25
0.78
0.71
0.29
0.01
G2
0.63
0.28
0.68
0.62
0.9
0.21
0.73
0.26
0.27
0.14
G3
0.66
0.26
0.03
0.64
0.54
0.53
0.47
0.46
0.15
0.02
After applying rule 1 (for each ground truth, find the maximum IoU with anchor and assign it as positive), So
For G1, the highest value is for A7, so A7 is matched to G1
For G2, the highest value is for A5, so A5 is matched to G2
For G3, the highest value is for A1, so A1 is matched to G3
A1
A2
A3
A4
A5
A6
A7
A8
A9
A10
G1
G2
G1
After applying rule 2 we will get (for each anchor box, if IOU is greater than 0.7, then assign to the ground-truth)
For A8, the maximum value occurs with G1, so A8 is matched with G1
A1
A2
A3
A4
A5
A6
A7
A8
A9
A10
G1
G2
G1
G1
After applying rule 3 we will get
A1
A2
A3
A4
A5
A6
A7
A8
A9
A10
G1
G2
G1
G1
N
N
Now all the remaining one are marked as ignored.
A1
A2
A3
A4
A5
A6
A7
A8
A9
A10
G1
I
I
I
G2
I
G1
G1
N
N
My questions :
I wanted to know if my understanding is right or wrong ?
Also, if the rules are applied in different order then will it change the final output ?
In the above example, for rule 1 if suppose G2 maximum is also A7, then A7, then how should one decide G1 or G2 (I suppose choose the one which has the maximum, but I am not sure though)
Thanks.

Related

MariaDB / MySQL Combine two tables

I have 2 tables tnHeaders and tnData
tnHeaders
fnIDX
fnDESCRIPTION
1
h1
2
h2
3
h3
tnData
fnIDX
fnHEADER_IDX
fnDESCRIPTION
1
1
d1
2
1
d2
3
1
d3
4
2
d4
5
2
d5
6
2
d6
7
3
d7
8
3
d8
9
3
d9
and would like to produce this output
fnOUTPUT
h1
d1
d2
d3
h2
d4
d5
d6
h3
d7
d8
d9
I can do this in code no problem, but how can I do this in SQL? (Make the server work)
You need to use UNION ALL for the descriptions of both tables and sort the results in such a way that headers are on top of their data:
SELECT fnOUTPUT
FROM (
SELECT fnDESCRIPTION fnOUTPUT, fnIDX header_index, 1 is_header FROM tnHeaders
UNION ALL
SELECT fnDESCRIPTION, fnHEADER_IDX, 0 FROM tnData
) t
ORDER BY header_index, is_header DESC, fnOUTPUT;
See the demo.

How to start measure halfway?

In my hymn, I need to start the first measure halfway through. It has a time of 3/4, but I have to insert two empty, non-showing eighth notes. How do I do that?
I've used o4 o4 c8[ d] below for the first measure, but lilypond does not like this. What's the right way?
Here's the line:
o4 o4 c8[ d] e4 e4 e8[ f] g4 g4 f8[ e] d4 d4 g8[ f] e2
For upbeats, there's a special command \partial available. In your case, you should notate a quarter partial:
\relative c' {
\time 3/4
\partial 4
c8 d | e4 e4 e8 f | g4 g4 f8 e | d4 d4 g8 f | e2
}
This results in:

Circuit design that outputs square of binary input

So for my digital logic course, we were asked to design a combinational circuit with 3 inputs, and an output that generates the square of the binary input. I assume she means the inputs are 3 bit binary numbers 0-7. In describing the solution, she mentioned 3 general steps of 1. Finding truth table, 2. deriving the function and 3. Simplifying
I understand perfectly how to do this when the output is a single function (combine the instances of a true function, simplify etc.) In our only relevant example, we input BCD numbers 0-9 and output their excess-3 equivalent, then simplified a k-map for each of the 4 output variables (a map for W, the leftmost bit, X the second-to-left bit, etc.). Not sure what to do from here tho. Thanks for the help
As you already mentioned, you need to fetch the inputs in binary, calculate the square in binary format (the binary length will increase from 3 to 6).
But, you don't need those BCD numbers and output their excess-3 equivalent. That would rather make the problem more complex. Simply do as directed below.
So, for the 3 different bit combinations, you need to generate a function in terms of combinational circuit that will yield a 6-bit square of the given number.
So, your input set = {b0,b1,b2} and your output set = {B1,B2,B3,B4,B5,B6}.
Then, you need to draw the truth table of 3-bit to 6-bit square converter as :-
Input B6 B5 B4 B3 B2 B1 B0
b0
b1
b2
Fill the entries, that's the homework for you.
And, then when you have output bits B6,B5,...,B0 in terms of b0,b1 and b2, just simplify all the functions.
If you still have any doubt, comment below. I will help you with your issue. Good luck.
I have used Logic Friday 1 to derive the following minimized expression for the six outputs of your multiplier:
ab5 = a2 a1 b2 b1 + a2 a1 a0 b2 b0 + a2 a0 b2 b1 b0;
ab4 = a2 a1' a0' b2 + a2 a1' b2 b1' + a2 a0' b2 b1'
+ a2 a1' b2 b0' + a2 b2 b1' b0' + a2' a1 a0 b2 b1
+ a2 a1 b2' b1 b0 + a1 a0 b2 b1 b0;
ab3 = a2' a1 a0' b2 + a2 a1' b2' b1 + a2' a1 b2 b1'
+ a2 b2' b1 b0' + a2' a1 a0 b2' b1 b0 + a2 a1' a0 b2 b1' b0
+ a1 a0' b2 b1' + a2 a1' b1 b0' + a2 a0' b2 b1 b0
+ a2 a1 a0 b2 b0';
ab2 = a2' a1 a0' b1 + a2 a1' a0' b0 + a2 a0' b1' b0
+ a1' a0 b2 b0' + a1 a0' b1 b0' + a1 b2' b1 b0'
+ a0 b2 b1' b0' + a2' a0 b2 b0 + a2 a0 b2' b0;
ab1 = a1' a0 b1 + a1 a0' b0 + a1 b1' b0 + a0 b1 b0';
ab0 = a0 b0;
As a truth table:
The original truth table has 64 rows.
The largest output number is 49 = 7 * 7 = 32 + 16 + 1.
Therefore, six (= 3 + 3) output bits are sufficient.

Get Hierarchial Data using LINQ

ID Name Designation PID
1 E1 D1 0
2 E2 D2 0
3 E3 D3 1
4 E4 D3 1
5 E5 D4 3
6 E6 D4 3
7 E7 D4 2
8 E8 D4 2
How can we get all the child employees based on the parent employee using LINQ ?
For eg., if we want child records for employee E1 we should get E3,E4,E5,E6
Thanks in advance...
You can't do it using one single LINQ query. But you can do it using a recursive function smth like:
IList<Employee> GetAllChildren(IList<Employee> employees, int pid)
{
var children = employees.Where (e => e.PID == pid).ToList();
children.AddRange (children.SelectMany (e => GetAllChildren (employees, e.ID)).ToList());
return children;
}

Count rows to end

id date group n1 n2 n3 n4 n5
18853 1945-01-05 BA 87 34 1 59 50
18854 1945-01-13 BA 6 66 1 16 48 <= the last 16, 7 rows to the end
18855 1945-01-20 BA 38 14 24 78 36
18856 1945-01-27 BA 49 30 87 15 65 <= the last 49, 5 rows to the end
18857 1945-02-03 BA 30 64 36 5 32
18858 1945-02-10 BA 15 36 37 86 31 <= the last 36, 3 rows to the end
18859 1945-02-17 BA 86 78 69 7 60 <= the last 86, 2 rows to the end
18860 1945-02-24 BA 83 7 72 88 19 <= the last 7, 1 row to the end
18861 1945-03-03 BA 47 20 77 73 30 <= the last 47, 0 rows to the end
I have the above table (it's ordered by id, however I plan to order it by date). Is there a way to get the number of rows between a specified number and the last row in mySql?
Note that some numbers are repeated twice or more times. The script should use the lowest rows.
Here is the table that mySQL should output:
Number|Rows count to the end
16|7
7|1
86|2
49|5
47|0
36|3
The query should search columns n1, n2, n3, n4, n5 and pick the value most nearly to the end and count the remaining rows to the end.
Thanks ;)
Assuming your unnamed columns are named as follows:
c1 c2 c3 c4 c5 c6 c7 c8
18853 1945-01-05 BA 87 34 1 59 50
18854 1945-01-13 BA 6 66 1 16 48
18855 1945-01-20 BA 38 14 24 78 36
18856 1945-01-27 BA 49 30 87 15 65
18857 1945-02-03 BA 30 64 36 5 32
18858 1945-02-10 BA 15 36 37 86 31
18859 1945-02-17 BA 86 78 69 7 60
18860 1945-02-24 BA 83 7 72 88 19
18861 1945-03-03 BA 47 20 77 73 30
Furthermore assuming c1 is you PK index column and column c7 is the one you're interested in, following might give you what you want:
select t1.c7, MAX(t1.c1), (select count(*)
from table t2
where MAX(t1.c1) < t2.c1) as rowsToEnd
from table t1
group by t1.c7
Ok, after having supposedly understood what you want, the following should give you what you want:
EDIT: After having read Imre L's answer i realized i totally forgot about the IN operator, so this is the more elegant solution:
EDIT AGAIN: After having read your question update.
This is assuming that one of c4, c5, c6, c7, c8 contains all numbers that are occur in any one of those rows:
select distinct t3.c4, ( select count(*) AS RowsToEnd
from table t1
where t1.c1 > ( select max(t2.c1)
from table t2
where t3.c4 IN
(t2.c4, t2.c5, t2.c6, t2.c7, t2.c8)
)
from table t3
assuming the columns of numbers are names n1..n6
using 16 as the example number
select count(1)
from tablename
where date > (select date
from tablename
where 16 in (n1,n2,n3,n4,n5,n6)
order by date desc
limit 1)
what about reoccuring dates?