Helper to create a Variable stored on CPU memory.

  Args:
    name: name of the variable
    shape: list of ints
    initializer: initializer for Variable

  Returns:
    Variable Tensor
423279
def _variable_on_cpu(name, shape, initializer):
  
  with tf.device('/cpu:0'):
    dtype = tf.float16 if FLAGS.use_fp16 else tf.float32
    var = tf.get_variable(name, shape, initializer=initializer, dtype=dtype)
  return var
891290
def get_variable(self, name):
        
        name = get_op_tensor_name(name)[1]
        if len(self.vs_name):
            name_with_vs = self.vs_name + "/" + name
        else:
            name_with_vs = name
        return get_op_or_tensor_by_name(name_with_vs)
1207415
def get_var(self, name):
        
        for var in self.vars:
            if var.name == name:
                return var
        else:
            raise ValueError
835081
def isel_variable_and_index(
    name: Hashable,
    variable: Variable,
    index: pd.Index,
    indexers: Mapping[Any, Union[slice, Variable]],
) -> Tuple[Variable, Optional[pd.Index]]:
    """"""
    if not indexers:
        # nothing to index
        return variable.copy(deep=False), index

    if len(variable.dims) > 1:
        raise NotImplementedError(
            'indexing multi-dimensional variable with indexes is not '
            'supported yet')

    new_variable = variable.isel(indexers)

    if new_variable.dims != (name,):
        # can't preserve a index if result has new dimensions
        return new_variable, None

    # we need to compute the new index
    (dim,) = variable.dims
    indexer = indexers[dim]
    if isinstance(indexer, Variable):
        indexer = indexer.data
    new_index = index[indexer]
    return new_variable, new_index
552831
def _calc_T_var(self,X) -> int:
        """"""
        shape = X.shape
        tensor_rank: int = len(shape)
        if tensor_rank == 0:
            return 1
        if tensor_rank == 1:
            return shape[0]
        if tensor_rank == 2:
            if shape[1] > 1:
                raise ValueError('Initial value of a variable must have dimension T*1.')
            return shape[0]
887773
def var_str(name, shape):
    

    size = prod(shape)
    ind = (indices(shape) + 1).reshape(-1, size)
    names = ['[' + ','.join(list(map(str, i))) + ']' for i in zip(*ind)]
    names[0] = '%s %s' % (name, names[0])
    return names
988513
def get_global_variable(self, name):
        
        p = ffi.lib.LLVMPY_GetNamedGlobalVariable(self, _encode_string(name))
        if not p:
            raise NameError(name)
        return ValueRef(p, 'global', dict(module=self))
1010193
def _create_variables_no_pretrain(self, n_features):
        
        self.encoding_w_ = []
        self.encoding_b_ = []

        for l, layer in enumerate(self.layers):

            w_name = 'enc-w-{}'.format(l)
            b_name = 'enc-b-{}'.format(l)

            if l == 0:
                w_shape = [n_features, self.layers[l]]
            else:
                w_shape = [self.layers[l - 1], self.layers[l]]

            w_init = tf.truncated_normal(shape=w_shape, stddev=0.1)
            W = tf.Variable(w_init, name=w_name)
            tf.summary.histogram(w_name, W)
            self.encoding_w_.append(W)

            b_init = tf.constant(0.1, shape=[self.layers[l]])
            b = tf.Variable(b_init, name=b_name)
            tf.summary.histogram(b_name, b)
            self.encoding_b_.append(b)
331111
def iter(self, name):
        '''
        
        '''
        for frame in self.frames:
            vals = frame.get(name)
            if vals is None:
                continue
            for valu in vals:
                yield valu
479363
def _varname(self):
        
        if not self._flags['address']:
            self.log('Unable to assign Varname before allocating address',
                     ERROR)
            return

        varname = self.system.varname
        for i in range(self.n):
            iname = str(self.name[i])

            for e, var in enumerate(self._states):
                unamex = self._unamex[e]
                fnamex = self._fnamex[e]
                idx = self.__dict__[var][i]

                varname.unamex[idx] = '{} {}'.format(unamex, iname)[:33]
                varname.fnamex[idx] = '$' + '{}\\ {}'.format(
                    fnamex, iname.replace(' ', '\\ '))[:33] + '$'

            for e, var in enumerate(self._algebs):
                unamey = self._unamey[e]
                fnamey = self._fnamey[e]
                idx = self.__dict__[var][i]

                varname.unamey[idx] = '{} {}'.format(unamey, iname)[:33]
                varname.fnamey[idx] = '$' + '{}\\ {}'.format(
                    fnamey, iname.replace(' ', '\\ '))[:33] + '$'
423437
def underlying_variable(t):
  
  t = underlying_variable_ref(t)
  assert t is not None
  # make sure that the graph has a variable index and that it is up-to-date
  if not hasattr(tf.get_default_graph(), "var_index"):
    tf.get_default_graph().var_index = {}
  var_index = tf.get_default_graph().var_index
  for v in tf.global_variables()[len(var_index):]:
    var_index[v.name] = v
  return var_index[t.name]
567376
public SDVariable gatherNd(String name, SDVariable df, SDVariable indices) {
        SDVariable ret = f().gatherNd(df, indices);
        return updateVariableNameAndReference(ret, name);
    }
710204
def create_session(self, name=None):
        
        self.session = Session.create(self, name=name)
        return self.session
686348
def __make_var(self, name: str, shape: list):
        
        return tf.get_variable(name, shape, trainable=self.__network.is_trainable())
469187
def get_variable(self, name, initializer):
    
    v = tf.get_variable(name, shape=initializer.shape,
                        initializer=(lambda shape, dtype, partition_info:
                                     initializer),
                        trainable=self.training)
    return v
868767
def store_variable(var)
      # Force the correct bounds since we can't explicitly specify binary
      if var.type == :binary
        var.instance_variable_set(:@lower_bound, 0)
        var.instance_variable_set(:@upper_bound, 1)
      end
      set_variable_bounds var.index, var.lower_bound, var.upper_bound, true

      Cbc.Cbc_setObjCoeff @ptr, var.index, var.coefficient
      Cbc.Cbc_setColName(@ptr, var.index, var.name) unless var.name.nil?
      set_variable_type var.index, var.type
    end
1297399
def get_name_curr(self, name):
        
        self._register_name(name)

        return self._var_name_mappers[name].get_current()