Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Multi-Layer Neural Networks
#python 3.5.2 def HammingDistance(a,b,n): p = 0 i = 1 while i<=n : if (((a&1)^(b&1))==1) : p = p + 1 a = a>>1 b = b>>1 i = i+1 return p def GetHyperCube(ds,n,n2): nmc = 0 mask = 0 h = [] x = [] y = [] z = 0 while z<=256 : h.append([0]) x.append([0]) y.append([0]) z = z+1 z = 0 while z<=256 : h[z] = -1 x[z] = -1 y[z] = -1 z = z + 1 max = n2 st = ds i = 0 while i<max : p = 0 j = 0 while j<n : if (st[((i+j) % max)]=='1') : p = p | 1 p = p << 1 j = j + 1 x[i] = p >> 1 i = i+1 t = 0 p = 0 f = 0 h[0] = x[0] y[x[0]] = 1 while f==0 : z = t j = 0 while j<max : if (y[x[j]]==-1) : p = x[j] q = 0 i = 0 if t>=(n-1) : u = n-1 else : u = t+1 while i<u : if (HammingDistance(p,h[(t-i)],n)==(i+1)) : q = q+1 i = i+1 if q==u : break if q==u : t = t+1 h[t] = x[j] y[x[j]] = 1 f = 0 break j = j+1 if t==z : break i = 0 while i<max : a = '' j = 0 while j<max : a = a + '+' if h[i]==x[j] : k = 0 while k<n : a = a + str((x[j]>>(n-k-1))&1) k = k+1 print(a) break j = j+1 i = i+1 return 0 GetHyperCube('00000101100011101111100100110101',5,32)
run
|
edit
|
history
|
help
0
function and doc string
PyWordQuant
Remove all Adjacent duplicates using a loop
Assignment-3c
Python: Functions I : Functions with messages.
5
vbcb
PyBatScoreAbs
StringManipulation
31 dec string