我有一个设置,我需要在主要初始化后使用初始化LSTM tf.initialize_all_variables()
.即我想打电话tf.initialize_variables([var_list])
有没有办法收集所有内部可训练变量:
这样我可以初始化JUST这些参数吗?
我想要这个的主要原因是因为我不想重新初始化一些训练过的值.
所以我想使用Boost.Log进行所有日志记录.我目前编写了一个包含实例化和设置辅助方法所需的所有操作的类.
问题是我想重载<<运算符以cout方式使用它.我希望能够使用它来使不同的参数类型似乎是最大的问题.
这是我试过的:
template <typename T>
void trace::operator <<(T data)
{
std::string text=boost::lexical_cast<std::string>(data);
std::cout<<data<<std::endl;
BOOST_LOG_TRIVIAL(debug) << text;
}
Run Code Online (Sandbox Code Playgroud)
但是,据我所知,这在逻辑上有点瑕疵.为了能够将多个args传递给<<它需要递归.但我有点困惑如何用升压日志来做这件事.
我是否必须使用自定义接收器而不是方便的boost宏来定义日志系统?如果是这样支持std :: ostream返回?我猜这将是返回值和流中的输入值.
我有一个以下时间格式的字符串:
"%Y-%m-%d %H:%M:%S.%f"
其中%f是毫秒,例如: 14:31:23.946571
我希望这是一个chrono time_point
.有演员这样做吗?
我如何从boost :: chrono :: steady_clock :: now()获得double值?我不相信这有一个.count()参数.
我为什么需要这个?我有一个方法无法解析提升返回.
因此,在你向我开枪告诉我这是一件非常糟糕的事情之前,我只是想表明我想知道这只是为了好奇和可能的代码减少.我想有一个基类来实现派生类的单例.但是,这样做会导致派生类丢失数据.如何根据派生类获取基类来实现单例.例如:
class Application{
public:
/**
* @brief instance: C++11 [If control enters the declaration concurrently while the variable is being initialized,
*the concurrent execution shall wait for completion of the initialization.—§6.7 [stmt.dcl] p4]
* @return handle to application
*/
static Application& instance(){
static Application s_Application;
return s_Application;
}
void setName(std::string Name){
AppName=Name;
}
std::string getName(){
return AppName;
}
virtual ~Application(){ }
private:
Application(){}
std::string AppName;
};
Run Code Online (Sandbox Code Playgroud)
现在我创建一个继承自Application的派生类:
class Test:public Application{
public:
void printer(std::string test){
std::cout<<"test\n";
}
};
int main(int argc, …
Run Code Online (Sandbox Code Playgroud) c++ ×4
boost ×2
boost-log ×1
c++-chrono ×1
c++11 ×1
casting ×1
inheritance ×1
python ×1
singleton ×1
tensorflow ×1