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


Python tensorflow.float64方法代码示例

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


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

示例1: __init__

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import float64 [as 别名]
def __init__(self):
    global FLAGS
    self.FLAGS = FLAGS
    self.unk_token = "UNK"
    self.entry_match_token = "entry_match"
    self.column_match_token = "column_match"
    self.dummy_token = "dummy_token"
    self.tf_data_type = {}
    self.tf_data_type["double"] = tf.float64
    self.tf_data_type["float"] = tf.float32
    self.np_data_type = {}
    self.np_data_type["double"] = np.float64
    self.np_data_type["float"] = np.float32
    self.operations_set = ["count"] + [
        "prev", "next", "first_rs", "last_rs", "group_by_max", "greater",
        "lesser", "geq", "leq", "max", "min", "word-match"
    ] + ["reset_select"] + ["print"]
    self.word_ids = {}
    self.reverse_word_ids = {}
    self.word_count = {}
    self.random = Random(FLAGS.python_seed) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:23,代码来源:neural_programmer.py

示例2: get_privacy_spent

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import float64 [as 别名]
def get_privacy_spent(self, sess, target_eps=None):
    """Report the spending so far.

    Args:
      sess: the session to run the tensor.
      target_eps: the target epsilon. Unused.
    Returns:
      the list containing a single EpsDelta, with values as Python floats (as
      opposed to numpy.float64). This is to be consistent with
      MomentAccountant which can return a list of (eps, delta) pair.
    """

    # pylint: disable=unused-argument
    unused_target_eps = target_eps
    eps_squared_sum, delta_sum = sess.run([self._eps_squared_sum,
                                           self._delta_sum])
    return [EpsDelta(math.sqrt(eps_squared_sum), float(delta_sum))] 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:19,代码来源:accountant.py

示例3: __init__

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import float64 [as 别名]
def __init__(self, total_examples, moment_orders=32):
    """Initialize a MomentsAccountant.

    Args:
      total_examples: total number of examples.
      moment_orders: the order of moments to keep.
    """

    assert total_examples > 0
    self._total_examples = total_examples
    self._moment_orders = (moment_orders
                           if isinstance(moment_orders, (list, tuple))
                           else range(1, moment_orders + 1))
    self._max_moment_order = max(self._moment_orders)
    assert self._max_moment_order < 100, "The moment order is too large."
    self._log_moments = [tf.Variable(numpy.float64(0.0),
                                     trainable=False,
                                     name=("log_moments-%d" % moment_order))
                         for moment_order in self._moment_orders] 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:21,代码来源:accountant.py

示例4: simulate

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import float64 [as 别名]
def simulate(self, action):
    """Step the batch of environments.

    The results of the step can be accessed from the variables defined below.

    Args:
      action: Tensor holding the batch of actions to apply.

    Returns:
      Operation.
    """
    with tf.name_scope('environment/simulate'):
      if action.dtype in (tf.float16, tf.float32, tf.float64):
        action = tf.check_numerics(action, 'action')
      observ_dtype = self._parse_dtype(self._batch_env.observation_space)
      observ, reward, done = tf.py_func(
          lambda a: self._batch_env.step(a)[:3], [action],
          [observ_dtype, tf.float32, tf.bool], name='step')
      observ = tf.check_numerics(observ, 'observ')
      reward = tf.check_numerics(reward, 'reward')
      return tf.group(
          self._observ.assign(observ),
          self._action.assign(action),
          self._reward.assign(reward),
          self._done.assign(done)) 
开发者ID:utra-robosoccer,项目名称:soccer-matlab,代码行数:27,代码来源:in_graph_batch_env.py

示例5: simulate

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import float64 [as 别名]
def simulate(self, action):
    """Step the batch of environments.

    The results of the step can be accessed from the variables defined below.

    Args:
      action: Tensor holding the batch of actions to apply.

    Returns:
      Operation.
    """
    with tf.name_scope('environment/simulate'):
      if action.dtype in (tf.float16, tf.float32, tf.float64):
        action = tf.check_numerics(action, 'action')
      observ_dtype = utils.parse_dtype(self._batch_env.observation_space)
      observ, reward, done = tf.py_func(
          lambda a: self._batch_env.step(a)[:3], [action],
          [observ_dtype, tf.float32, tf.bool], name='step')
      observ = tf.check_numerics(observ, 'observ')
      reward = tf.check_numerics(reward, 'reward')
      reward.set_shape((len(self),))
      done.set_shape((len(self),))
      with tf.control_dependencies([self._observ.assign(observ)]):
        return tf.identity(reward), tf.identity(done) 
开发者ID:akzaidi,项目名称:fine-lm,代码行数:26,代码来源:py_func_batch_env.py

