Skip to content

Commit

Permalink
Merge pull request #2 from rbgirshick/faster-R-CNN-linux-compat
Browse files Browse the repository at this point in the history
linux compat fixes
  • Loading branch information
ShaoqingRen committed Aug 9, 2015
2 parents 3c5bead + 78e7eb3 commit 40213bf
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 39 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ $(MAT$(PROJECT)_SO): $(MAT$(PROJECT)_SRC) $(STATIC_NAME)
@ echo MEX $<
$(Q)$(MATLAB_DIR)/bin/mex $(MAT$(PROJECT)_SRC) \
CXX="$(CXX)" \
CXXFLAGS="\$$CXXFLAGS $(MATLAB_CXXFLAGS)" \
CXXFLAGS="\$$CXXFLAGS $(MATLAB_CXXFLAGS) -DBUILD_MEX_INTERFACE" \
CXXLIBS="\$$CXXLIBS $(STATIC_LINK_COMMAND) $(LDFLAGS)" -output $@
@ if [ -f "$(PROJECT)_.d" ]; then \
mv -f $(PROJECT)_.d $(BUILD_DIR)/${MAT$(PROJECT)_SO:.$(MAT_SO_EXT)=.d}; \
Expand Down
72 changes: 36 additions & 36 deletions matlab/+caffe/private/caffe_.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,8 @@ static void protobuf_log_handler(::google::protobuf::LogLevel level, const char*
{
const int max_err_length = 512;
char err_message[max_err_length];
sprintf_s(err_message, "Protobuf : %s . at %s Line %d", message.c_str(), filename, line);
snprintf(err_message, max_err_length, "Protobuf : %s . at %s Line %d",
message.c_str(), filename, line);
LOG(INFO) << err_message;
::google::FlushLogFiles(0);
mexErrMsgTxt(err_message);
Expand Down Expand Up @@ -588,40 +589,40 @@ struct handler_registry {

static handler_registry handlers[] = {
// Public API functions
{ "get_solver", get_solver },
{ "solver_get_attr", solver_get_attr },
{ "solver_get_iter", solver_get_iter },
{ "solver_get_max_iter", solver_get_max_iter },
{ "solver_restore", solver_restore },
{ "solver_solve", solver_solve },
{ "solver_step", solver_step },
{ "get_net", get_net },
{ "net_get_attr", net_get_attr },
{ "net_set_phase", net_set_phase },
{ "net_forward", net_forward },
{ "net_backward", net_backward },
{ "net_copy_from", net_copy_from },
{ "net_share_trained_layers_with", net_share_trained_layers_with },
{ "net_reshape", net_reshape },
{ "net_save", net_save },
{ "layer_get_attr", layer_get_attr },
{ "layer_get_type", layer_get_type },
{ "blob_get_shape", blob_get_shape },
{ "blob_reshape", blob_reshape },
{ "blob_get_data", blob_get_data },
{ "blob_set_data", blob_set_data },
{ "blob_get_diff", blob_get_diff },
{ "blob_set_diff", blob_set_diff },
{ "set_mode_cpu", set_mode_cpu },
{ "set_mode_gpu", set_mode_gpu },
{ "set_device", set_device },
{ "set_random_seed", set_random_seed },
{ "get_init_key", get_init_key },
{ "init_log", init_log },
{ "reset", reset },
{ "read_mean", read_mean },
{ "get_solver", get_solver },
{ "solver_get_attr", solver_get_attr },
{ "solver_get_iter", solver_get_iter },
{ "solver_get_max_iter", solver_get_max_iter },
{ "solver_restore", solver_restore },
{ "solver_solve", solver_solve },
{ "solver_step", solver_step },
{ "get_net", get_net },
{ "net_get_attr", net_get_attr },
{ "net_set_phase", net_set_phase },
{ "net_forward", net_forward },
{ "net_backward", net_backward },
{ "net_copy_from", net_copy_from },
{ "net_share_trained_layers_with", net_share_trained_layers_with },
{ "net_reshape", net_reshape },
{ "net_save", net_save },
{ "layer_get_attr", layer_get_attr },
{ "layer_get_type", layer_get_type },
{ "blob_get_shape", blob_get_shape },
{ "blob_reshape", blob_reshape },
{ "blob_get_data", blob_get_data },
{ "blob_set_data", blob_set_data },
{ "blob_get_diff", blob_get_diff },
{ "blob_set_diff", blob_set_diff },
{ "set_mode_cpu", set_mode_cpu },
{ "set_mode_gpu", set_mode_gpu },
{ "set_device", set_device },
{ "set_random_seed", set_random_seed },
{ "get_init_key", get_init_key },
{ "init_log", init_log },
{ "reset", reset },
{ "read_mean", read_mean },
// The end.
{ "END", NULL },
{ "END", NULL },
};

/** -----------------------------------------------------------------
Expand Down Expand Up @@ -650,5 +651,4 @@ void mexFunction(MEX_ARGS) {
mxFree(cmd);
}


#endif
#endif
5 changes: 3 additions & 2 deletions src/caffe/layers/contrastive_loss_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ void ContrastiveLossLayer<Dtype>::Forward_cpu(
loss += dist_sq_.cpu_data()[i];
} else { // dissimilar pairs
if (legacy_version) {
loss += std::max(margin - dist_sq_.cpu_data()[i], Dtype(0.0));
loss += std::max(Dtype(margin - dist_sq_.cpu_data()[i]), Dtype(0.0));
} else {
Dtype dist = std::max(margin - sqrt(dist_sq_.cpu_data()[i]), Dtype(0.0));
Dtype dist = std::max(Dtype(margin - sqrt(dist_sq_.cpu_data()[i])),
Dtype(0.0));
loss += dist*dist;
}
}
Expand Down

0 comments on commit 40213bf

Please sign in to comment.