The following are code examples for showing how to use . They are extracted from open source Python projects. You can vote up the examples you like or vote down the exmaples you don’t like. You can also save this page to your account.
Example 1
def test_order(self): """ Test that ipipe(f, g, h, arrays) -> f(g(h(arr))) for arr in arrays """ stream = [np.random.random((15,7,2,1)) for _ in range(10)] squared = [np.cbrt(np.square(arr)) for arr in stream] pipeline = ipipe(np.cbrt, np.square, stream) self.assertTrue(all(np.allclose(s, p) for s, p in zip(pipeline, squared)))
Example 2
def test_multiprocessing(self): """ Test that ipipe(f, g, h, arrays) -> f(g(h(arr))) for arr in arrays """ stream = [np.random.random((15,7,2,1)) for _ in range(10)] squared = [np.cbrt(np.square(arr)) for arr in stream] pipeline = ipipe(np.cbrt, np.square, stream, processes = 2) self.assertTrue(all(np.allclose(s, p) for s, p in zip(pipeline, squared)))
Example 3
def test_cbrt_scalar(self): assert_almost_equal((np.cbrt(np.float32(-2.5)**3)), -2.5)
Example 4
def test_cbrt(self): x = np.array([1., 2., -3., np.inf, -np.inf]) assert_almost_equal(np.cbrt(x**3), x) assert_(np.isnan(np.cbrt(np.nan))) assert_equal(np.cbrt(np.inf), np.inf) assert_equal(np.cbrt(-np.inf), -np.inf)
Example 5
def make_data(num): """ Make data allocates num samples with input dimension 3 and output dimension of 1. """ inputs = np.random.normal(size=[3, num]) targets = np.cbrt(np.square(2.5*inputs[0:1, :]) - inputs[1:2, :] * inputs[2:3, :]) return inputs, targets
Example 6
def test_cbrt_scalar(self): assert_almost_equal((np.cbrt(np.float32(-2.5)**3)), -2.5)
Example 7
def test_cbrt(self): x = np.array([1., 2., -3., np.inf, -np.inf]) assert_almost_equal(np.cbrt(x**3), x) assert_(np.isnan(np.cbrt(np.nan))) assert_equal(np.cbrt(np.inf), np.inf) assert_equal(np.cbrt(-np.inf), -np.inf)
Example 8
def test_cbrt_scalar(self): assert_almost_equal((np.cbrt(np.float32(-2.5)**3)), -2.5)
Example 9
def test_cbrt(self): x = np.array([1., 2., -3., np.inf, -np.inf]) assert_almost_equal(np.cbrt(x**3), x) assert_(np.isnan(np.cbrt(np.nan))) assert_equal(np.cbrt(np.inf), np.inf) assert_equal(np.cbrt(-np.inf), -np.inf)
Example 10
def test_cbrt_scalar(self): assert_almost_equal((np.cbrt(np.float32(-2.5)**3)), -2.5)
Example 11
def test_cbrt(self): x = np.array([1., 2., -3., np.inf, -np.inf]) assert_almost_equal(np.cbrt(x**3), x) assert_(np.isnan(np.cbrt(np.nan))) assert_equal(np.cbrt(np.inf), np.inf) assert_equal(np.cbrt(-np.inf), -np.inf)
Example 12
def test_cbrt_scalar(self): assert_almost_equal((np.cbrt(np.float32(-2.5)**3)), -2.5)
Example 13
def test_cbrt(self): x = np.array([1., 2., -3., np.inf, -np.inf]) assert_almost_equal(np.cbrt(x**3), x) assert_(np.isnan(np.cbrt(np.nan))) assert_equal(np.cbrt(np.inf), np.inf) assert_equal(np.cbrt(-np.inf), -np.inf)
Example 14
def test_cbrt_scalar(self): assert_almost_equal((np.cbrt(np.float32(-2.5)**3)), -2.5)
Example 15
def test_cbrt(self): x = np.array([1., 2., -3., np.inf, -np.inf]) assert_almost_equal(np.cbrt(x**3), x) assert_(np.isnan(np.cbrt(np.nan))) assert_equal(np.cbrt(np.inf), np.inf) assert_equal(np.cbrt(-np.inf), -np.inf)
Example 16
def test_cbrt_scalar(self): assert_almost_equal((np.cbrt(np.float32(-2.5)**3)), -2.5)
Example 17
def test_cbrt(self): x = np.array([1., 2., -3., np.inf, -np.inf]) assert_almost_equal(np.cbrt(x**3), x) assert_(np.isnan(np.cbrt(np.nan))) assert_equal(np.cbrt(np.inf), np.inf) assert_equal(np.cbrt(-np.inf), -np.inf)
Example 18
def np_2_vExample(vid, labs, rgb, audio): nframes = audio.shape[0] if False: # top 5 k = 5 if nframes > 10: tk_rgb = my_utils.top_k_along_column(rgb, k) tk_audio = my_utils.top_k_along_column(audio, k) else: tk_rgb = np.repeat(rgb[0].reshape([1, rgb.shape[1]]), k, axis=0) tk_audio = np.repeat(audio[0].reshape([1, audio.shape[1]]), k, axis=0) # std of all rgb or audio entries s_rgb = np.std(rgb) s_aud = np.std(audio) rgb_sq = rgb * rgb aud_sq = audio * audio vExample = tf.train.Example(features=tf.train.Features(feature={ 'video_id': my_utils._byteslist_feature([vid]), 'labels': my_utils._int64list_feature(labs), 'mean_rgb': my_utils._floatlist_feature(np.mean(rgb, axis=0)), 'mean_audio': my_utils._floatlist_feature(np.mean(audio, axis=0)), 'std_rgb': my_utils._floatlist_feature(np.std(rgb, axis=0)), 'std_audio': my_utils._floatlist_feature(np.std(audio, axis=0)), 'x3_rgb': my_utils._floatlist_feature(np.cbrt(np.mean(rgb_sq * rgb, axis=0))), 'x3_audio': my_utils._floatlist_feature(np.cbrt(np.mean(aud_sq * audio, axis=0))), 'num_frames': my_utils._floatlist_feature([(nframes-151.)/300.]), 'std_all_rgb': my_utils._floatlist_feature([s_rgb]), 'std_all_audio': my_utils._floatlist_feature([s_aud]) })) #'top_1_rgb': my_utils._floatlist_feature(tk_rgb[-1]), #'top_3_rgb': my_utils._floatlist_feature(tk_rgb[-3]), #'top_5_rgb': my_utils._floatlist_feature(tk_rgb[-5]), #'top_1_audio': my_utils._floatlist_feature(tk_audio[-1]), #'top_3_audio': my_utils._floatlist_feature(tk_audio[-3]), #'top_5_audio': my_utils._floatlist_feature(tk_audio[-5]), return vExample #%%