示例6: __init__

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import float64 [as 别名]
def __init__(self, epsilon=1e-4, shape=(), scope=''):
        sess = get_session()

        self._new_mean = tf.placeholder(shape=shape, dtype=tf.float64)
        self._new_var = tf.placeholder(shape=shape, dtype=tf.float64)
        self._new_count = tf.placeholder(shape=(), dtype=tf.float64)

        
        with tf.variable_scope(scope, reuse=tf.AUTO_REUSE):
            self._mean  = tf.get_variable('mean',  initializer=np.zeros(shape, 'float64'),      dtype=tf.float64)
            self._var   = tf.get_variable('std',   initializer=np.ones(shape, 'float64'),       dtype=tf.float64)    
            self._count = tf.get_variable('count', initializer=np.full((), epsilon, 'float64'), dtype=tf.float64)

        self.update_ops = tf.group([
            self._var.assign(self._new_var),
            self._mean.assign(self._new_mean),
            self._count.assign(self._new_count)
        ])

        sess.run(tf.variables_initializer([self._mean, self._var, self._count]))
        self.sess = sess
        self._set_mean_var_count() 
开发者ID:MaxSobolMark,项目名称:HardRLWithYoutube,代码行数:24,代码来源:running_mean_std.py

示例7: _build_relation_feature

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import float64 [as 别名]
def _build_relation_feature(self):
        if self.feature_type == 'id':
            self.relation_dim = self.n_relations
            self.relation_features = tf.eye(self.n_relations, dtype=tf.float64)
        elif self.feature_type == 'bow':
            bow = np.load('../data/' + self.dataset + '/bow.npy')
            self.relation_dim = bow.shape[1]
            self.relation_features = tf.constant(bow, tf.float64)
        elif self.feature_type == 'bert':
            bert = np.load('../data/' + self.dataset + '/bert.npy')
            self.relation_dim = bert.shape[1]
            self.relation_features = tf.constant(bert, tf.float64)

        # the feature of the last relation (the null relation) is a zero vector
        self.relation_features = tf.concat([self.relation_features, tf.zeros([1, self.relation_dim], tf.float64)],
                                           axis=0, name='relation_features') 
开发者ID:hwwang55,项目名称:PathCon,代码行数:18,代码来源:model.py

示例8: _get_neighbors_and_masks

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import float64 [as 别名]
def _get_neighbors_and_masks(self, relations, entity_pairs, train_edges):
        edges_list = [relations]
        masks = []
        train_edges = tf.expand_dims(train_edges, -1)  # [batch_size, 1]

        for i in range(self.context_hops):
            if i == 0:
                neighbor_entities = entity_pairs
            else:
                neighbor_entities = tf.reshape(tf.gather(self.edge2entities, edges_list[-1]), [self.batch_size, -1])
            neighbor_edges = tf.reshape(tf.gather(self.entity2edges, neighbor_entities), [self.batch_size, -1])
            edges_list.append(neighbor_edges)

            mask = neighbor_edges - train_edges  # [batch_size, -1]
            mask = tf.cast(tf.cast(mask, tf.bool), tf.float64)  # [batch_size, -1]
            masks.append(mask)
        return edges_list, masks 
开发者ID:hwwang55,项目名称:PathCon,代码行数:19,代码来源:model.py

示例9: _rnn

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import float64 [as 别名]
def _rnn(self, path_ids):
        path_ids = tf.reshape(path_ids, [self.batch_size * self.path_samples])  # [batch_size * path_samples]
        paths = tf.nn.embedding_lookup(self.id2path, path_ids)  # [batch_size * path_samples, max_path_len]
        # [batch_size * path_samples, max_path_len, relation_dim]
        path_features = tf.nn.embedding_lookup(self.relation_features, paths)
        lengths = tf.nn.embedding_lookup(self.id2length, path_ids)  # [batch_size * path_samples]

        cell = tf.nn.rnn_cell.LSTMCell(num_units=self.hidden_dim, name='basic_lstm_cell')
        initial_state = cell.zero_state(self.batch_size * self.path_samples, tf.float64)

        # [batch_size * path_samples, hidden_dim]
        _, last_state = tf.nn.dynamic_rnn(cell, path_features, sequence_length=lengths, initial_state=initial_state)

        self.W, self.b = self._get_weight_and_bias(self.hidden_dim, self.n_relations)
        output = tf.matmul(last_state.h, self.W) + self.b  # [batch_size * path_samples, n_relations]
        output = tf.reshape(output, [self.batch_size, self.path_samples, self.n_relations])

        return output 
开发者ID:hwwang55,项目名称:PathCon,代码行数:20,代码来源:model.py

示例10: initialize

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import float64 [as 别名]
def initialize(self, dtype=tf.float64):
        if self.tf_variance_scalar is None:
            if self.scalar is not None:
                self.tf_variance_scalar = tf.Variable(self.scalar, dtype=dtype)
            else:
                self.tf_variance_scalar = tf.Variable(1.0, dtype=dtype)

        if self.has_prior is None:
            if self.prior is not None:
                self.has_prior = True
                self.tf_alpha = tf.constant(self.prior["alpha"], dtype=dtype)
                self.tf_beta = tf.constant(self.prior["beta"], dtype=dtype)
            else:
                self.has_prior = False

        self.tf_dims = tf.constant(self.dims, dtype=dtype) 
开发者ID:aakhundov,项目名称:tf-example-models,代码行数:18,代码来源:isotropic_covariance.py

示例11: __init__

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import float64 [as 别名]
def __init__(self, data, components, cluster=None, dtype=tf.float64):
        if isinstance(data, np.ndarray):
            data = [data]

        self.data = data
        self.dims = sum(d.shape[1] for d in data)
        self.num_points = data[0].shape[0]
        self.components = components

        self.tf_graph = tf.Graph()

        self._initialize_workers(cluster)
        self._initialize_component_mapping()
        self._initialize_data_sources()
        self._initialize_variables(dtype)
        self._initialize_graph(dtype) 
开发者ID:aakhundov,项目名称:tf-example-models,代码行数:18,代码来源:mixture_model.py

示例12: initialize

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import float64 [as 别名]
def initialize(self, dtype=tf.float64):
        if self.tf_mean is None:
            if self.mean is not None:
                self.tf_mean = tf.Variable(self.mean, dtype=dtype)
            else:
                self.tf_mean = tf.Variable(tf.cast(tf.fill([self.dims], 0.0), dtype))

        if self.tf_covariance is None:
            if self.covariance is not None:
                self.tf_covariance = self.covariance
            else:
                self.tf_covariance = FullCovariance(self.dims)

            self.tf_covariance.initialize(dtype)

        if self.tf_ln2piD is None:
            self.tf_ln2piD = tf.constant(np.log(2 * np.pi) * self.dims, dtype=dtype) 
开发者ID:aakhundov,项目名称:tf-example-models,代码行数:19,代码来源:gaussian_distribution.py

示例13: llhIndividual

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import float64 [as 别名]
def llhIndividual(self, X: Tensor) -> Tensor:
        """Log likelihood of the parameters given data `X`."""

        # log likelihood of the noise
        llhRes = self.likelihood.llh(self.U, X)
        llh = llhRes

        # log likelihood of the factors
        llhU = []
        llhUfk = []
        U = list(self.U)
        for f, postUf in enumerate(self.postU):
            U = self.rescale(U=U, fNonUnit=f)
            UfT = tf.transpose(U[f])
            llhUfk.append(tf.reduce_sum(postUf.prior.llh(UfT), axis=0))
            llhUf = tf.reduce_sum(postUf.prior.llh(UfT))
            llh = llh + llhUf
            llhU.append(llhUf)
        llh = tf.cast(llh, tf.float64)
        return(llh, llhRes, llhU, llhUfk) 
开发者ID:bethgelab,项目名称:decompose,代码行数:22,代码来源:tensorFactorisation.py

示例14: __init__

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import float64 [as 别名]
def __init__(self, epsilon=1e-4, shape=(), scope=''):
        sess = get_session()

        self._new_mean = tf.placeholder(shape=shape, dtype=tf.float64)
        self._new_var = tf.placeholder(shape=shape, dtype=tf.float64)
        self._new_count = tf.placeholder(shape=(), dtype=tf.float64)


        with tf.variable_scope(scope, reuse=tf.AUTO_REUSE):
            self._mean  = tf.get_variable('mean',  initializer=np.zeros(shape, 'float64'),      dtype=tf.float64)
            self._var   = tf.get_variable('std',   initializer=np.ones(shape, 'float64'),       dtype=tf.float64)
            self._count = tf.get_variable('count', initializer=np.full((), epsilon, 'float64'), dtype=tf.float64)

        self.update_ops = tf.group([
            self._var.assign(self._new_var),
            self._mean.assign(self._new_mean),
            self._count.assign(self._new_count)
        ])

        sess.run(tf.variables_initializer([self._mean, self._var, self._count]))
        self.sess = sess
        self._set_mean_var_count() 
开发者ID:quantumiracle,项目名称:Reinforcement_Learning_for_Traffic_Light_Control,代码行数:24,代码来源:running_mean_std.py

示例15: train

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import float64 [as 别名]
def train(self):
        print("Total number of parameters: %d" % (self.hyp.shape[0]))
        
        X_tf = tf.placeholder(tf.float64)
        y_tf = tf.placeholder(tf.float64)
        hyp_tf = tf.Variable(self.hyp, dtype=tf.float64)
        
        train = self.likelihood(hyp_tf, X_tf, y_tf)
        
        init = tf.global_variables_initializer()
        self.sess.run(init)
        
        start_time = timeit.default_timer()
        for i in range(1,self.max_iter+1):
            # Fetch minibatch
            X_batch, y_batch = fetch_minibatch(self.X,self.y,self.N_batch)
            self.sess.run(train, {X_tf:X_batch, y_tf:y_batch})
            
            if i % self.monitor_likelihood == 0:
                elapsed = timeit.default_timer() - start_time
                nlml = self.sess.run(self.nlml)
                print('Iteration: %d, NLML: %.2f, Time: %.2f' % (i, nlml, elapsed))
                start_time = timeit.default_timer()

        self.hyp = self.sess.run(hyp_tf) 
开发者ID:maziarraissi,项目名称:ParametricGP,代码行数:27,代码来源:parametric_GP.py


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