distance-matrix

How to produce a variable size distance matrix in keras?

旧时模样 提交于 2021-01-29 14:13:11
问题 What I am trying to achieve now is to create a custom loss function in Keras that takes in two tensors (y_true, y_pred) with shapes (None, None, None) and (None, None, 3) , respectively. However, the None 's are so, that the two shapes are always equal for every (y_true, y_pred) . From these tensors I want to produce two distance matrices that contain the squared distances between every possible point pair (the third, length 3 dimension contains x, y, and z spatial values) inside them and

Computing the distance matrix from an adjacency matrix in python

≯℡__Kan透↙ 提交于 2021-01-29 07:58:30
问题 Write a code that produces the distance matrix from a graph (graph theory), the code should use the adjacency matrix and cannot use any functions from NetworkX module, apart from networkx.adjacency_matrix(). I understand the process of how the distance matrix works. My theory of how the adjacency matrix is involved is that it takes an element that connects two nodes and adds the distance up. For example, lets say i have nodes A, B and C. A is connected to B, and B is connected to C. The

Create an Array of vectors in C++

安稳与你 提交于 2021-01-29 05:37:49
问题 I want to create a distance matrix of a big dataset, and only want to store the 'close' enough elements. The code reads like this vector<double> * D; D = (vector<double> *) malloc(dim *sizeof(vector<double>) ) ; for(i=0;i<dim;i++){ for(j=i+1;j<dim;j++){ dx = s[j][0] - s[i][0]; dy = s[j][1] - s[i][1]; d = sqrt( dx*dx + dy*dy ); if(d < MAX_DISTANCE){ D[i].push_back(d); D[j].push_back(d); } } which gives me segmentation fault. I guess I have not defined the array of vector correctly. How do I

Distance matrix for custom distance

…衆ロ難τιáo~ 提交于 2020-01-28 11:27:31
问题 From what I understand, the scipy function scipy.spatial.distance_matrix returns the Minkowski distance for any pair of vectors from the provided matrices of vectors. Is there a way to get the same result for a different distance? Something that would look like distance_matrix(X, Y, distance_function) ? I assume that scipy does some sort of optimization under the hood. Since I am dealing with very large vectors, I would rather not lose the benefit of these optimizations by implementing my own

Distance matrix for custom distance

守給你的承諾、 提交于 2020-01-28 11:27:12
问题 From what I understand, the scipy function scipy.spatial.distance_matrix returns the Minkowski distance for any pair of vectors from the provided matrices of vectors. Is there a way to get the same result for a different distance? Something that would look like distance_matrix(X, Y, distance_function) ? I assume that scipy does some sort of optimization under the hood. Since I am dealing with very large vectors, I would rather not lose the benefit of these optimizations by implementing my own

how to get coordiantes in response instead of origin & destination addresses in Google Map Distance Matrix API

强颜欢笑 提交于 2019-12-13 07:59:38
问题 I'm using google distance matrix api in my android application. I'm calling Google distance matrix api by sending origin and destination to API. API returns response as: { "destination_addresses" : [ "Islamabad, Islamabad Capital Territory, Pakistan" ], "origin_addresses" : [ "Lahore, Punjab, Pakistan" ], "rows" : [ { "elements" : [ { "distance" : { "text" : "234 mi", "value" : 376505 }, "duration" : { "text" : "4 hours 20 mins", "value" : 15608 }, "status" : "OK" } ] } ], "status" : "OK" } I

Unable to build a bicycle route in Google maps

一个人想着一个人 提交于 2019-12-12 04:25:51
问题 i am wonder ! when i using origin1 and destinationA not working status = "ZERO_RESULTS"; but if used origin2 and destinationB it is working perfectly do i missed anything var origin = "55.930385, -3.118425" var destination = "50.087692, 14.421150" override func viewDidLoad() { super.viewDidLoad() durationDestance(origin: origin, destination: destination, mode:"bicycling") } func durationDestance(origin: String, destination: String, mode:String) { var urlString : String = "https://maps

R Interclass distance matrix

谁说胖子不能爱 提交于 2019-12-10 11:21:03
问题 This question is sort of a follow-up to how to extract intragroup and intergroup distances from a distance matrix? in R. In that question, they first computed the distance matrix for all points, and then simply extracted the inter-class distance matrix. I have a situation where I'd like to bypass the initial computation and skip right to extraction, i.e. I want to directly compute the inter-class distance matrix. Drawing from the linked example, with tweaks, let's say I have some data in a

Optimizing execution of a CUDA kernel for Triangular Matrix calculation

不问归期 提交于 2019-12-09 06:13:21
问题 I am developing my first Cuda application, and I have a kernel with "below-expected throughput", which seems to be the biggest bottleneck at the moment. The task of the kernel is to compute an N by N sized matrix ( DD ) containing squared distances between all elements on a data matrix. The data matrix ( Y ) is size N by D (to support multi dimensional data) and stored as row-major. Source: __global__ void computeSquaredEuclideanDistance(const float * __restrict__ Y, float * __restrict__ DD,

Visualizing data on geographic map with networks (R)

被刻印的时光 ゝ 提交于 2019-12-08 12:28:46
问题 I am trying to depict a network on the geographic map using data contained in a cultural distance matrix. E.g.: AT BE CH CZ AT 0 0.00276 0.148 0.109 BE 0.00276 0 0.145 0.112 CH 0.148 0.145 0 0.257 CZ 0.109 0.112 0.257 0 Starting and ending points of the network’s lines should be located in different countries (i.e. here AT, BE, CH and CZ). Lines should be depicted between countries when a corresponding entry of the matrix is below a certain threshold (e.g., the mean of all matrix’ entries).