зеркало из https://github.com/microsoft/caffe.git
bugfix and made the C++ interface for creating leveldb
This commit is contained in:
Родитель
0d752824e8
Коммит
cf301543fb
|
@ -44,7 +44,7 @@ MKL_LIB_DIR := $(MKL_DIR)/lib $(MKL_DIR)/lib/intel64
|
||||||
INCLUDE_DIRS := ./src ./include /u/vis/software/include /usr/local/include $(CUDA_INCLUDE_DIR) $(MKL_INCLUDE_DIR)
|
INCLUDE_DIRS := ./src ./include /u/vis/software/include /usr/local/include $(CUDA_INCLUDE_DIR) $(MKL_INCLUDE_DIR)
|
||||||
LIBRARY_DIRS := /usr/lib /u/vis/software/lib /usr/local/lib $(CUDA_LIB_DIR) $(MKL_LIB_DIR)
|
LIBRARY_DIRS := /usr/lib /u/vis/software/lib /usr/local/lib $(CUDA_LIB_DIR) $(MKL_LIB_DIR)
|
||||||
LIBRARIES := cudart cublas protobuf glog mkl_rt curand \
|
LIBRARIES := cudart cublas protobuf glog mkl_rt curand \
|
||||||
leveldb snappy pthread
|
leveldb snappy pthread opencv_core opencv_highgui
|
||||||
WARNINGS := -Wall
|
WARNINGS := -Wall
|
||||||
|
|
||||||
COMMON_FLAGS := $(foreach includedir,$(INCLUDE_DIRS),-I$(includedir))
|
COMMON_FLAGS := $(foreach includedir,$(INCLUDE_DIRS),-I$(includedir))
|
||||||
|
|
|
@ -31,7 +31,7 @@ using std::stringstream;
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
::google::InitGoogleLogging(argv[0]);
|
::google::InitGoogleLogging(argv[0]);
|
||||||
std::ifstream infile(argv[2]);
|
std::ifstream infile(argv[2]);
|
||||||
vector<pair<string, int> > lines;
|
std::vector<std::pair<string, int> > lines;
|
||||||
string filename;
|
string filename;
|
||||||
int label;
|
int label;
|
||||||
while (infile >> filename >> label) {
|
while (infile >> filename >> label) {
|
||||||
|
|
|
@ -53,7 +53,7 @@ int main(int argc, char** argv) {
|
||||||
SolverParameter solver_param;
|
SolverParameter solver_param;
|
||||||
// Solver Parameters are hard-coded in this case, but you can write a
|
// Solver Parameters are hard-coded in this case, but you can write a
|
||||||
// SolverParameter protocol buffer to specify all these values.
|
// SolverParameter protocol buffer to specify all these values.
|
||||||
solver_param.set_base_lr(0.01);
|
solver_param.set_base_lr(0.001);
|
||||||
solver_param.set_display(100);
|
solver_param.set_display(100);
|
||||||
solver_param.set_max_iter(5000);
|
solver_param.set_max_iter(5000);
|
||||||
solver_param.set_lr_policy("inv");
|
solver_param.set_lr_policy("inv");
|
||||||
|
|
|
@ -22,8 +22,7 @@ int main(int argc, char** argv) {
|
||||||
leveldb::Iterator* it = db->NewIterator(read_options);
|
leveldb::Iterator* it = db->NewIterator(read_options);
|
||||||
for (it->SeekToFirst(); it->Valid(); it->Next()) {
|
for (it->SeekToFirst(); it->Valid(); it->Next()) {
|
||||||
// just a dummy operation
|
// just a dummy operation
|
||||||
it->value().ToString();
|
LOG(ERROR) << it->key().ToString();
|
||||||
// LOG(ERROR) << it->key().ToString();
|
|
||||||
if (++count % 10000 == 0) {
|
if (++count % 10000 == 0) {
|
||||||
LOG(ERROR) << "Processed " << count << " files.";
|
LOG(ERROR) << "Processed " << count << " files.";
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,9 @@ void BNLLLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom,
|
||||||
Dtype* top_data = (*top)[0]->mutable_cpu_data();
|
Dtype* top_data = (*top)[0]->mutable_cpu_data();
|
||||||
const int count = bottom[0]->count();
|
const int count = bottom[0]->count();
|
||||||
for (int i = 0; i < count; ++i) {
|
for (int i = 0; i < count; ++i) {
|
||||||
top_data[i] = log(1. + exp(min(bottom_data[i], Dtype(kBNLL_THRESHOLD))));
|
top_data[i] = bottom_data[i] > 0 ?
|
||||||
|
bottom_data[i] + log(1. + exp(-bottom_data[i])) :
|
||||||
|
log(1. + exp(bottom_data[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +45,9 @@ template <typename Dtype>
|
||||||
__global__ void BNLLForward(const int n, const Dtype* in, Dtype* out) {
|
__global__ void BNLLForward(const int n, const Dtype* in, Dtype* out) {
|
||||||
int index = threadIdx.x + blockIdx.x * blockDim.x;
|
int index = threadIdx.x + blockIdx.x * blockDim.x;
|
||||||
if (index < n) {
|
if (index < n) {
|
||||||
out[index] = log(1. + exp(min(in[index], Dtype(kBNLL_THRESHOLD))));
|
out[index] = in[index] > 0 ?
|
||||||
|
in[index] + log(1. + exp(-in[index])) :
|
||||||
|
log(1. + exp(in[index]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ void WriteProtoToBinaryFile(const Message& proto, const char* filename) {
|
||||||
|
|
||||||
|
|
||||||
void ReadImageToDatum(const string& filename, const int label, Datum* datum) {
|
void ReadImageToDatum(const string& filename, const int label, Datum* datum) {
|
||||||
Mat cv_img;
|
cv::Mat cv_img;
|
||||||
cv_img = cv::imread(filename, CV_LOAD_IMAGE_COLOR);
|
cv_img = cv::imread(filename, CV_LOAD_IMAGE_COLOR);
|
||||||
CHECK(cv_img.data) << "Could not open or find the image.";
|
CHECK(cv_img.data) << "Could not open or find the image.";
|
||||||
datum->set_channels(3);
|
datum->set_channels(3);
|
||||||
|
@ -80,7 +80,7 @@ void ReadImageToDatum(const string& filename, const int label, Datum* datum) {
|
||||||
for (int c = 0; c < 3; ++c) {
|
for (int c = 0; c < 3; ++c) {
|
||||||
for (int h = 0; h < cv_img.rows; ++h) {
|
for (int h = 0; h < cv_img.rows; ++h) {
|
||||||
for (int w = 0; w < cv_img.cols; ++w) {
|
for (int w = 0; w < cv_img.cols; ++w) {
|
||||||
datum_string->push_back(static_cast<char>(cv_img.at<Vec3b>(h, w)[c]));
|
datum_string->push_back(static_cast<char>(cv_img.at<cv::Vec3b>(h, w)[c]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче