GVKun编程网logo

Python numpy 模块-product() 实例源码(python的numpy模块)

1

在这篇文章中,我们将为您详细介绍Pythonnumpy模块-product()实例源码的内容,并且讨论关于python的numpy模块的相关问题。此外,我们还会涉及一些关于AndroidAOSP构建错

在这篇文章中,我们将为您详细介绍Python numpy 模块-product() 实例源码的内容,并且讨论关于python的numpy模块的相关问题。此外,我们还会涉及一些关于Android AOSP 构建错误 mkbootimg --kernel out/target/product/xiaomi/kernel 而不是 mkbootimg --kernel out/target/product/xiaomi/boot.img、Commerce Cloud 里的 Product Catalog 和 Product Categories 的联系、CRM 2015 - 如果我从 Project-Product、Quote-Product、Order-Project不是批量删除中选择多个记录,则删除需要将近 35 到 40 秒、javascript-TinyMCE将HREF从“ / category / product-name”更改为“ ../../../../category/product-name”的知识,以帮助您更全面地了解这个主题。

本文目录一览:

Python numpy 模块-product() 实例源码(python的numpy模块)

Python numpy 模块-product() 实例源码(python的numpy模块)

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

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

项目:deep_architect    作者:negrinho    | 项目源码 | 文件源码
  1. def compile(self, in_x, train_Feed, eval_Feed):
  2. n = np.product(self.in_d)
  3. m, param_init_fn = [dom[i] for (dom, i) in zip(self.domains, self.chosen)]
  4.  
  5. #sc = np.sqrt(6.0) / np.sqrt(m + n)
  6. #W = tf.Variable(tf.random_uniform([n,m],-sc,sc))
  7. W = tf.Variable( param_init_fn( [n, m] ) )
  8. b = tf.Variable(tf.zeros([m]))
  9.  
  10. # if the number of input dimensions is larger than one,flatten the
  11. # input and apply the affine transformation.
  12. if len(self.in_d) > 1:
  13. in_x_flat = tf.reshape(in_x, shape=[-1, n])
  14. out_y = tf.add(tf.matmul(in_x_flat, W), b)
  15. else:
  16. out_y = tf.add(tf.matmul(in_x, b)
  17. return out_y
  18.  
  19. # computes the output dimension based on the padding scheme used.
  20. # this comes from the tensorflow documentation
项目:deep_architect    作者:negrinho    | 项目源码 | 文件源码
  1. def get_outdim(self):
  2. #assert in_x == self.b.get_outdim()
  3. # relaxing input dimension equal to output dimension. taking into
  4. # account the padding scheme considered.
  5. out_d_b = self.b.get_outdim()
  6. in_d = self.in_d
  7.  
  8. if len(out_d_b) == len(in_d):
  9. out_d = tuple(
  10. [max(od_i, id_i) for (od_i, id_i) in zip(out_d_b, in_d)])
  11.  
  12. else:
  13. # flattens both input and output.
  14. out_d_b_flat = np.product(out_d_b)
  15. in_d_flat = np.product(in_d)
  16. out_d = (max(out_d_b_flat, in_d_flat) ,)
  17.  
  18. return out_d
项目:Projects    作者:it2school    | 项目源码 | 文件源码
  1. def get_surface(self, dest_surf = None):
  2. camera = self.camera
  3.  
  4. im = highgui.cvQueryFrame(camera)
  5. #convert Ipl image to PIL image
  6. #print type(im)
  7. if im:
  8. xx = opencv.adaptors.Ipl2NumPy(im)
  9. #print type(xx)
  10. #print xx.iscontiguous()
  11. #print dir(xx)
  12. #print xx.shape
  13. xxx = numpy.reshape(xx, (numpy.product(xx.shape),))
  14.  
  15. if xx.shape[2] != 3:
  16. raise ValueError("not sure what to do about this size")
  17.  
  18. pg_img = pygame.image.frombuffer(xxx, (xx.shape[1],xx.shape[0]), "RGB")
  19.  
  20. # if there is a destination surface given,we blit onto that.
  21. if dest_surf:
  22. dest_surf.blit(pg_img, (0,0))
  23. return dest_surf
  24. #return pg_img
项目:radar    作者:amoose136    | 项目源码 | 文件源码
  1. def test_addsumprod(self):
  2. # Tests add,sum,product.
  3. (x, y, a10, m1, m2, xm, ym, z, zm, xf) = self.d
  4. assert_equal(np.add.reduce(x), add.reduce(x))
  5. assert_equal(np.add.accumulate(x), add.accumulate(x))
  6. assert_equal(4, sum(array(4), axis=0))
  7. assert_equal(4, axis=0))
  8. assert_equal(np.sum(x, axis=0), sum(x, axis=0))
  9. assert_equal(np.sum(filled(xm, 0), sum(xm, 0))
  10. assert_equal(np.product(x, product(x, axis=0))
  11. assert_equal(np.product(x, 0))
  12. assert_equal(np.product(filled(xm, 1), product(xm, axis=0))
  13. s = (3, 4)
  14. x.shape = y.shape = xm.shape = ym.shape = s
  15. if len(s) > 1:
  16. assert_equal(np.concatenate((x, y), concatenate((xm, ym), 1))
  17. assert_equal(np.add.reduce(x, add.reduce(x, 1))
  18. assert_equal(np.sum(x, 1))
  19. assert_equal(np.product(x, 1))
项目:radar    作者:amoose136    | 项目源码 | 文件源码
  1. def test_testAddSumProd(self):
  2. # Test add, xf, s) = self.d
  3. self.assertTrue(eq(np.add.reduce(x), add.reduce(x)))
  4. self.assertTrue(eq(np.add.accumulate(x), add.accumulate(x)))
  5. self.assertTrue(eq(4, axis=0)))
  6. self.assertTrue(eq(4, axis=0)))
  7. self.assertTrue(eq(np.sum(x, axis=0)))
  8. self.assertTrue(eq(np.sum(filled(xm, 0)))
  9. self.assertTrue(eq(np.product(x, axis=0)))
  10. self.assertTrue(eq(np.product(x, 0)))
  11. self.assertTrue(eq(np.product(filled(xm,
  12. product(xm, axis=0)))
  13. if len(s) > 1:
  14. self.assertTrue(eq(np.concatenate((x,
  15. concatenate((xm, 1)))
  16. self.assertTrue(eq(np.add.reduce(x, 1)))
  17. self.assertTrue(eq(np.sum(x, 1)))
  18. self.assertTrue(eq(np.product(x, 1)))
项目:HTM_experiments    作者:ctrl-z-9000-times    | 项目源码 | 文件源码
  1. def __init__(self, input_shape, output_shape, output_sparsity=.05):
  2. """
  3. """
  4. self.learning_rate = 1/100
  5. self.input_shape = tuple(input_shape)
  6. self.output_shape = tuple(output_shape)
  7. self.input_size = np.product(self.input_shape)
  8. self.output_size = np.product(self.output_shape)
  9. self.on_bits = max(1, int(round(output_sparsity * self.output_size)))
  10. self.xp_q = NStepQueue(3, .90, self.learn)
  11. self.expected_values = np.random.random((self.input_size, self.output_size)) * self.learning_rate
  12. self.expected_values = np.array(self.expected_values, dtype=np.float32)
  13. print("Supervised Controller")
  14. print("\\tExpected Values shape:", self.expected_values.shape)
  15. print("\\tFuture discount:", self.xp_q.discount)
  16. print("\\tLearning Rate:", self.learning_rate)
项目:HTM_experiments    作者:ctrl-z-9000-times    | 项目源码 | 文件源码
  1. def predict(self, input_sdr=None):
  2. """
  3. Argument inputs is ndarray of indexes into the input space.
  4. Returns probability of each catagory in output space.
  5. """
  6. self.input_sdr.assign(input_sdr)
  7. pdf = self.stats[self.input_sdr.flat_index]
  8. if True:
  9. # Combine multiple probabilities into single pdf. Product,not
  10. # summation,to combine probabilities of independant events. The
  11. # problem with this is if a few unexpected bits turn on it
  12. # mutliplies the result by zero,and the test dataset is going to
  13. # have unexpected things in it.
  14. return np.product(pdf, axis=0, keepdims=False)
  15. else:
  16. # Use summation B/C it works well.
  17. return np.sum(pdf, keepdims=False)
项目:dist_hyperas    作者:osh    | 项目源码 | 文件源码
  1. def add_task(self, dataset_filename, model_filename):
  2. dataset_src = open(dataset_filename,''r'').read()
  3. model_src = open(model_filename,"r").read()
  4. src,info = hopt.extract_hopts(model_src)
  5. ss_size = int(np.product( map(lambda x: len(x["options"]), info.values() ) ))
  6. print "Search space size: ", ss_size
  7. w = []
  8.  
  9. for i in range(0,ss_size):
  10. info_i,src_i = hopt.produce_variant(src,copy.deepcopy(info),i)
  11. info_i["subtask"] = i
  12. w.append( (info_i,dataset_src,src_i) )
  13.  
  14. print "submitting task..."
  15. rv = self.socket.send_json(("submit_task", w))
  16. print rv
项目:vampyre    作者:GAMPTeam    | 项目源码 | 文件源码
  1. def repeat_sum(u,shape,rep_axes):
  2. """
  3. Computes sum of a repeated matrix
  4.  
  5. In effect,this routine computes
  6. code:`np.sum(repeat(u,shape,rep_axes))`. However,it performs
  7. this without having to perform the full repetition.
  8.  
  9. """
  10. # Must convert to np.array to perform slicing
  11. shape_vec = np.array(shape,dtype=int)
  12. rep_vec = np.array(rep_axes,dtype=int)
  13.  
  14. # repeat and sum
  15. urep = repeat_axes(u,rep_axes,rep=False)
  16. usum = np.sum(urep)*np.product(shape_vec[rep_vec])
  17. return usum
项目:sympl    作者:mcgibbon    | 项目源码 | 文件源码
  1. def get_final_shape(data_array, out_dims, direction_to_names):
  2. """
  3. Determine the final shape that data_array must be reshaped to in order to
  4. have one axis for each of the out_dims (for instance,combining all
  5. axes collected by the ''*'' direction).
  6. """
  7. final_shape = []
  8. for direction in out_dims:
  9. if len(direction_to_names[direction]) == 0:
  10. final_shape.append(1)
  11. else:
  12. # determine shape once dimensions for direction (usually ''*'') are combined
  13. final_shape.append(
  14. np.product([len(data_array.coords[name])
  15. for name in direction_to_names[direction]]))
  16. return final_shape
项目:bolero    作者:rock-learning    | 项目源码 | 文件源码
  1. def _init_space(self, space):
  2. if not isinstance(space, gym.Space):
  3. raise ValueError("UnkNown space,type ''%s''" % type(space))
  4. elif isinstance(space, gym.spaces.Box):
  5. n_dims = np.product(space.shape)
  6. handler = BoxClipHandler(space.low, space.high)
  7. elif isinstance(space, gym.spaces.discrete):
  8. n_dims = 1
  9. handler = IntHandler(space.n)
  10. elif isinstance(space, gym.spaces.HighLow):
  11. n_dims = space.num_rows
  12. handler = HighLowHandler(space.matrix)
  13. elif isinstance(space, gym.spaces.Tuple):
  14. raise NotImplementedError("Space of type ''%s'' is not supported"
  15. % type(space))
  16. return n_dims, handler
项目:dl4nlp    作者:yohokuno    | 项目源码 | 文件源码
  1. def train(self, sentences, iterations=1000):
  2. # Preprocess sentences to create indices of context and next words
  3. self.dictionary = build_dictionary(sentences, self.vocabulary_size)
  4. indices = to_indices(sentences, self.dictionary)
  5. self.reverse_dictionary = {index: word for word, index in self.dictionary.items()}
  6. inputs, outputs = self.create_context(indices)
  7.  
  8. # Create cost and gradient function for gradient descent
  9. shapes = [self.W_shape, self.U_shape, self.H_shape, self.C_shape]
  10. flatten_nplm_cost_gradient = flatten_cost_gradient(nplm_cost_gradient, shapes)
  11. cost_gradient = bind_cost_gradient(flatten_nplm_cost_gradient, inputs, outputs,
  12. sampler=get_stochastic_sampler(10))
  13.  
  14. # Train neural network
  15. parameters_size = np.sum(np.product(shape) for shape in shapes)
  16. initial_parameters = np.random.normal(size=parameters_size)
  17. self.parameters, cost_history = gradient_descent(cost_gradient, initial_parameters, iterations)
  18. return cost_history
项目:arlpy    作者:org-arl    | 项目源码 | 文件源码
  1. def ser(x, y):
  2. """Measure symbol error rate between symbols in x and y.
  3.  
  4. :param x: symbol array #1
  5. :param y: symbol array #2
  6. :returns: symbol error rate
  7.  
  8. >>> import arlpy
  9. >>> arlpy.comms.ser([0,1,2,3],[0,2])
  10. 0.25
  11. """
  12. x = _np.asarray(x, dtype=_np.int)
  13. y = _np.asarray(y, dtype=_np.int)
  14. n = _np.product(_np.shape(x))
  15. e = _np.count_nonzero(x^y)
  16. return float(e)/n
项目:arlpy    作者:org-arl    | 项目源码 | 文件源码
  1. def ber(x, m=2):
  2. """Measure bit error rate between symbols in x and y.
  3.  
  4. :param x: symbol array #1
  5. :param y: symbol array #2
  6. :param m: symbol alphabet size (maximum 64)
  7. :returns: bit error rate
  8.  
  9. >>> import arlpy
  10. >>> arlpy.comms.ber([0,2],m=4)
  11. 0.125
  12. """
  13. x = _np.asarray(x, dtype=_np.int)
  14. if _np.any(x >= m) or _np.any(y >= m) or _np.any(x < 0) or _np.any(y < 0):
  15. raise ValueError(''Invalid data for specified m'')
  16. if m == 2:
  17. return ser(x, y)
  18. if m > _MAX_M:
  19. raise ValueError(''m > %d not supported'' % (_MAX_M))
  20. n = _np.product(_np.shape(x))*_np.log2(m)
  21. e = x^y
  22. e = e[_np.nonzero(e)]
  23. e = _np.sum(_popcount[e])
  24. return float(e)/n
项目:sporco    作者:bwohlberg    | 项目源码 | 文件源码
  1. def __init__(self, xshape, dtype, opt=None):
  2. """
  3. Initialise an FISTADFT object with problem size and options.
  4.  
  5. Parameters
  6. ----------
  7. xshape : tuple of ints
  8. Shape of working variable X (the primary variable)
  9. dtype : data-type
  10. Data type for working variables
  11. opt : :class:`FISTADFT.Options` object
  12. Algorithm options
  13. """
  14.  
  15. if opt is None:
  16. opt = FISTADFT.Options()
  17. Nx = np.product(xshape)
  18. super(FISTADFT, self).__init__(Nx, opt)
  19.  
  20. self.Xf = None
  21. self.Yf = None
项目:sporco    作者:bwohlberg    | 项目源码 | 文件源码
  1. def __init__(self, opt=None):
  2. """
  3. Initialise an ADMMEqual object with problem size and options.
  4.  
  5. Parameters
  6. ----------
  7. xshape : tuple of ints
  8. Shape of working variable X (the primary variable)
  9. dtype : data-type
  10. Data type for working variables
  11. opt : :class:`ADMMEqual.Options` object
  12. Algorithm options
  13. """
  14.  
  15. if opt is None:
  16. opt = ADMMEqual.Options()
  17. Nx = np.product(xshape)
  18. super(ADMMEqual, opt)
项目:sporco    作者:bwohlberg    | 项目源码 | 文件源码
  1. def mpraw_as_np(shape, dtype):
  2. """Construct a numpy array of the specified shape and dtype for which the
  3. underlying storage is a multiprocessing RawArray in shared memory.
  4.  
  5. Parameters
  6. ----------
  7. shape : tuple
  8. Shape of numpy array
  9. dtype : data-type
  10. Data type of array
  11.  
  12. Returns
  13. -------
  14. arr : ndarray
  15. Numpy array
  16. """
  17.  
  18. sz = int(np.product(shape))
  19. csz = sz * np.dtype(dtype).itemsize
  20. raw = mp.RawArray(''c'', csz)
  21. return np.frombuffer(raw, dtype=dtype, count=sz).reshape(shape)
项目:tools    作者:kastnerkyle    | 项目源码 | 文件源码
  1. def slinterp(X, factor, copy=True):
  2. """
  3. Slow-ish linear interpolation of a 1D numpy array. There must be some
  4. better function to do this in numpy.
  5.  
  6. Parameters
  7. ----------
  8. X : ndarray
  9. 1D input array to interpolate
  10.  
  11. factor : int
  12. Integer factor to interpolate by
  13.  
  14. Return
  15. ------
  16. X_r : ndarray
  17. """
  18. sz = np.product(X.shape)
  19. X = np.array(X, copy=copy)
  20. X_s = np.hstack((X[1:], [0]))
  21. X_r = np.zeros((factor, sz))
  22. for i in range(factor):
  23. X_r[i, :] = (factor - i) / float(factor) * X + (i / float(factor)) * X_s
  24. return X_r.T.ravel()[:(sz - 1) * factor + 1]
项目:tools    作者:kastnerkyle    | 项目源码 | 文件源码
  1. def slinterp(X, :] = (factor - i) / float(factor) * X + (i / float(factor)) * X_s
  2. return X_r.T.ravel()[:(sz - 1) * factor + 1]
项目:instacart-basket-prediction    作者:colinmorris    | 项目源码 | 文件源码
  1. def exact_expected_fscore_naive(probs, thresh):
  2. """NB: This algorithm is exponential in the size of probs!
  3. Based on initial measurements,less than 15 items is
  4. sub-second. 16 = 2s,17=4s,18=8s,and,well,you kNow
  5. the rest...
  6. possible relaxation to allow larger number of products:
  7. force items with sufficiently low probs (e.g. < 1%) off
  8. in groundtruths.
  9. """
  10. probs = np.asarray(probs)
  11. n = len(probs)
  12. expected = 0
  13. p_none = np.product(1-probs)
  14. predict_none = p_none > thresh
  15. predictions = (probs >= thresh).astype(np.int8)
  16. for gt in itertools.product([0,1], repeat=n):
  17. gt = np.array(gt)
  18. fs = fscore(predictions, gt, predict_none)
  19. p = gt_prob(gt, probs)
  20. expected += fs * p
  21. return expected
项目:vec4ir    作者:lgalke    | 项目源码 | 文件源码
  1. def eqe1(E, query, vocabulary, priors):
  2. """
  3. Arguments:
  4. E - word embedding
  5. Q - list of query terms
  6. vocabulary -- list of relevant words
  7. priors - precomputed priors with same indices as vocabulary
  8. >>> E = dict()
  9. >>> E[''a''] = np.asarray([0.5,0.5])
  10. >>> E[''b''] = np.asarray([0.2,0.8])
  11. >>> E[''c''] = np.asarray([0.9,0.1])
  12. >>> E[''d''] = np.asarray([0.8,0.2])
  13. >>> q = "a b".split()
  14. >>> vocabulary = "a b c".split()
  15. >>> priors = np.asarray([0.25,0.5,0.25])
  16. >>> posterior = eqe1(E,q,vocabulary,priors)
  17. >>> vocabulary[np.argmax(posterior)]
  18. ''c''
  19. """
  20. posterior = [priors[i] *
  21. np.product([delta(E[qi], E[w]) / priors[i] for qi in query])
  22. for i, w in enumerate(vocabulary)]
  23.  
  24. return np.asarray(posterior)
项目:luna16    作者:gzuidhof    | 项目源码 | 文件源码
  1. def weight_by_class_balance(truth, classes=None):
  2. """
  3. Determines a loss weight map given the truth by balancing the classes from the classes argument.
  4. The classes argument can be used to only include certain classes (you may for instance want to exclude the background).
  5. """
  6.  
  7. if classes is None:
  8. # Include all classes
  9. classes = np.unique(truth)
  10.  
  11. weight_map = np.zeros_like(truth, dtype=np.float32)
  12. total_amount = np.product(truth.shape)
  13.  
  14. for c in classes:
  15. class_mask = np.where(truth==c,1,0)
  16. class_weight = 1/((np.sum(class_mask)+1e-8)/total_amount)
  17.  
  18. weight_map += (class_mask*class_weight)#/total_amount
  19.  
  20. return weight_map
项目:pyprocessmacro    作者:QuentinAndre    | 项目源码 | 文件源码
  1. def eval_expression(expr, values=None):
  2. """
  3. Evaluate a symbolic expression and returns a numerical array.
  4. :param expr: A symbolic expression to evaluate,in the form of a N_terms * N_Vars matrix
  5. :param values: None,or a dictionary of variable:value pairs,to substitute in the symbolic expression.
  6. :return: An evaled expression,in the form of an N_terms array.
  7. """
  8. n_coeffs = expr.shape[0]
  9. evaled_expr = np.zeros(n_coeffs)
  10. for (i, term) in enumerate(expr):
  11. if values:
  12. evaled_term = np.array([values.get(elem, 0) if isinstance(elem, str) else elem for elem in term])
  13. else:
  14. evaled_term = np.array(
  15. [0 if isinstance(elem, str) else elem for elem in term]) # All variables at 0
  16. evaled_expr[i] = np.product(evaled_term.astype(float)) # Gradient is the product of values
  17. return evaled_expr
项目:krpcScripts    作者:jwvanderbeck    | 项目源码 | 文件源码
  1. def test_addsumprod(self):
  2. # Tests add, 1))
项目:krpcScripts    作者:jwvanderbeck    | 项目源码 | 文件源码
  1. def test_testAddSumProd(self):
  2. # Test add, 1)))
项目:yt    作者:yt-project    | 项目源码 | 文件源码
  1. def _read_raw_field(self, grid, field):
  2. field_name = field[1]
  3. base_dir = self.ds.index.raw_file
  4.  
  5. Box_list = self.ds.index.raw_field_map[field_name][0]
  6. fn_list = self.ds.index.raw_field_map[field_name][1]
  7. offset_list = self.ds.index.raw_field_map[field_name][2]
  8.  
  9. lev = grid.Level
  10. filename = base_dir + "Level_%d/" % lev + fn_list[grid.id]
  11. offset = offset_list[grid.id]
  12. Box = Box_list[grid.id]
  13.  
  14. lo = Box[0]
  15. hi = Box[1]
  16. shape = hi - lo + 1
  17. with open(filename, "rb") as f:
  18. f.seek(offset)
  19. f.readline() # always skip the first line
  20. arr = np.fromfile(f, ''float64'', np.product(shape))
  21. arr = arr.reshape(shape, order=''F'')
  22. return arr
项目:yt    作者:yt-project    | 项目源码 | 文件源码
  1. def __init__(self, ds, max_level=2):
  2. self.max_level = max_level
  3. self.cell_count = 0
  4. self.layers = []
  5. self.domain_dimensions = ds.domain_dimensions
  6. self.domain_left_edge = ds.domain_left_edge
  7. self.domain_right_edge = ds.domain_right_edge
  8. self.grid_filename = "amr_grid.inp"
  9. self.ds = ds
  10.  
  11. base_layer = RadMC3DLayer(0, None, 0,
  12. self.domain_left_edge,
  13. self.domain_right_edge,
  14. self.domain_dimensions)
  15.  
  16. self.layers.append(base_layer)
  17. self.cell_count += np.product(ds.domain_dimensions)
  18.  
  19. sorted_grids = sorted(ds.index.grids, key=lambda x: x.Level)
  20. for grid in sorted_grids:
  21. if grid.Level <= self.max_level:
  22. self._add_grid_to_layers(grid)
项目:data_tools    作者:veugene    | 项目源码 | 文件源码
  1. def __init__(self, patchsize, source, binary_mask=None,
  2. random_order=False, mirrored=True, max_num=None):
  3. self.patchsize = patchsize
  4. self.source = source.astype(np.float32)
  5. self.mask = binary_mask
  6. self.random_order = random_order
  7. self.mirrored = mirrored
  8. self.max_num = max_num
  9.  
  10. if len(self.source.shape)==2:
  11. self.source = self.source[:,:,np.newaxis]
  12. if self.mask is not None and len(self.mask.shape)==2:
  13. self.mask = self.mask[:,np.newaxis]
  14.  
  15. if self.mask is not None:
  16. self.num_patches = (self.mask>0).sum()
  17. else:
  18. self.num_patches = np.product(self.source.shape)
项目:drmad    作者:bigaidream-projects    | 项目源码 | 文件源码
  1. def apply(self, data, copy=False):
  2. if copy:
  3. data = np.copy(data)
  4. data_shape = data.shape
  5. if len(data.shape) > 2:
  6. data = data.reshape(data.shape[0], np.product(data.shape[1:]))
  7. assert len(data.shape) == 2, ''Contrast norm on flattened data''
  8. # assert np.min(data) >= 0.
  9. # assert np.max(data) <= 1.
  10. data -= data.mean(axis=1)[:, np.newaxis]
  11. norms = np.sqrt(np.sum(data ** 2, axis=1)) / self.scale
  12. norms[norms < self.epsilon] = self.epsilon
  13. data /= norms[:, np.newaxis]
  14. if data_shape != data.shape:
  15. data = data.reshape(data_shape)
  16. return data
项目:data-science-bowl-2017    作者:tondonia    | 项目源码 | 文件源码
  1. def weight_by_class_balance(truth, dtype=np.float32)
  2. total_amount = np.product(truth.shape)
  3.  
  4. min_weight = sys.maxint
  5. for c in classes:
  6. class_mask = np.where(truth==c,0)
  7. class_weight = 1/((np.sum(class_mask)+1e-8)/total_amount)
  8. if class_weight < min_weight:
  9. min_weight = class_weight
  10. weight_map += (class_mask*class_weight)#/total_amount
  11. weight_map /= min_weight
  12. return weight_map
项目:mriqc    作者:poldracklab    | 项目源码 | 文件源码
  1. def __iter__(self):
  2. """Iterate over the points in the grid.
  3. Returns
  4. -------
  5. params : iterator over dict of string to any
  6. Yields dictionaries mapping each estimator parameter to one of its
  7. allowed values.
  8. """
  9. for p in self.param_grid:
  10. # Always sort the keys of a dictionary,for reproducibility
  11. items = list(p.items())
  12. if not items:
  13. yield {}
  14. else:
  15. for estimator, grid_list in items:
  16. for grid in grid_list:
  17. grid_points = sorted(list(grid.items()))
  18. keys, values = zip(*grid_points)
  19. for v in product(*values):
  20. params = dict(zip(keys, v))
  21. yield (estimator, params)
项目:coremltools    作者:apple    | 项目源码 | 文件源码
  1. def test_activation_layer_params(self):
  2. options = dict(
  3. activation = [''tanh'', ''relu'', ''sigmoid'', ''softmax'', ''softplus'', ''softsign'', ''hard_sigmoid'', ''elu'']
  4. )
  5.  
  6. # Define a function that tests a model
  7. num_channels = 10
  8. input_dim = 10
  9. def build_model(x):
  10. model = Sequential()
  11. model.add(Dense(num_channels, input_dim = input_dim))
  12. model.add(Activation(**dict(zip(options.keys(), x))))
  13. return x, model
  14.  
  15. # Iterate through all combinations
  16. product = itertools.product(*options.values())
  17. args = [build_model(p) for p in product]
  18.  
  19. # Test the cases
  20. print("Testing a total of %s cases. This Could take a while" % len(args))
  21. for param, model in args:
  22. model.set_weights([np.random.rand(*w.shape) for w in model.get_weights()])
  23. self._run_test(model, param)
项目:coremltools    作者:apple    | 项目源码 | 文件源码
  1. def test_dense_layer_params(self):
  2. options = dict(
  3. activation = [''relu'', ''tanh'', ''elu'',''hard_sigmoid''],
  4. use_bias = [True, False],
  5. )
  6. # Define a function that tests a model
  7. input_shape = (10,)
  8. num_channels = 10
  9. def build_model(x):
  10. kwargs = dict(zip(options.keys(), x))
  11. model = Sequential()
  12. model.add(Dense(num_channels, input_shape = input_shape, **kwargs))
  13. return x, model in args:
  14. self._run_test(model, param)
项目:coremltools    作者:apple    | 项目源码 | 文件源码
  1. def test_conv_layer_params(self, model_precision=_MLMODEL_FULL_PRECISION):
  2. options = dict(
  3. activation = [''relu'', ''sigmoid''], # keras does not support softmax on 4-D
  4. use_bias = [True,
  5. padding = [''same'', ''valid''],
  6. filters = [1, 3, 5],
  7. kernel_size = [[5,5]], # fails when sizes are different
  8. )
  9.  
  10. # Define a function that tests a model
  11. input_shape = (10, 10, 1)
  12. def build_model(x):
  13. kwargs = dict(zip(options.keys(), x))
  14. model = Sequential()
  15. model.add(Conv2D(input_shape = input_shape, param, model_precision=model_precision)
项目:coremltools    作者:apple    | 项目源码 | 文件源码
  1. def test_activation_layer_params(self):
  2. options = dict(
  3. activation = [''tanh'', ''softsign'']
  4. )
  5.  
  6. # Define a function that tests a model
  7. num_channels = 10
  8. input_dim = 10
  9. def build_model(x):
  10. model = Sequential()
  11. model.add(Dense(num_channels, param)
项目:coremltools    作者:apple    | 项目源码 | 文件源码
  1. def test_dense_layer_params(self):
  2. options = dict(
  3. activation = [''relu'',
  4. bias = [True,
  5. )
  6.  
  7. # Define a function that tests a model
  8. input_dim = 10
  9. num_channels = 10
  10. def build_model(x):
  11. kwargs = dict(zip(options.keys(), input_dim = input_dim, param)
项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda    作者:SignalMedia    | 项目源码 | 文件源码
  1. def cartesian_product(X):
  2. ''''''
  3. Numpy version of itertools.product or pandas.compat.product.
  4. Sometimes faster (for large inputs)...
  5.  
  6. Examples
  7. --------
  8. >>> cartesian_product([list(''ABC''),[1,2]])
  9. [array([''A'',''A'',''B'',''C'',''C''],dtype=''|S1''),
  10. array([1,2])]
  11.  
  12. ''''''
  13.  
  14. lenX = np.fromiter((len(x) for x in X), dtype=int)
  15. cumprodX = np.cumproduct(lenX)
  16.  
  17. a = np.roll(cumprodX, 1)
  18. a[0] = 1
  19.  
  20. b = cumprodX[-1] / cumprodX
  21.  
  22. return [np.tile(np.repeat(np.asarray(com._values_from_object(x)), b[i]),
  23. np.product(a[i]))
  24. for i, x in enumerate(X)]
项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda    作者:SignalMedia    | 项目源码 | 文件源码
  1. def test_addsumprod(self):
  2. # Tests add, 1))
项目:aifun    作者:Plottel    | 项目源码 | 文件源码
  1. def get_surface(self,0))
  2. return dest_surf
  3. #return pg_img
项目:aws-lambda-numpy    作者:vitolimandibhrata    | 项目源码 | 文件源码
  1. def test_addsumprod(self):
  2. # Tests add, 1))
项目:aws-lambda-numpy    作者:vitolimandibhrata    | 项目源码 | 文件源码
  1. def test_testAddSumProd(self):
  2. # Test add, 1)))
项目:pyDataView    作者:edwardsmith999    | 项目源码 | 文件源码
  1. def __init__(self, fdir, fname, nperbin):
  2.  
  3. if (fdir[-1] != ''/''): fdir += ''/''
  4. self.fdir = fdir
  5. self.procxyz = self.get_proc_topology()
  6. self.procs = int(np.product(self.procxyz))
  7. print("OpenFOAM_RawData Warning - disable parallel check,assuming always parallel")
  8. self.parallel_run = True
  9. #if self.procs != 1:
  10. # self.parallel_run = True
  11. #else:
  12. # self.parallel_run = False
  13. self.grid = self.get_grid()
  14. self.reclist = self.get_reclist()
  15. self.maxrec = len(self.reclist) - 1 # count from 0
  16. self.fname = fname
  17. self.npercell = nperbin #self.get_npercell()
  18. self.nu = self.get_nu()
  19. self.header = None
项目:keras-steering-angle-visualizations    作者:jacobgil    | 项目源码 | 文件源码
  1. def visualize_hypercolumns(model, original_img):
  2.  
  3. img = np.float32(cv2.resize(original_img, (200, 66))) / 255.0
  4.  
  5. layers_extract = [9]
  6.  
  7. hc = extract_hypercolumns(model, layers_extract, img)
  8. avg = np.product(hc, axis=0)
  9. avg = np.abs(avg)
  10. avg = avg / np.max(np.max(avg))
  11.  
  12. heatmap = cv2.applyColorMap(np.uint8(255 * avg), cv2.COLORMAP_JET)
  13. heatmap = np.float32(heatmap) / np.max(np.max(heatmap))
  14. heatmap = cv2.resize(heatmap, original_img.shape[0:2][::-1])
  15.  
  16. both = 255 * heatmap * 0.7 + original_img
  17. both = both / np.max(both)
  18. return both
项目:kaggle_dsb    作者:syagev    | 项目源码 | 文件源码
  1. def weight_by_class_balance(truth,0)
  2. class_weight = 1/((np.sum(class_mask)+1e-8)/total_amount)
  3.  
  4. weight_map += (class_mask*class_weight)#/total_amount
  5.  
  6. return weight_map
项目:yt_astro_analysis    作者:yt-project    | 项目源码 | 文件源码
  1. def __init__(self, key=lambda x: x.Level)
  2. for grid in sorted_grids:
  3. if grid.Level <= self.max_level:
  4. self._add_grid_to_layers(grid)
项目:lambda-numba    作者:rlhotovy    | 项目源码 | 文件源码
  1. def test_addsumprod(self):
  2. # Tests add, 1))
项目:lambda-numba    作者:rlhotovy    | 项目源码 | 文件源码
  1. def test_testAddSumProd(self):
  2. # Test add, 1)))
项目:opminreplicability    作者:epochx    | 项目源码 | 文件源码
  1. def __iter__(self):
  2. """Iterate over the points in the grid.
  3.  
  4. Returns
  5. -------
  6. params : iterator over dict of string to any
  7. Yields dictionaries mapping each estimator parameter to one of its
  8. allowed values.
  9. """
  10. for p in self.param_grid:
  11. # Always sort the keys of a dictionary,for reproducibility
  12. items = sorted(p.items())
  13. if not items:
  14. yield {}
  15. else:
  16. keys, values = zip(*items)
  17. for v in product(*values):
  18. params = dict(zip(keys, v))
  19. yield params
项目:dynesty    作者:joshspeagle    | 项目源码 | 文件源码
  1. def make_eigvals_positive(am, targetprod):
  2. """For the symmetric square matrix `am`,increase any zero eigenvalues
  3. such that the total product of eigenvalues is greater or equal to
  4. `targetprod`. Returns a (possibly) new,non-singular matrix."""
  5.  
  6. w, v = linalg.eigh(am) # use eigh since a is symmetric
  7. mask = w < 1.e-10
  8. if np.any(mask):
  9. nzprod = np.product(w[~mask]) # product of nonzero eigenvalues
  10. nzeros = mask.sum() # number of zero eigenvalues
  11. new_val = max(1.e-10, (targetprod / nzprod) ** (1. / nzeros))
  12. w[mask] = new_val # adjust zero eigvals
  13. am_new = np.dot(np.dot(v, np.diag(w)), linalg.inv(v)) # re-form cov
  14. else:
  15. am_new = am
  16.  
  17. return am_new
项目:deliver    作者:orchestor    | 项目源码 | 文件源码
  1. def test_addsumprod(self):
  2. # Tests add, 1))

Android AOSP 构建错误 mkbootimg --kernel out/target/product/xiaomi/kernel 而不是 mkbootimg --kernel out/target/product/xiaomi/boot.img

Android AOSP 构建错误 mkbootimg --kernel out/target/product/xiaomi/kernel 而不是 mkbootimg --kernel out/target/product/xiaomi/boot.img

如何解决Android AOSP 构建错误 mkbootimg --kernel out/target/product/xiaomi/kernel 而不是 mkbootimg --kernel out/target/product/xiaomi/boot.img

我正在尝试为 redmi 5a 构建 aosp,所有设备、内核和供应商都是通过清单设置的。构建时出现以下错误:

Failed: ninja: ''out/target/product/xiaomi/kernel'',''out/target/product/xiaomi/boot.img'' 需要,缺少并且没有已知的规则来实现

我认为它无法创建手动创建的“内核”文件夹,但后来出现了新错误: enter image description here

如果您仔细查看输出(请参考图片): /bin/bash -c "(out/host/linux-x86/bin/mkbootimg --kernel out/target/product/xiaomi/kernel

代替 mkbootimg --kernel out/target/product/xiaomi/kernel 应该是 mkbootimg --kernel out/target/product/xiaomi/boot.img*

我无法找到我可以在哪里进行更改以实现此目的。请帮我解决这个问题。

Commerce Cloud 里的 Product Catalog 和 Product Categories 的联系

Commerce Cloud 里的 Product Catalog 和 Product Categories 的联系

SAP Commerce Cloud 是一个为企业提供全方位电子商务解决方案的平台,旨在帮助企业实现高效的在线销售和客户管理。其中,product catalog(产品目录)是该平台中一个核心的组件,它承载着企业对外展示商品信息的重要功能。

product catalog 在 SAP Commerce Cloud 中,主要指的是一个组织结构化的商品和服务的集合。这个目录包含了企业提供的全部或部分产品,按照一定的分类和属性进行组织,以便客户能够方便地浏览、搜索和选择产品。通常情况下,一个企业可以拥有多个 product catalog,比如区分为 Summer CollectionWinter Collection,或者是基于市场区分的,如 EU CatalogUS Catalog

product categories(产品类别),则是在产品目录内部用来进一步组织产品的方式。类别可以被视为目录内的一个层次或者节点,它帮助将产品细分成更小的集合,这对于管理大量的产品非常有帮助。例如,一个服装零售商的 product catalog 可能包括如 Men''s ClothingWomen''s ClothingChildren''s Clothing 这样的产品类别。每个类别下面,还可以进一步细分,如 Men''s Clothing 可以分为 SuitsCasual WearOuterwear 等子类别。

在 SAP Commerce Cloud 中,产品目录和产品类别的关系是非常紧密的。产品目录提供了一个宏观的视角,展示了企业可以提供的所有商品的范围。而产品类别则提供了更细化的视图,帮助客户在复杂多变的商品中快速找到他们感兴趣的项。此外,这种结构化的信息不仅仅是为了方便用户,它也使得企业能够更有效地管理产品数据,比如轻松更新、维护和推广特定类别的商品。

例如,假设一个国际运动服装品牌拥有一个全球性的 product catalog。在这个目录下,可能会有 RunningFootballBasketball 等多个产品类别。每个类别下面,根据具体的需求和市场定位,又会分为不同的子类别,如 Running 可以细分为 ShoesApparelAccessories。这种组织方式不仅帮助消费者更快地找到他们需要的产品,也便于企业针对特定市场或季节推出促销活动。

对于企业来说,管理 product catalogproduct categories 是非常重要的。这不仅关系到产品信息的准确性和及时更新,也关系到企业能否提供良好的客户体验。例如,确保产品分类逻辑、直观并且易于导航是提高转化率的关键。此外,随着电子商务的发展,企业还需要不断地通过数据分析来优化目录结构,以适应市场趋势和消费者行为的变化。

在实际操作中,SAP Commerce Cloud 提供了强大的工具和接口来管理产品目录和类别。通过后台管理系统,企业可以轻松地添加、修改或删除产品信息,调整类别结构,或者为特定的市场或客户群体定制目录。此外,这个平台还支持多种语言和货币,使得跨国经营变得更加容易。

最终,通过高效的目录管理,企业可以确保在竞争激烈的市场中保持优势,通过精确的市场定位和有效的客户沟通来提升销售业绩和品牌价值。无论是面对企业客户还是最终消费者,一个结构清晰、易于导航的产品目录都是成功的关键。

总结来说,product catalogproduct categories 在 SAP Commerce Cloud 中扮演着至关重要的角色。它们不仅构成了企业提供服务的基础,也是提升客户体验和实现销售目标的重要工具。通过合理的规划和细致的管理,企业可以利用这些工具来提升市场竞争力和客户满意度,实现持续的业务增长和扩展。

CRM 2015 - 如果我从 Project-Product、Quote-Product、Order-Project不是批量删除中选择多个记录,则删除需要将近 35 到 40 秒

CRM 2015 - 如果我从 Project-Product、Quote-Product、Order-Project不是批量删除中选择多个记录,则删除需要将近 35 到 40 秒

如何解决CRM 2015 - 如果我从 Project-Product、Quote-Product、Order-Project不是批量删除中选择多个记录,则删除需要将近 35 到 40 秒

在 CRM 2015 中,从项目产品、报价产品或订单产品列表中删除超过 5 条记录需要 35 到 40 秒。这不是批量删除。

有时我会在删除过程之间看到下面的无响应/等待屏幕。

如何解决这个问题或减少时间?

解决方法

由于包括重新计算父订单值在内的内部流程,删除订单产品等子记录可能需要一段时间。

当您删除单个订单产品时,系统会重新计算父订单的总数等。每个记录都会发生这种情况,删除多条记录当然需要更长的时间。

可能还会发生其他进程 - 自定义进程或系统进程。您可以检查是否有任何自定义的,但系统进程很大程度上是一个黑匣子。

我见过客户偶尔需要创建超过 10,000 行的发票的情况。由于创建每一行会触发重新计算,因此正常的自动化选项会超时。我最终创建了一个控制台应用程序,将这些行分批添加到怪物发票中。

javascript-TinyMCE将HREF从“ / category / product-name”更改为“ ../../../../category/product-name”

javascript-TinyMCE将HREF从“ / category / product-name”更改为“ ../../../../category/product-name”

我已经使用TinyMCE已有一段时间了,以前没有遇到过此问题.尽管每次我尝试向文本添加href链接时,它都会添加不需要的“ ../”.也许这是一个普遍的问题,但我不知道您将其称为“ ../”还是返回目录

convert_urls: false,
relative_urls: false

解决方法:

您想看一下有关配置TinyMCE是否使用相对链接的文章:

http://tinymce.moxiecode.com/tryit/url_conversion.php

它涵盖了许多不同的选择

我们今天的关于Python numpy 模块-product() 实例源码python的numpy模块的分享就到这里,谢谢您的阅读,如果想了解更多关于Android AOSP 构建错误 mkbootimg --kernel out/target/product/xiaomi/kernel 而不是 mkbootimg --kernel out/target/product/xiaomi/boot.img、Commerce Cloud 里的 Product Catalog 和 Product Categories 的联系、CRM 2015 - 如果我从 Project-Product、Quote-Product、Order-Project不是批量删除中选择多个记录,则删除需要将近 35 到 40 秒、javascript-TinyMCE将HREF从“ / category / product-name”更改为“ ../../../../category/product-name”的相关信息,可以在本站进行搜索。

本文标签: