deep-compute / diskarray Goto Github PK
View Code? Open in Web Editor NEWA resizable numpy array on disk (mmap based)
License: MIT License
A resizable numpy array on disk (mmap based)
License: MIT License
def close(self):
del self.data
self.data = None
I am using version 0.1.4.
The value of the appended numbers change -
>>> float_d = DiskArray('/tmp/float.diskarray', shape=(0,), dtype=[('floats', np.float32, 1)])
>>> float_d.append((0.1,))
>>> float_d.append((0.2,))
>>> float_d.append((0.3,))
>>> float_d.append((0.4,))
>>> float_d.append((0.5,))
>>> float_d['floats']
memmap([ 0.1 , 0.2 , 0.30000001, ..., 0. ,
0. , 0. ], dtype=float32)
>>> float_d['floats'][0]
0.1
>>> float_d['floats'][2]
0.30000001
>>> float_d['floats'][3]
0.40000001
>>> float_d['floats'][4]
0.5
>>> z = D('/tmp/float.diskarray', shape=(0,), dtype=[('floats', np.float32, 1)])
>>> z.append((0.87686,))
>>> z[:][0]
( 0.87686002,)
>>>
>>>
>>> z.append((0.87684556,))
>>> z[:][1]
( 0.87684554,)
>>> list_d = D('/tmp/float_list.diskarray', shape=(0,), dtype=[('floats', np.float32, 5)])
>>> list_d.append(([0.234324, -0.898767, 0.12213, 0.465477, 0.1]))
>>> list_d[:][0]
([ 0.23432399, -0.89876699, 0.12213 , 0.46547699, 0.1 ],)
While dealing with wvspace file vectors this happens
>>> vec_d = D('/tmp/vec.diskarray', shape=(0,), dtype=[('vec', np.float32, 300)])
>>> vec_d.append((wv.get_word_vector('the')))
>>> vec_d['vec']
memmap([[-0.0708, -0.1261, -0.0024, ..., 0.3283, -0.1717, -0.0638],
[ 0. , 0. , 0. , ..., 0. , 0. , 0. ],
[ 0. , 0. , 0. , ..., 0. , 0. , 0. ],
...,
[ 0. , 0. , 0. , ..., 0. , 0. , 0. ],
[ 0. , 0. , 0. , ..., 0. , 0. , 0. ],
[ 0. , 0. , 0. , ..., 0. , 0. , 0. ]], dtype=float32)
>>> vec_d['vec'][0]
memmap([-0.0708, -0.1261, -0.0024, 0.071 , -0.244 , 0.4421, 0.0462,
0.3307, -0.2153, -0.3359, 0.33 , 0.1035, 0.173 , -0.026 ,
0.2973, -0.1994, 0.0365, -0.0269, -0.1076, -0.269 , 0.0057,
0.0448, -0.0338, -0.1212, 0.2337, 0.0181, 0.178 , -0.0441,
-0.1288, -0.5501, -0.0296, -0.4436, 0.3562, -0.085 , 0.0061,
-0.4216, -0.167 , -0.2316, 0.2465, -0.576 , -0.2651, 0.1639,
0.1773, -0.1638, -0.0192, 0.2562, 0.1118, 0.2438, -0.3158,
-0.1226, -0.0164, 0.1403, 0.2215, -0.079 , -0.5859, -0.133 ,
0.0374, -0.0172, 0.2372, -0.0897, -0.3149, -0.2292, 0.0373,
0.1108, -0.0798, 0.2603, -0.2713, -0.287 , 0.0302, -0.1888,
0.6536, -0.4905, 0.2123, -0.3576, -0.0011, -0.2266, 0.1184,
0.3063, -0.2623, -0.0794, 0.2039, 0.2903, -0.292 , -0.1514,
-0.0664, -0.0811, -0.2342, -0.0881, 0.153 , 0.0052, 0.0293,
0.3174, 0.0053, -0.3784, 0.1975, -0.2095, -0.1435, 0.1823,
-0.151 , 0.1768, -0.0346, -0.0776, 0.1035, -0.083 , 0.1746,
0.0941, -0.0066, 0.2882, 0.0505, 0.0989, -0.0578, 0.2479,
0.043 , 0.2448, 0.0516, 0.2548, 0.1639, 0.0132, 0.0273,
-0.3195, 0.1441, 0.0072, -0.2061, 0.0982, -0.0936, -0.2313,
0.2072, -0.0253, 0.0126, -0.0423, 0.2766, 0.0332, 0.0633,
-0.1975, -0.0643, 0.0887, -0.1165, 0.0899, -0.2726, -0.4402,
-0.1391, 0.1087, 0.0317, -0.0621, 0.2462, -0.1575, -0.3078,
-0.2344, -0.0769, -0.043 , -0.0089, 0.0353, 0.1602, -0.041 ,
-0.2797, 0.2453, 0.0144, -0.0767, -0.2859, -0.0195, -0.1154,
0.0503, 0.0656, -0.0075, -0.3465, -0.1241, -0.302 , 0.1875,
0.279 , 0.0758, -0.1974, 0.223 , -0.3469, 0.0192, 0.1762,
0.0787, 0.2191, -0.1073, 0.2317, 0.3902, -0.3307, -0.079 ,
0.1755, -0.1113, 0.1689, 0.166 , -0.1134, 0.0815, 0.1436,
-0.0286, -0.1198, -0.1074, -0.0272, 0.2614, -0.251 , 0.0039,
0.0329, 0.2288, 0.2932, 0.5009, -0.0998, 0.1664, 0.084 ,
0.1192, -0.432 , -0.3663, 0.2071, 0.795 , -0.1185, -0.2545,
-0.1827, -0.1033, -0.3473, -0.149 , -0.0287, -0.1032, -0.0202,
0.3946, 0.1252, 0.0658, -0.0617, -0.4052, 0.0417, 0.1702,
0.0718, 0.2493, -0.2788, 0.2397, 0.1541, -0.0553, 0.1348,
0.4107, -0.0179, 0.0422, -0.1157, 0.0066, 0.2859, 0.0109,
0.0334, -0.3072, -0.0232, -0.3964, -0.0321, -0.5027, -0.1077,
0.094 , -0.0616, 0.1182, 0.024 , 0.3452, 0.3762, -0.0421,
0.1445, 0.0904, -0.6647, 0.3608, -0.0042, -0.0711, 0.1041,
-0.445 , 0.1815, 0.3388, -0.135 , 0.1139, -0.0077, 0.2227,
-0.1813, -0.068 , -0.1217, -0.0918, -0.0526, 0.1311, -0.0199,
-0.1598, -0.1521, -0.0995, 0.0921, 0.1171, -0.1107, 0.3541,
-0.2168, 0.2845, -0.2572, 0.4754, -0.0839, 0.286 , 0.5393,
-0.1501, 0.2447, 0.3126, 0.345 , 0.2083, 0.0781, 0.2214,
0.0664, -0.0724, -0.0039, 0.3283, -0.1717, -0.0638], dtype=float32)
>>> wv.get_word_vector('the')
array([-0.0708, -0.1261, -0.0024, 0.071 , -0.244 , 0.4421, 0.0462,
0.3307, -0.2153, -0.3359, 0.33 , 0.1035, 0.173 , -0.026 ,
0.2973, -0.1994, 0.0365, -0.0269, -0.1076, -0.269 , 0.0057,
0.0448, -0.0338, -0.1212, 0.2337, 0.0181, 0.178 , -0.0441,
-0.1288, -0.5501, -0.0296, -0.4436, 0.3562, -0.085 , 0.0061,
-0.4216, -0.167 , -0.2316, 0.2465, -0.576 , -0.2651, 0.1639,
0.1773, -0.1638, -0.0192, 0.2562, 0.1118, 0.2438, -0.3158,
-0.1226, -0.0164, 0.1403, 0.2215, -0.079 , -0.5859, -0.133 ,
0.0374, -0.0172, 0.2372, -0.0897, -0.3149, -0.2292, 0.0373,
0.1108, -0.0798, 0.2603, -0.2713, -0.287 , 0.0302, -0.1888,
0.6536, -0.4905, 0.2123, -0.3576, -0.0011, -0.2266, 0.1184,
0.3063, -0.2623, -0.0794, 0.2039, 0.2903, -0.292 , -0.1514,
-0.0664, -0.0811, -0.2342, -0.0881, 0.153 , 0.0052, 0.0293,
0.3174, 0.0053, -0.3784, 0.1975, -0.2095, -0.1435, 0.1823,
-0.151 , 0.1768, -0.0346, -0.0776, 0.1035, -0.083 , 0.1746,
0.0941, -0.0066, 0.2882, 0.0505, 0.0989, -0.0578, 0.2479,
0.043 , 0.2448, 0.0516, 0.2548, 0.1639, 0.0132, 0.0273,
-0.3195, 0.1441, 0.0072, -0.2061, 0.0982, -0.0936, -0.2313,
0.2072, -0.0253, 0.0126, -0.0423, 0.2766, 0.0332, 0.0633,
-0.1975, -0.0643, 0.0887, -0.1165, 0.0899, -0.2726, -0.4402,
-0.1391, 0.1087, 0.0317, -0.0621, 0.2462, -0.1575, -0.3078,
-0.2344, -0.0769, -0.043 , -0.0089, 0.0353, 0.1602, -0.041 ,
-0.2797, 0.2453, 0.0144, -0.0767, -0.2859, -0.0195, -0.1154,
0.0503, 0.0656, -0.0075, -0.3465, -0.1241, -0.302 , 0.1875,
0.279 , 0.0758, -0.1974, 0.223 , -0.3469, 0.0192, 0.1762,
0.0787, 0.2191, -0.1073, 0.2317, 0.3902, -0.3307, -0.079 ,
0.1755, -0.1113, 0.1689, 0.166 , -0.1134, 0.0815, 0.1436,
-0.0286, -0.1198, -0.1074, -0.0272, 0.2614, -0.251 , 0.0039,
0.0329, 0.2288, 0.2932, 0.5009, -0.0998, 0.1664, 0.084 ,
0.1192, -0.432 , -0.3663, 0.2071, 0.795 , -0.1185, -0.2545,
-0.1827, -0.1033, -0.3473, -0.149 , -0.0287, -0.1032, -0.0202,
0.3946, 0.1252, 0.0658, -0.0617, -0.4052, 0.0417, 0.1702,
0.0718, 0.2493, -0.2788, 0.2397, 0.1541, -0.0553, 0.1348,
0.4107, -0.0179, 0.0422, -0.1157, 0.0066, 0.2859, 0.0109,
0.0334, -0.3072, -0.0232, -0.3964, -0.0321, -0.5027, -0.1077,
0.094 , -0.0616, 0.1182, 0.024 , 0.3452, 0.3762, -0.0421,
0.1445, 0.0904, -0.6647, 0.3608, -0.0042, -0.0711, 0.1041,
-0.445 , 0.1815, 0.3388, -0.135 , 0.1139, -0.0077, 0.2227,
-0.1813, -0.068 , -0.1217, -0.0918, -0.0526, 0.1311, -0.0199,
-0.1598, -0.1521, -0.0995, 0.0921, 0.1171, -0.1107, 0.3541,
-0.2168, 0.2845, -0.2572, 0.4754, -0.0839, 0.286 , 0.5393,
-0.1501, 0.2447, 0.3126, 0.345 , 0.2083, 0.0781, 0.2214,
0.0664, -0.0724, -0.0039, 0.3283, -0.1717, -0.0638], dtype=float32)
>>> vec_d['vec'][0][0]
>>> vec_d['vec'][0][0]
-0.070754707
>>> wv.get_word_vector('the')[0]
-0.070754707
The values in the memmap and array remain the same, but on accessing the individual values see how it varies, what is the reason for this.
This been tested on dev0.servers.deepcompute.com and [email protected]
@prashanthellina Is this actually as change in information. Also, I believe this is harmful for NN training.
diskarray.take:
If we want to take the data from diskarray then we need to specify diskarray[:].take. Instead of this it would be better to support take.
The same with diskarray.data like if I want the data instead of specifying diskarray[:] support diskarray.data.
In 89 line of README
>>> da = DiskArray('/tmp/disk.array', shape=(0, 3), capacity=(10, 3), dtype=np.float32)
it should be dtype=dtype. It is wrongly mentioned as np.float32.
If anyone gives commit please fix this.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.