Python numpy 模块,cbrt() 实例源码

我们从Python开源项目中,提取了以下18个代码示例,用于说明如何使用numpy.cbrt()

项目:npstreams    作者:LaurentRDC    | 项目源码 | 文件源码
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)))
项目:npstreams    作者:LaurentRDC    | 项目源码 | 文件源码
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)))
项目:radar    作者:amoose136    | 项目源码 | 文件源码
def test_cbrt_scalar(self):
        assert_almost_equal((np.cbrt(np.float32(-2.5)**3)), -2.5)
项目:radar    作者:amoose136    | 项目源码 | 文件源码
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)
项目:learning-tf    作者:unixpickle    | 项目源码 | 文件源码
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
项目:krpcScripts    作者:jwvanderbeck    | 项目源码 | 文件源码
def test_cbrt_scalar(self):
        assert_almost_equal((np.cbrt(np.float32(-2.5)**3)), -2.5)
项目:krpcScripts    作者:jwvanderbeck    | 项目源码 | 文件源码
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)
项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda    作者:SignalMedia    | 项目源码 | 文件源码
def test_cbrt_scalar(self):
        assert_almost_equal((np.cbrt(np.float32(-2.5)**3)), -2.5)
项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda    作者:SignalMedia    | 项目源码 | 文件源码
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)
项目:aws-lambda-numpy    作者:vitolimandibhrata    | 项目源码 | 文件源码
def test_cbrt_scalar(self):
        assert_almost_equal((np.cbrt(np.float32(-2.5)**3)), -2.5)
项目:aws-lambda-numpy    作者:vitolimandibhrata    | 项目源码 | 文件源码
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)
项目:lambda-numba    作者:rlhotovy    | 项目源码 | 文件源码
def test_cbrt_scalar(self):
        assert_almost_equal((np.cbrt(np.float32(-2.5)**3)), -2.5)
项目:lambda-numba    作者:rlhotovy    | 项目源码 | 文件源码
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)
项目:deliver    作者:orchestor    | 项目源码 | 文件源码
def test_cbrt_scalar(self):
        assert_almost_equal((np.cbrt(np.float32(-2.5)**3)), -2.5)
项目:deliver    作者:orchestor    | 项目源码 | 文件源码
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)
项目:Alfred    作者:jkachhadia    | 项目源码 | 文件源码
def test_cbrt_scalar(self):
        assert_almost_equal((np.cbrt(np.float32(-2.5)**3)), -2.5)
项目:Alfred    作者:jkachhadia    | 项目源码 | 文件源码
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)
项目:Y8M    作者:mpekalski    | 项目源码 | 文件源码
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

#%%