cwise_ops_cplx_test.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:complex_tf 作者: woodshop 项目源码 文件源码
def testCplxNotEqualGPU(self):
        shapes1 = [(5,4,3), (5,4), (1,), (5,)]
        shapes2 = [(5,4,3), (1,), (5,4), (5,)]
        for [sh0, sh1] in zip(shapes1, shapes2):
            x = (np.random.randn(np.prod(sh0)) +
                 1j*np.random.randn(np.prod(sh0))).astype(np.complex64)
            y = (np.random.randn(np.prod(sh1)) +
                 1j*np.random.randn(np.prod(sh1))).astype(np.complex64)
            if len(sh0) == 1:
                ix = np.random.permutation(
                    np.arange(np.prod(sh1)))[:np.prod(sh1)//2]
                y[ix] = x[0]
            elif len(sh1) == 1:
                ix = np.random.permutation(
                    np.arange(np.prod(sh0)))[:np.prod(sh0)//2]
                x[ix] = y[0]
            else:
                ix = np.random.permutation(
                    np.arange(np.prod(sh0)))[:np.prod(sh0)//2]
                x[ix] = y[ix]
            x = np.reshape(x, sh0)
            y = np.reshape(y, sh1)
            self._compareGpu(x, y, np.not_equal, tf.not_equal)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号