Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
added 14 characters in body
Source Link

I have an array of time of arrivals and I want to convert it to count data using pytorch in a differentiable way.

Example arrival times:

arrival_times = [2.1, 2.9, 5.1]

and let's say the total range is 6 seconds. What I want to have is:

counts = [0, 0, 2, 2, 2, 3]

For this task, a non-differentiable way works perfect:

x = [1, 2, 3, 4,5,6] counts = torch.sum(arrival_times[torch.Tensor(arrival_times)[:, None] < torch.Tensor(x), dim=0) 

It turns out the < operation here is not differentiable. I need a differentiable approximation of this operation.

What I could think of is to subtract the x from arrival_times with broadcasting which leads the following array.

[ [1.1, 0.1, -0.9, -1.9, -2.9, -3.9] [1.9, 0.9, -0.1, -1.1, -2.1, -3.1] [4.1, 3.1, 2.1, 1.1, 0.1, -0.9] ] 

And then somehow count the number of negative (and also zero preferably) elements vertically which will give us the counts [0, 0, 2, 2, 2, 3].

Is there a way to do this or completely new idea for such approximation?

I have an array of time of arrivals and I want to convert it to count data using pytorch in a differentiable way.

Example arrival times:

arrival_times = [2.1, 2.9, 5.1]

and let's say the total range is 6 seconds. What I want to have is:

counts = [0, 0, 2, 2, 2, 3]

For this task, a non-differentiable way works perfect:

x = [1, 2, 3, 4,5,6] counts = torch.sum(arrival_times[:, None] < torch.Tensor(x), dim=0) 

It turns out the < operation here is not differentiable. I need a differentiable approximation of this operation.

What I could think of is to subtract the x from arrival_times with broadcasting which leads the following array.

[ [1.1, 0.1, -0.9, -1.9, -2.9, -3.9] [1.9, 0.9, -0.1, -1.1, -2.1, -3.1] [4.1, 3.1, 2.1, 1.1, 0.1, -0.9] ] 

And then somehow count the number of negative (and also zero preferably) elements vertically which will give us the counts [0, 0, 2, 2, 2, 3].

Is there a way to do this or completely new idea for such approximation?

I have an array of time of arrivals and I want to convert it to count data using pytorch in a differentiable way.

Example arrival times:

arrival_times = [2.1, 2.9, 5.1]

and let's say the total range is 6 seconds. What I want to have is:

counts = [0, 0, 2, 2, 2, 3]

For this task, a non-differentiable way works perfect:

x = [1, 2, 3, 4,5,6] counts = torch.sum(torch.Tensor(arrival_times)[:, None] < torch.Tensor(x), dim=0) 

It turns out the < operation here is not differentiable. I need a differentiable approximation of this operation.

What I could think of is to subtract the x from arrival_times with broadcasting which leads the following array.

[ [1.1, 0.1, -0.9, -1.9, -2.9, -3.9] [1.9, 0.9, -0.1, -1.1, -2.1, -3.1] [4.1, 3.1, 2.1, 1.1, 0.1, -0.9] ] 

And then somehow count the number of negative (and also zero preferably) elements vertically which will give us the counts [0, 0, 2, 2, 2, 3].

Is there a way to do this or completely new idea for such approximation?

edited body
Source Link

I have an array of time of arrivals and I want to convert it to count data using pytorch in a differentiable way.

Example arrival times:

arrival_times = [2.1, 2.9, 5.1]

and let's say the total range is 6 seconds. What I want to have is:

counts = [0, 0, 2, 2, 2, 3]

For this task, a non-differentiable way works perfect:

x = [1, 2, 3, 4,5,6] counts = torch.sum(arrival_times[:, None] < torch.Tensor(x), dim=1dim=0) 

It turns out the < operation here is not differentiable. I need a differentiable approximation of this operation.

What I could think of is to subtract the x from arrival_times with broadcasting which leads the following array.

[ [1.1, 0.1, -0.9, -1.9, -2.9, -3.9] [1.9, 0.9, -0.1, -1.1, -2.1, -3.1] [4.1, 3.1, 2.1, 1.1, 0.1, -0.9] ] 

And then somehow count the number of negative (and also zero preferably) elements vertically which will give us the counts [0, 0, 2, 2, 2, 3].

Is there a way to do this or completely new idea for such approximation?

I have an array of time of arrivals and I want to convert it to count data using pytorch in a differentiable way.

Example arrival times:

arrival_times = [2.1, 2.9, 5.1]

and let's say the total range is 6 seconds. What I want to have is:

counts = [0, 0, 2, 2, 2, 3]

For this task, a non-differentiable way works perfect:

x = [1, 2, 3, 4,5,6] counts = torch.sum(arrival_times[:, None] < torch.Tensor(x), dim=1) 

It turns out the < operation here is not differentiable. I need a differentiable approximation of this operation.

What I could think of is to subtract the x from arrival_times with broadcasting which leads the following array.

[ [1.1, 0.1, -0.9, -1.9, -2.9, -3.9] [1.9, 0.9, -0.1, -1.1, -2.1, -3.1] [4.1, 3.1, 2.1, 1.1, 0.1, -0.9] ] 

And then somehow count the number of negative (and also zero preferably) elements vertically which will give us the counts [0, 0, 2, 2, 2, 3].

Is there a way to do this or completely new idea for such approximation?

I have an array of time of arrivals and I want to convert it to count data using pytorch in a differentiable way.

Example arrival times:

arrival_times = [2.1, 2.9, 5.1]

and let's say the total range is 6 seconds. What I want to have is:

counts = [0, 0, 2, 2, 2, 3]

For this task, a non-differentiable way works perfect:

x = [1, 2, 3, 4,5,6] counts = torch.sum(arrival_times[:, None] < torch.Tensor(x), dim=0) 

It turns out the < operation here is not differentiable. I need a differentiable approximation of this operation.

What I could think of is to subtract the x from arrival_times with broadcasting which leads the following array.

[ [1.1, 0.1, -0.9, -1.9, -2.9, -3.9] [1.9, 0.9, -0.1, -1.1, -2.1, -3.1] [4.1, 3.1, 2.1, 1.1, 0.1, -0.9] ] 

And then somehow count the number of negative (and also zero preferably) elements vertically which will give us the counts [0, 0, 2, 2, 2, 3].

Is there a way to do this or completely new idea for such approximation?

Source Link

Differentiable approximation for counting negative values in array

I have an array of time of arrivals and I want to convert it to count data using pytorch in a differentiable way.

Example arrival times:

arrival_times = [2.1, 2.9, 5.1]

and let's say the total range is 6 seconds. What I want to have is:

counts = [0, 0, 2, 2, 2, 3]

For this task, a non-differentiable way works perfect:

x = [1, 2, 3, 4,5,6] counts = torch.sum(arrival_times[:, None] < torch.Tensor(x), dim=1) 

It turns out the < operation here is not differentiable. I need a differentiable approximation of this operation.

What I could think of is to subtract the x from arrival_times with broadcasting which leads the following array.

[ [1.1, 0.1, -0.9, -1.9, -2.9, -3.9] [1.9, 0.9, -0.1, -1.1, -2.1, -3.1] [4.1, 3.1, 2.1, 1.1, 0.1, -0.9] ] 

And then somehow count the number of negative (and also zero preferably) elements vertically which will give us the counts [0, 0, 2, 2, 2, 3].

Is there a way to do this or completely new idea for such approximation?