报错compile_str() flow.php on line 375的解决方法

本文讨论了ECShop中关于收货人信息处理的改进,特别关注了一个名为compile_str的函数,其目的是为了防止script攻击并过滤用户输入。通过分析原始代码,解释了为何需要这个函数以及如何正确实现,确保网站的安全性和用户体验。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

flow.php line 375,flow.php  找到375行:

         * 保存收货人信息
         */
        $consignee = array(
            'address_id'    => empty($_POST['address_id']) ? 0  :   intval($_POST['address_id']),
            'consignee'     => empty($_POST['consignee'])  ? '' :   compile_str(trim($_POST['consignee'])),
            'country'       => empty($_POST['country'])    ? '' :   intval($_POST['country']),
            'province'      => empty($_POST['province'])   ? '' :   intval($_POST['province']),
            'city'          => empty($_POST['city'])       ? '' :   intval($_POST['city']),
            'district'      => empty($_POST['district'])   ? '' :   intval($_POST['district']),
            'email'         => empty($_POST['email'])      ? '' :   compile_str($_POST['email']),
            'address'       => empty($_POST['address'])    ? '' :   compile_str($_POST['address']),
            'zipcode'       => empty($_POST['zipcode'])    ? '' :   compile_str(make_semiangle(trim($_POST['zipcode']))),
            'tel'           => empty($_POST['tel'])        ? '' :   compile_str(make_semiangle(trim($_POST['tel']))),
            'mobile'        => empty($_POST['mobile'])     ? '' :   compile_str(make_semiangle(trim($_POST['mobile']))),
            'sign_building' => empty($_POST['sign_building']) ? '' :compile_str($_POST['sign_building']),
            'best_time'     => empty($_POST['best_time'])  ? '' :   compile_str($_POST['best_time']),
        );

这里代码多了个函数 compile_str。 改函数是ecshop最新补丁新加入进入的。原本的这块代码是

           'address_id'    => empty($_POST['address_id']) ? 0  : intval($_POST['address_id']),
            'consignee'     => empty($_POST['consignee'])  ? '' : trim($_POST['consignee']),
            'country'       => empty($_POST['country'])    ? '' : $_POST['country'],
            'province'      => empty($_POST['province'])   ? '' : $_POST['province'],
            'city'          => empty($_POST['city'])       ? '' : $_POST['city'],
            'district'      => empty($_POST['district'])   ? '' : $_POST['district'],
            'email'         => empty($_POST['email'])      ? '' : $_POST['email'],
            'address'       => empty($_POST['address'])    ? '' : $_POST['address'],
            'zipcode'       => empty($_POST['zipcode'])    ? '' : make_semiangle(trim($_POST['zipcode'])),
            'tel'           => empty($_POST['tel'])        ? '' : make_semiangle(trim($_POST['tel'])),
            'mobile'        => empty($_POST['mobile'])     ? '' : make_semiangle(trim($_POST['mobile'])),
            'sign_building' => empty($_POST['sign_building']) ? '' : $_POST['sign_building'],
            'best_time'     => empty($_POST['best_time'])  ? '' : $_POST['best_time'],

该函数是为补漏洞的。 在文件lib_base.php 776行。

/**
 * 过滤用户输入的基本数据,防止script攻击
 *
 * @access      public
 * @return      string
 */
function compile_str($str)
{
    $arr = array('<' => '<', '>' => '>');
    return strtr($str, $arr);
}
该函数是为补漏洞的。 过滤用户输入的基本数据,防止script攻击!所以如果网站提示缺少此函数,直接补个函数就可以了。贴在flow.php底部,问题就解决了
Traceback (most recent call last): File "/home/vuxuanni/code/Compaired-HIT-IIL/train_fivek_skff_no_patches.py", line 123, in <module> train() File "/home/vuxuanni/code/Compaired-HIT-IIL/train_fivek_skff_no_patches.py", line 67, in train GCMModel_out_warp, rgb_mask, raw_demosaic_warp, raw_demosaic_mask = get_backwarp(x, GCMModel_out, target, File "/home/vuxuanni/code/Compaired-HIT-IIL/model/warp_modules.py", line 65, in get_backwarp flow = get_flow(tenFirst, tenSecond, net) File "/home/vuxuanni/code/Compaired-HIT-IIL/model/warp_modules.py", line 82, in get_flow flow = estimate(tenFirst, tenSecond, net) File "/home/vuxuanni/code/Compaired-HIT-IIL/model/warp_modules.py", line 33, in estimate input=net(tenPreprocessedFirst, tenPreprocessedSecond), File "/home/vuxuanni/.conda/envs/yxn_pytorch_1/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) File "/home/vuxuanni/.conda/envs/yxn_pytorch_1/lib/python3.8/site-packages/torch/nn/parallel/data_parallel.py", line 166, in forward return self.module(*inputs[0], **kwargs[0]) File "/home/vuxuanni/.conda/envs/yxn_pytorch_1/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) File "/home/vuxuanni/code/Compaired-HIT-IIL/pwc_net/pwc_net.py", line 270, in forward objEstimate = self.netSix(tenFirst[-1], tenSecond[-1], None) File "/home/vuxuanni/.conda/envs/yxn_pytorch_1/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) File "/home/vuxuanni/code/Compaired-HIT-IIL/pwc_net/pwc_net.py", line 147, in forward tenVolume = torch.nn.functional.leaky_relu(input=correlation.FunctionCorrelation( File "/home/vuxuanni/code/Compaired-HIT-IIL/pwc_net/correlation/correlation.py", line 418, in FunctionCorrelation return _FunctionCorrelation.apply(tenFirst, tenSecond) File "/home/vuxuanni/code/Compaired-HIT-IIL/pwc_net/correlation/correlation.py", line 336, in forward cupy_launch('kernel_Correlation_updateOutput', cupy_kernel('kernel_Correlation_updateOutput', { File "cupy/_util.pyx", line 64, in cupy._util.memoize.decorator.ret File "/home/vuxuanni/code/Compaired-HIT-IIL/pwc_net/correlation/correlation.py", line 297, in cupy_launch return module.get_function(strFunction) File "cupy/_core/raw.pyx", line 485, in cupy._core.raw.RawModule.get_function File "cupy/_core/raw.pyx", line 96, in cupy._core.raw.RawKernel.kernel.__get__ File "cupy/_core/raw.pyx", line 113, in cupy._core.raw.RawKernel._kernel File "cupy/_util.pyx", line 64, in cupy._util.memoize.decorator.ret File "cupy/_core/raw.pyx", line 536, in cupy._core.raw._get_raw_module File "cupy/_core/core.pyx", line 2188, in cupy._core.core.compile_with_cache File "cupy/_core/core.pyx", line 2251, in cupy._core.core.compile_with_cache File "/home/vuxuanni/.conda/envs/yxn_pytorch_1/lib/python3.8/site-packages/cupy/cuda/compiler.py", line 496, in _compile_module_with_cache return _compile_with_cache_cuda( File "/home/vuxuanni/.conda/envs/yxn_pytorch_1/lib/python3.8/site-packages/cupy/cuda/compiler.py", line 618, in _compile_with_cache_cuda mod.load(cubin) File "cupy/cuda/function.pyx", line 263, in cupy.cuda.function.Module.load File "cupy/cuda/function.pyx", line 265, in cupy.cuda.function.Module.load File "cupy_backends/cuda/api/driver.pyx", line 210, in cupy_backends.cuda.api.driver.moduleLoadData File "cupy_backends/cuda/api/driver.pyx", line 60, in cupy_backends.cuda.api.driver.check_status cupy_backends.cuda.api.driver.CUDADriverError: CUDA_ERROR_ILLEGAL_ADDRESS: an illegal memory access was encountered Traceback (most recent call last): File "cupy_backends/cuda/api/driver.pyx", line 217, in cupy_backends.cuda.api.driver.moduleUnload File "cupy_backends/cuda/api/driver.pyx", line 60, in cupy_backends.cuda.api.driver.check_status cupy_backends.cuda.api.driver.CUDADriverError: CUDA_ERROR_ILLEGAL_ADDRESS: an illegal memory access was encountered Exception ignored in: 'cupy.cuda.function.Module.__dealloc__' Traceback (most recent call last): File "cupy_backends/cuda/api/driver.pyx", line 217, in cupy_backends.cuda.api.driver.moduleUnload File "cupy_backends/cuda/api/driver.pyx", line 60, in cupy_backends.cuda.api.driver.check_status cupy_backends.cuda.api.driver.CUDADriverError: CUDA_ERROR_ILLEGAL_ADDRESS: an illegal memory access was encountered Process finished with exit code 1
最新发布
08-06
/home/vuxuanni/.conda/envs/yxn_pytorch_1/bin/python /home/vuxuanni/code/Compaired-HIT-IIL/train_fivek_skff_no_patches.py CUDA visible devices: 4 CUDA Device Name: NVIDIA GeForce RTX 3090 batch_size:1 Total_params: 8946598 length of dataset:10 Train loader length: 10 /home/vuxuanni/.conda/envs/yxn_pytorch_1/lib/python3.8/site-packages/cupy/cuda/compiler.py:464: UserWarning: cupy.cuda.compile_with_cache has been deprecated in CuPy v10, and will be removed in the future. Use cupy.RawModule or cupy.RawKernel instead. warnings.warn( Traceback (most recent call last): File "/home/vuxuanni/code/Compaired-HIT-IIL/train_fivek_skff_no_patches.py", line 123, in <module> train() File "/home/vuxuanni/code/Compaired-HIT-IIL/train_fivek_skff_no_patches.py", line 67, in train GCMModel_out_warp, rgb_mask, raw_demosaic_warp, raw_demosaic_mask = get_backwarp(x, GCMModel_out, target, File "/home/vuxuanni/code/Compaired-HIT-IIL/model/warp_modules.py", line 65, in get_backwarp flow = get_flow(tenFirst, tenSecond, net) File "/home/vuxuanni/code/Compaired-HIT-IIL/model/warp_modules.py", line 82, in get_flow flow = estimate(tenFirst, tenSecond, net) File "/home/vuxuanni/code/Compaired-HIT-IIL/model/warp_modules.py", line 33, in estimate input=net(tenPreprocessedFirst, tenPreprocessedSecond), File "/home/vuxuanni/.conda/envs/yxn_pytorch_1/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) File "/home/vuxuanni/.conda/envs/yxn_pytorch_1/lib/python3.8/site-packages/torch/nn/parallel/data_parallel.py", line 166, in forward return self.module(*inputs[0], **kwargs[0]) File "/home/vuxuanni/.conda/envs/yxn_pytorch_1/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) File "/home/vuxuanni/code/Compaired-HIT-IIL/pwc_net/pwc_net.py", line 270, in forward objEstimate = self.netSix(tenFirst[-1], tenSecond[-1], None) File "/home/vuxuanni/.conda/envs/yxn_pytorch_1/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) File "/home/vuxuanni/code/Compaired-HIT-IIL/pwc_net/pwc_net.py", line 147, in forward tenVolume = torch.nn.functional.leaky_relu(input=correlation.FunctionCorrelation( File "/home/vuxuanni/code/Compaired-HIT-IIL/pwc_net/correlation/correlation.py", line 398, in FunctionCorrelation return _FunctionCorrelation.apply(tenFirst, tenSecond) File "/home/vuxuanni/code/Compaired-HIT-IIL/pwc_net/correlation/correlation.py", line 316, in forward cupy_launch('kernel_Correlation_updateOutput', cupy_kernel('kernel_Correlation_updateOutput', { File "cupy/_util.pyx", line 64, in cupy._util.memoize.decorator.ret File "/home/vuxuanni/code/Compaired-HIT-IIL/pwc_net/correlation/correlation.py", line 276, in cupy_launch return cupy.cuda.compile_with_cache(strKernel).get_function(strFunction) File "/home/vuxuanni/.conda/envs/yxn_pytorch_1/lib/python3.8/site-packages/cupy/cuda/compiler.py", line 468, in compile_with_cache return _compile_module_with_cache(*args, **kwargs) File "/home/vuxuanni/.conda/envs/yxn_pytorch_1/lib/python3.8/site-packages/cupy/cuda/compiler.py", line 496, in _compile_module_with_cache return _compile_with_cache_cuda( File "/home/vuxuanni/.conda/envs/yxn_pytorch_1/lib/python3.8/site-packages/cupy/cuda/compiler.py", line 565, in _compile_with_cache_cuda mod.load(cubin) File "cupy/cuda/function.pyx", line 263, in cupy.cuda.function.Module.load File "cupy/cuda/function.pyx", line 265, in cupy.cuda.function.Module.load File "cupy_backends/cuda/api/driver.pyx", line 210, in cupy_backends.cuda.api.driver.moduleLoadData File "cupy_backends/cuda/api/driver.pyx", line 60, in cupy_backends.cuda.api.driver.check_status cupy_backends.cuda.api.driver.CUDADriverError: CUDA_ERROR_ILLEGAL_ADDRESS: an illegal memory access was encountered Traceback (most recent call last): File "cupy_backends/cuda/api/driver.pyx", line 217, in cupy_backends.cuda.api.driver.moduleUnload File "cupy_backends/cuda/api/driver.pyx", line 60, in cupy_backends.cuda.api.driver.check_status cupy_backends.cuda.api.driver.CUDADriverError: CUDA_ERROR_ILLEGAL_ADDRESS: an illegal memory access was encountered Exception ignored in: 'cupy.cuda.function.Module.__dealloc__' Traceback (most recent call last): File "cupy_backends/cuda/api/driver.pyx", line 217, in cupy_backends.cuda.api.driver.moduleUnload File "cupy_backends/cuda/api/driver.pyx", line 60, in cupy_backends.cuda.api.driver.check_status cupy_backends.cuda.api.driver.CUDADriverError: CUDA_ERROR_ILLEGAL_ADDRESS: an illegal memory access was encountered 如何解决该问题
08-05
def main(): t0 = time.time() ​ # 选择模型 model = build_lstm_model() ​ # 编译模型 model.compile(optimizer=tf.keras.optimizers.Adam(0.001), loss=tf.keras.losses.BinaryCrossentropy(), metrics=['accuracy']) ​ # 训练模型 checkpoint = ModelCheckpoint('model_checkpoint.h5', save_weights_only=True, verbose=1, save_freq='epoch') model.fit(x_train, y_train, batch_size=batch_size, epochs=epochs, callbacks=[checkpoint]) ​ # 评估模型 loss, accuracy = model.evaluate(x_test, y_test) print(f"Test Loss: {loss}, Test Accuracy: {accuracy}") ​ t1 = time.time() print(f"模型运行的时间为:{t1 - t0:.2f} 秒") ​ if __name__ == '__main__': main() 10秒 WARNING:tensorflow:From /opt/conda/lib/python3.8/site-packages/tensorflow_core/python/keras/initializers.py:118: calling RandomUniform.__init__ (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version. Instructions for updating: Call initializer instance with the dtype argument instead of passing it to the constructor WARNING:tensorflow:From /opt/conda/lib/python3.8/site-packages/tensorflow_core/python/ops/resource_variable_ops.py:1623: calling BaseResourceVariable.__init__ (from tensorflow.python.ops.resource_variable_ops) with constraint is deprecated and will be removed in a future version. Instructions for updating: If using Keras pass *_constraint arguments to layers. NotImplementedError: Cannot convert a symbolic Tensor (lstm/strided_slice:0) to a numpy array. --------------------------------------------------------------------------- NotImplementedError Traceback (most recent call last) Cell In[21], line 24 21 print(f"模型运行的时间为:{t1 - t0:.2f} 秒") 23 if __name__ == '__main__': ---> 24 main() Cell In[21], line 5, in main() 2 t0 = time.time() 4 # 选择模型 ----> 5 model = build_lstm_model() 7 # 编译模型 8 model.compile(optimizer=tf.keras.optimizers.Adam(0.001), 9 loss=tf.keras.losses.BinaryCrossentropy(), 10 metrics=['accuracy']) Cell In[15], line 4, in build_lstm_model() 3 def build_lstm_model(): ----> 4 model = keras.Sequential([ 5 layers.Embedding(total_words, embedding_len, input_length=max_review_len), 6 layers.LSTM(64, return_sequences=False), 7 layers.Dense(1, activation='sigmoid') 8 ]) 9 return model File /opt/conda/lib/python3.8/site-packages/tensorflow_core/python/training/tracking/base.py:457, in no_automatic_dependency_tracking.<locals>._method_wrapper(self, *args, **kwargs) 455 self._self_setattr_tracking = False # pylint: disable=protected-access 456 try: --> 457 result = method(self, *args, **kwargs) 458 finally: 459 self._self_setattr_tracking = previous_value # pylint: disable=protected-access File /opt/conda/lib/python3.8/site-packages/tensorflow_core/python/keras/engine/sequential.py:113, in Sequential.__init__(self, layers, name) 111 tf_utils.assert_no_legacy_layers(layers) 112 for layer in layers: --> 113 self.add(layer) File /opt/conda/lib/python3.8/site-packages/tensorflow_core/python/training/tracking/base.py:457, in no_automatic_dependency_tracking.<locals>._method_wrapper(self, *args, **kwargs) 455 self._self_setattr_tracking = False # pylint: disable=protected-access 456 try: --> 457 result = method(self, *args, **kwargs) 458 finally: 459 self._self_setattr_tracking = previous_value # pylint: disable=protected-access File /opt/conda/lib/python3.8/site-packages/tensorflow_core/python/keras/engine/sequential.py:195, in Sequential.add(self, layer) 190 self.inputs = layer_utils.get_source_inputs(self.outputs[0]) 192 elif self.outputs: 193 # If the model is being built continuously on top of an input layer: 194 # refresh its output. --> 195 output_tensor = layer(self.outputs[0]) 196 if len(nest.flatten(output_tensor)) != 1: 197 raise TypeError('All layers in a Sequential model ' 198 'should have a single output tensor. ' 199 'For multi-output layers, ' 200 'use the functional API.') File /opt/conda/lib/python3.8/site-packages/tensorflow_core/python/keras/layers/recurrent.py:623, in RNN.__call__(self, inputs, initial_state, constants, **kwargs) 617 inputs, initial_state, constants = _standardize_args(inputs, 618 initial_state, 619 constants, 620 self._num_constants) 622 if initial_state is None and constants is None: --> 623 return super(RNN, self).__call__(inputs, **kwargs) 625 # If any of `initial_state` or `constants` are specified and are Keras 626 # tensors, then add them to the inputs and temporarily modify the 627 # input_spec to include them. 629 additional_inputs = [] File /opt/conda/lib/python3.8/site-packages/tensorflow_core/python/keras/engine/base_layer.py:854, in Layer.__call__(self, inputs, *args, **kwargs) 852 outputs = base_layer_utils.mark_as_return(outputs, acd) 853 else: --> 854 outputs = call_fn(cast_inputs, *args, **kwargs) 856 except errors.OperatorNotAllowedInGraphError as e: 857 raise TypeError('You are attempting to use Python control ' 858 'flow in a layer that was not declared to be ' 859 'dynamic. Pass `dynamic=True` to the class ' 860 'constructor.\nEncountered error:\n"""\n' + 861 str(e) + '\n"""') File /opt/conda/lib/python3.8/site-packages/tensorflow_core/python/keras/layers/recurrent.py:2548, in LSTM.call(self, inputs, mask, training, initial_state) 2546 self.cell.reset_dropout_mask() 2547 self.cell.reset_recurrent_dropout_mask() -> 2548 return super(LSTM, self).call( 2549 inputs, mask=mask, training=training, initial_state=initial_state) File /opt/conda/lib/python3.8/site-packages/tensorflow_core/python/keras/layers/recurrent.py:681, in RNN.call(self, inputs, mask, training, initial_state, constants) 675 def call(self, 676 inputs, 677 mask=None, 678 training=None, 679 initial_state=None, 680 constants=None): --> 681 inputs, initial_state, constants = self._process_inputs( 682 inputs, initial_state, constants) 684 if mask is not None: 685 # Time step masks must be the same for each input. 686 # TODO(scottzhu): Should we accept multiple different masks? 687 mask = nest.flatten(mask)[0] File /opt/conda/lib/python3.8/site-packages/tensorflow_core/python/keras/layers/recurrent.py:798, in RNN._process_inputs(self, inputs, initial_state, constants) 796 initial_state = self.states 797 else: --> 798 initial_state = self.get_initial_state(inputs) 800 if len(initial_state) != len(self.states): 801 raise ValueError('Layer has ' + str(len(self.states)) + 802 ' states but was passed ' + str(len(initial_state)) + 803 ' initial states.') File /opt/conda/lib/python3.8/site-packages/tensorflow_core/python/keras/layers/recurrent.py:605, in RNN.get_initial_state(self, inputs) 603 dtype = inputs.dtype 604 if get_initial_state_fn: --> 605 init_state = get_initial_state_fn( 606 inputs=None, batch_size=batch_size, dtype=dtype) 607 else: 608 init_state = _generate_zero_filled_state(batch_size, self.cell.state_size, 609 dtype) File /opt/conda/lib/python3.8/site-packages/tensorflow_core/python/keras/layers/recurrent.py:2313, in LSTMCell.get_initial_state(self, inputs, batch_size, dtype) 2312 def get_initial_state(self, inputs=None, batch_size=None, dtype=None): -> 2313 return list(_generate_zero_filled_state_for_cell( 2314 self, inputs, batch_size, dtype)) File /opt/conda/lib/python3.8/site-packages/tensorflow_core/python/keras/layers/recurrent.py:2752, in _generate_zero_filled_state_for_cell(cell, inputs, batch_size, dtype) 2750 batch_size = array_ops.shape(inputs)[0] 2751 dtype = inputs.dtype -> 2752 return _generate_zero_filled_state(batch_size, cell.state_size, dtype) File /opt/conda/lib/python3.8/site-packages/tensorflow_core/python/keras/layers/recurrent.py:2768, in _generate_zero_filled_state(batch_size_tensor, state_size, dtype) 2765 return array_ops.zeros(init_state_size, dtype=dtype) 2767 if nest.is_sequence(state_size): -> 2768 return nest.map_structure(create_zeros, state_size) 2769 else: 2770 return create_zeros(state_size) File /opt/conda/lib/python3.8/site-packages/tensorflow_core/python/util/nest.py:536, in map_structure(func, *structure, **kwargs) 532 flat_structure = [flatten(s, expand_composites) for s in structure] 533 entries = zip(*flat_structure) 535 return pack_sequence_as( --> 536 structure[0], [func(*x) for x in entries], 537 expand_composites=expand_composites) File /opt/conda/lib/python3.8/site-packages/tensorflow_core/python/util/nest.py:536, in <listcomp>(.0) 532 flat_structure = [flatten(s, expand_composites) for s in structure] 533 entries = zip(*flat_structure) 535 return pack_sequence_as( --> 536 structure[0], [func(*x) for x in entries], 537 expand_composites=expand_composites) File /opt/conda/lib/python3.8/site-packages/tensorflow_core/python/keras/layers/recurrent.py:2765, in _generate_zero_filled_state.<locals>.create_zeros(unnested_state_size) 2763 flat_dims = tensor_shape.as_shape(unnested_state_size).as_list() 2764 init_state_size = [batch_size_tensor] + flat_dims -> 2765 return array_ops.zeros(init_state_size, dtype=dtype) File /opt/conda/lib/python3.8/site-packages/tensorflow_core/python/ops/array_ops.py:2338, in zeros(shape, dtype, name) 2334 if not isinstance(shape, ops.Tensor): 2335 try: 2336 # Create a constant if it won't be very big. Otherwise create a fill op 2337 # to prevent serialized GraphDefs from becoming too large. -> 2338 output = _constant_if_small(zero, shape, dtype, name) 2339 if output is not None: 2340 return output File /opt/conda/lib/python3.8/site-packages/tensorflow_core/python/ops/array_ops.py:2295, in _constant_if_small(value, shape, dtype, name) 2293 def _constant_if_small(value, shape, dtype, name): 2294 try: -> 2295 if np.prod(shape) < 1000: 2296 return constant(value, shape=shape, dtype=dtype, name=name) 2297 except TypeError: 2298 # Happens when shape is a Tensor, list with Tensor elements, etc. File <__array_function__ internals>:180, in prod(*args, **kwargs) File /opt/conda/lib/python3.8/site-packages/numpy/core/fromnumeric.py:3088, in prod(a, axis, dtype, out, keepdims, initial, where) 2970 @array_function_dispatch(_prod_dispatcher) 2971 def prod(a, axis=None, dtype=None, out=None, keepdims=np._NoValue, 2972 initial=np._NoValue, where=np._NoValue): 2973 """ 2974 Return the product of array elements over a given axis. 2975 (...) 3086 10 3087 """ -> 3088 return _wrapreduction(a, np.multiply, 'prod', axis, dtype, out, 3089 keepdims=keepdims, initial=initial, where=where) File /opt/conda/lib/python3.8/site-packages/numpy/core/fromnumeric.py:86, in _wrapreduction(obj, ufunc, method, axis, dtype, out, **kwargs) 83 else: 84 return reduction(axis=axis, out=out, **passkwargs) ---> 86 return ufunc.reduce(obj, axis, dtype, out, **passkwargs) File /opt/conda/lib/python3.8/site-packages/tensorflow_core/python/framework/ops.py:735, in Tensor.__array__(self) 734 def __array__(self): --> 735 raise NotImplementedError("Cannot convert a symbolic Tensor ({}) to a numpy" 736 " array.".format(self.name)) NotImplementedError: Cannot convert a symbolic Tensor (lstm/strided_slice:0) to a numpy array.
06-22
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值