如果我运行此代码两次:
tf.flags.DEFINE_integer("batch_size", "2", "batch size for training")
Run Code Online (Sandbox Code Playgroud)
我会收到这个错误:
DuplicateFlagError: The flag 'batch_size' is defined twice. First from D:/Python/workspace/FCN_dataset/FCN.tensorflow-master/FCN.py, Second from D:/Python/workspace/FCN_dataset/FCN.tensorflow-master/FCN.py. Description from first occurrence: batch size for training
Run Code Online (Sandbox Code Playgroud)
我知道这是因为我重新定义了flag的默认值.那么如何清除标志或允许重新定义标志的默认值呢?
像这样:
typeArray type[2] = {uint8_t, uint16_t};
for (int i=0; i < 2; i++)
{
myFunction<type[i]>();
}
Run Code Online (Sandbox Code Playgroud)
我认为这是不可能实现的,因为它违反了 C++ 中的一些规则。但我不确定,我也不熟悉 C++ 的新特性(11 14 17 等)。所以有人可以告诉我答案吗?
更加具体。
\\ Such as I have a template functon "PrintSecondTypeLen"
template<typename Type>PrintSecondTypeLen(unsigned int *a)
{
Type *b;
b = (Type *) a;
std::cout << *(b+1) << std::endl;
}
\\ Then suppose that I have a typeArray.
typeArray type[2] = {uint8_t, uint16_t}; \\ It's wrong, just for example.
\\ Then I use it:
unsigned int a[2] = …Run Code Online (Sandbox Code Playgroud) 我尝试将 python 脚本添加到我的包中,参考这两个教程。
所以我在 root 中添加了 setup.py ,test\src\test_pkg在 path 中更改了 CMakeLists.txt test\src。(我的包根路径是test\,我的包路径是test\src\test_pkg,我的python脚本路径是test\src\test_pkg\scripts)
这是 setup.py。
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup
setup_args = generate_distutils_setup(
packages=['test_pkg'],
scripts=['/scripts'],
package_dir={'': 'src'}
)
setup(**setup_args)
Run Code Online (Sandbox Code Playgroud)
这是 CMakeLists.txt
cmake_minimum_required(VERSION 2.8.3)
project(test_pkg)
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
sensor_msgs
message_generation
)
catkin_python_setup()
catkin_install_python(PROGRAMS scripts/talker
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
add_message_files(
FILES
Num.msg
)
add_service_files(
FILES
AddTwoInts.srv
)
generate_messages( …Run Code Online (Sandbox Code Playgroud)