![]() Keep in mind as you see above Cosine Similarity Value came up above 1.0 but when we use the map function and use do the int casting we get the following value which is the correct value: V2fColor = np.array(map(int,value2.split(','))) Not lets un commented two lines that and run the code with the David's Initial Solution: v1fColor = np.array(map(int,value1.split(','))) If you run this code you should get the following output: V2fColor = np.array( value2.split(','), dtype=np.uint8 ) ![]() V1fColor = np.array( value1.split(','), dtype=np.uint8 ) So I wrote a simple sample code to try out: import numpy as np I am writing this answer so if for any future references: I am not sure what is the correct solution in this case but I think What Robinson initially publish was the correct answer due to one reason: Cosine Similarity values can not be greater than one and when I use NP.array(v1fColor.split(","), dtype=NP.uint8) option I get strage values which are above 1.0 for cosine similarity between two vectors. So I tried the following to convert this string as a numpy array: v1fColor = NP.array(, dtype=NP.uint8)īut I ended up getting following error: v1fColor = NP.array(, dtype=NP.uint8) Here is my lambda function import numpy as NPĬx = lambda a, b : round(NP.inner(a, b)/(LA.norm(a)*LA.norm(b)), 3) I have the following lambda function to calculate cosine similarity of two images, So I tried to convert this is to numpy.array but I failed: I am treating it as a vector: Long story short its a forecolor of an image histogram: ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |