当前位置: 首页>>代码示例>>Python>>正文


Python tensorflow.conj方法代码示例

本文整理汇总了Python中tensorflow.conj方法的典型用法代码示例。如果您正苦于以下问题:Python tensorflow.conj方法的具体用法?Python tensorflow.conj怎么用?Python tensorflow.conj使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tensorflow的用法示例。


在下文中一共展示了tensorflow.conj方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _compareGradient

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import conj [as 别名]
def _compareGradient(self, x):
    # x[:, 0] is real, x[:, 1] is imag.  We combine real and imag into
    # complex numbers. Then, we extract real and imag parts and
    # computes the squared sum. This is obviously the same as sum(real
    # * real) + sum(imag * imag). We just want to make sure the
    # gradient function is checked.
    with self.test_session():
      inx = tf.convert_to_tensor(x)
      real, imag = tf.split(1, 2, inx)
      real, imag = tf.reshape(real, [-1]), tf.reshape(imag, [-1])
      cplx = tf.complex(real, imag)
      cplx = tf.conj(cplx)
      loss = tf.reduce_sum(
          tf.square(tf.real(cplx))) + tf.reduce_sum(
              tf.square(tf.imag(cplx)))
      epsilon = 1e-3
      jacob_t, jacob_n = tf.test.compute_gradient(inx,
                                                  list(x.shape),
                                                  loss,
                                                  [1],
                                                  x_init_value=x,
                                                  delta=epsilon)
    self.assertAllClose(jacob_t, jacob_n, rtol=epsilon, atol=epsilon) 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:25,代码来源:cwise_ops_test.py

示例2: _checkGrad

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import conj [as 别名]
def _checkGrad(self, func, x, y, use_gpu=False):
    with self.test_session(use_gpu=use_gpu):
      inx = tf.convert_to_tensor(x)
      iny = tf.convert_to_tensor(y)
      # func is a forward or inverse FFT function (batched or unbatched)
      z = func(tf.complex(inx, iny))
      # loss = sum(|z|^2)
      loss = tf.reduce_sum(tf.real(z * tf.conj(z)))
      ((x_jacob_t, x_jacob_n),
       (y_jacob_t, y_jacob_n)) = tf.test.compute_gradient(
           [inx, iny],
           [list(x.shape), list(y.shape)],
           loss,
           [1],
           x_init_value=[x, y],
           delta=1e-2)
    self.assertAllClose(x_jacob_t, x_jacob_n, rtol=1e-2, atol=1e-2)
    self.assertAllClose(y_jacob_t, y_jacob_n, rtol=1e-2, atol=1e-2) 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:20,代码来源:fft_ops_test.py

示例3: compute_log_mel_spectrograms

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import conj [as 别名]
def compute_log_mel_spectrograms(stfts, hparams):
    # power_spectrograms = tf.real(stfts * tf.conj(stfts))
    magnitude_spectrograms = tf.abs(stfts)

    num_spectrogram_bins = magnitude_spectrograms.shape[-1].value

    linear_to_mel_weight_matrix = signal.linear_to_mel_weight_matrix(
        hparams.num_mel_bins, num_spectrogram_bins, hparams.sample_rate, hparams.mel_lower_edge_hz,
        hparams.mel_upper_edge_hz)

    mel_spectrograms = tf.tensordot(
        magnitude_spectrograms, linear_to_mel_weight_matrix, 1)

    # Note: Shape inference for `tf.tensordot` does not currently handle this case.
    mel_spectrograms.set_shape(magnitude_spectrograms.shape[:-1].concatenate(
        linear_to_mel_weight_matrix.shape[-1:]))

    log_offset = 1e-6
    log_mel_spectrograms = tf.log(mel_spectrograms + log_offset)

    return log_mel_spectrograms 
开发者ID:georgesterpu,项目名称:avsr-tf1,代码行数:23,代码来源:audio.py

示例4: __init__

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import conj [as 别名]
def __init__(self,x_op,y_op,sess,remove_bias=False,name=None):
        # Save parameters
        self.x_op = x_op
        self.y_op = y_op
        self.sess = sess
        self.remove_bias = remove_bias

        # Get dimensions and data types
        shape0 = x_op.get_shape()
        shape1 = y_op.get_shape()
        dtype0 = x_op.dtype
        dtype1 = y_op.dtype
        BaseLinTrans.__init__(self, shape0, shape1, dtype0, dtype1,\
           svd_avail=False,name=name)

                
        # Create the ops for the gradient.  If the linear operator is y=F(x),
        # then z = y'*F(x).  Therefore, dz/dx = F'(y).
        self.ytr_op = tf.placeholder(self.dtype1,self.shape1)        
        self.z_op = tf.reduce_sum(tf.multiply(tf.conj(self.ytr_op),self.y_op))
        self.zgrad_op = tf.gradients(self.z_op,self.x_op)[0]
        
        # Compute output at zero to subtract 
        if self.remove_bias:
            xzero = np.zeros(self.shape0)
            self.y_bias = self.sess.run(self.y_op, feed_dict={self.x_op: xzero})
        else:
            self.y_bias = 0 
开发者ID:GAMPTeam,项目名称:vampyre,代码行数:30,代码来源:tflintrans.py

示例5: test_Conj

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import conj [as 别名]
def test_Conj(self):
        t = tf.conj(self.random(3, 4, complex=True))
        self.check(t) 
开发者ID:riga,项目名称:tfdeploy,代码行数:5,代码来源:ops.py

示例6: _matmul_right

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import conj [as 别名]
def _matmul_right(self, x, adjoint=False, adjoint_arg=False):
    diag_mat = tf.conj(self._diag) if adjoint else self._diag
    x = linalg.adjoint(x) if adjoint_arg else x
    return diag_mat * x 
开发者ID:tensorflow,项目名称:kfac,代码行数:6,代码来源:linear_operator.py

示例7: _matmul_sparse

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import conj [as 别名]
def _matmul_sparse(self, x, adjoint=False, adjoint_arg=False):
    diag_mat = tf.conj(self._diag) if adjoint else self._diag
    assert not adjoint_arg
    return utils.matmul_diag_sparse(diag_mat, x) 
开发者ID:tensorflow,项目名称:kfac,代码行数:6,代码来源:linear_operator.py

示例8: _compareConj

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import conj [as 别名]
def _compareConj(self, cplx, use_gpu):
    np_ans = np.conj(cplx)
    with self.test_session(use_gpu=use_gpu):
      inx = tf.convert_to_tensor(cplx)
      tf_conj = tf.conj(inx)
      tf_ans = tf_conj.eval()
    self.assertAllEqual(np_ans, tf_ans)
    self.assertShapeEqual(np_ans, tf_conj) 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:10,代码来源:cwise_ops_test.py

示例9: testConjReal

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import conj [as 别名]
def testConjReal(self):
    for dtype in tf.int32, tf.int64, tf.float16, tf.float32, tf.float64:
      x = tf.placeholder(dtype)
      y = tf.conj(x)
      self.assertEqual(x, y) 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:7,代码来源:cwise_ops_test.py

示例10: testConjString

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import conj [as 别名]
def testConjString(self):
    x = tf.placeholder(tf.string)
    with self.assertRaisesRegexp(TypeError, r"Expected numeric tensor"):
      tf.conj(x) 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:6,代码来源:cwise_ops_test.py

示例11: mriAdjointOpWithOS

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import conj [as 别名]
def mriAdjointOpWithOS(self, f, coil_sens, sampling_mask):
        with tf.variable_scope('mriAdjointOp'):
            # variables to remove frequency encoding oversampling
            pad_u = tf.cast(tf.multiply(tf.cast(tf.shape(sampling_mask)[1], tf.float32), 0.25) + 1, tf.int32)
            pad_l = tf.cast(tf.multiply(tf.cast(tf.shape(sampling_mask)[1], tf.float32), 0.25) - 1, tf.int32)
            # apply mask and perform inverse centered Fourier transform
            mask = tf.expand_dims(sampling_mask, axis=1)
            Finv = tf.contrib.icg.ifftc2d(tf.complex(tf.real(f) * mask, tf.imag(f) * mask))
            # multiply coil images with sensitivities and sum up over channels
            img = tf.reduce_sum(Finv * tf.conj(coil_sens), 1)[:, pad_u:-pad_l, :]
        return img 
开发者ID:VLOGroup,项目名称:mri-variationalnetwork,代码行数:13,代码来源:train_mri_vn.py

示例12: mriAdjointOp

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import conj [as 别名]
def mriAdjointOp(self, f, coil_sens, sampling_mask):
        with tf.variable_scope('mriAdjointOp'):
            # apply mask and perform inverse centered Fourier transform
            mask = tf.expand_dims(sampling_mask, axis=1)
            Finv = tf.contrib.icg.ifftc2d(tf.complex(tf.real(f) * mask, tf.imag(f) * mask))
            # multiply coil images with sensitivities and sum up over channels
            img = tf.reduce_sum(Finv * tf.conj(coil_sens), 1)
        return img 
开发者ID:VLOGroup,项目名称:mri-variationalnetwork,代码行数:10,代码来源:train_mri_vn.py

示例13: _ccorr

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import conj [as 别名]
def _ccorr(self, a, b):
		a = tf.cast(a, tf.complex64)
		b = tf.cast(b, tf.complex64)
		return tf.real(tf.ifft(tf.conj(tf.fft(a)) * tf.fft(b))) 
开发者ID:INK-USC,项目名称:KagNet,代码行数:6,代码来源:HolE.py

示例14: get_correlations

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import conj [as 别名]
def get_correlations(Y, inverse_power, taps, delay):
    """Calculates weighted correlations of a window of length taps

    Args:
        Y (tf.Ttensor): Complex-valued STFT signal with shape (F, D, T)
        inverse_power (tf.Tensor): Weighting factor with shape (F, T)
        taps (int): Lenghts of correlation window
        delay (int): Delay for the weighting factor

    Returns:
        tf.Tensor: Correlation matrix of shape (F, taps*D, taps*D)
        tf.Tensor: Correlation vector of shape (F, taps*D)
    """
    dyn_shape = tf.shape(Y)
    F = dyn_shape[0]
    D = dyn_shape[1]
    T = dyn_shape[2]

    Psi = tf_signal.frame(Y, taps, 1, axis=-1)[..., :T - delay - taps + 1, ::-1]
    Psi_conj_norm = (
        tf.cast(inverse_power[:, None, delay + taps - 1:, None], Psi.dtype)
        * tf.conj(Psi)
    )

    correlation_matrix = tf.einsum('fdtk,fetl->fkdle', Psi_conj_norm, Psi)
    correlation_vector = tf.einsum(
        'fdtk,fet->fked', Psi_conj_norm, Y[..., delay + taps - 1:]
    )

    correlation_matrix = tf.reshape(correlation_matrix, (F, taps * D, taps * D))
    return correlation_matrix, correlation_vector 
开发者ID:fgnt,项目名称:nara_wpe,代码行数:33,代码来源:tf_wpe.py

示例15: sph_harm_transform

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import conj [as 别名]
def sph_harm_transform(f, mode='DH', harmonics=None):
    """ Project spherical function into the spherical harmonics basis. """
    assert f.shape[0] == f.shape[1]

    if isinstance(f, tf.Tensor):
        sumfun = tf.reduce_sum
        conjfun = lambda x: tf.conj(x)
        n = f.shape[0].value
    else:
        sumfun = np.sum
        conjfun = np.conj
        n = f.shape[0]
    assert np.log2(n).is_integer()

    if harmonics is None:
        harmonics = sph_harm_all(n)

    a = DHaj(n, mode)

    f = f*np.array(a)[np.newaxis, :]

    real = is_real_sft(harmonics)

    coeffs = []
    for l in range(n // 2):
        row = []
        minl = 0 if real else -l
        for m in range(minl, l+1):
            # WARNING: results are off by this factor, when using driscoll1994computing formulas
            factor = 2*np.sqrt(np.pi)
            row.append(sumfun(factor * np.sqrt(2*np.pi)/n * f * conjfun(harmonics[l][m-minl])))
        coeffs.append(row)

    return coeffs 
开发者ID:daniilidis-group,项目名称:spherical-cnn,代码行数:36,代码来源:spherical.py


注:本文中的tensorflow.conj方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。