在XGBoost指南的链接上,
bst.save_model('0001.model')
bst.dump_model('dump.raw.txt') # dump model
bst.dump_model('dump.raw.txt','featmap.txt')# dump model with feature map
bst = xgb.Booster({'nthread':4}) #init model
bst.load_model("model.bin") # load data
我的问题是:
save_model&之间有什么区别dump_model?'0001.model'和'dump.raw.txt','featmap.txt'?之间的区别是什么?model.bin与要保存的名称不同0001.model?model_A和model_B,我想保存这两种模式以供将来使用,这save和load我应该使用功能?你能帮忙展示清楚的过程吗?我正在尝试使用Keras重现实体嵌入模型.这是github链接并使用kaggle分支.有一个python文件,models.py并使用该Merge层.
from keras.layers.core import Dense, Dropout, Activation, Merge, Reshape
......
self.model.add(Merge(models, mode='concat'))
这段代码应该适用于旧版本的Keras,但是使用使用tensorflow 1.0.0作为后端(python 2.7)的Keras 2.0.0,会有错误的信息:
Using TensorFlow backend.
Traceback (most recent call last):
File "/Users/pengjuzhao/Udacity/MLND/entity-embedding-rossmann/test_model.py", line 2, in <module>
from models import NN_with_EntityEmbedding
File "/Users/pengjuzhao/Udacity/MLND/entity-embedding-rossmann/models.py", line 8, in <module>
from keras.layers.core import Dense, Dropout, Activation, Merge, Reshape
ImportError: cannot import name Merge
[Finished in 1.8s with exit code 1]
[shell_cmd: python -u "/Users/pengjuzhao/Udacity/MLND/entity-embedding-rossmann/test_model.py"]
[dir: /Users/pengjuzhao/Udacity/MLND/entity-embedding-rossmann]
[path: /usr/bin:/bin:/usr/sbin:/sbin]
有没有人知道如何self.model.add(Merge(models, mode='concat'))使用Keras …
std::string file="C:\\folder1\\folder2\\folder3.txt";
fs::path file_path(file);
fs::path file_dir=file_path.parent_path();// "C:\\folder1\\folder2";
std::string str_path=file_path.string();
std::string str_dir=file_dir.string();
std:string str_folder=str_path.erase(0,str_dir()+1);// return folder2
Run Code Online (Sandbox Code Playgroud)
这是我使用的方法。它对我有用,但看起来很难看。所以我更喜欢寻找 boost::filesystems 或其他优雅的代码。注意:这个问题不重复,与提出的问题Get a directory name from a filename略有不同 。我的兴趣是找到文件名而不是整个目录路径。