void root_node(shared_ptr<Net<Dtype> > net, int iters, Dtype lr) { const std::vector<Blob<Dtype>*>& result = net -> output_blobs(); boost::posix_time::ptime timer = boost::posix_time::microsec_clock::local_time(); MPI_Status status; std::vector<Blob<Dtype>*> bottom_vec; float loss; init_buffer(iters, FLAGS_snapshot_intv, net); for (int i = 0; i < iters; i++) { MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status); ApplyUpdate(net, lr, status.MPI_SOURCE); std::cout << i << std::endl; if (i % FLAGS_snapshot_intv == 0) snapshot(net, i, (boost::posix_time::microsec_clock::local_time() - timer).total_milliseconds()); } save_snapshot(FLAGS_snap_path); }
bool C4UpdateDlg::DoUpdate(const char *szUpdateURL, C4GUI::Screen *pScreen) { if(szUpdateURL == NULL || strlen(szUpdateURL) == 0) { pScreen->ShowMessageModal(LoadResStr("IDS_MSG_NEWRELEASEAVAILABLE"), LoadResStr("IDS_TYPE_UPDATE"),C4GUI::MessageDialog::btnOK, C4GUI::Ico_Ex_Update); RedirectToDownloadPage(); return true; } // Determine local filename for update group StdCopyStrBuf strLocalFilename(Config.AtTempPath(GetFilename(szUpdateURL))); StdCopyStrBuf strRemoteURL(szUpdateURL); // cut off http:// strRemoteURL.Replace("http://",""); // Download update group if (!C4DownloadDlg::DownloadFile(LoadResStr("IDS_TYPE_UPDATE"), pScreen, strRemoteURL.getData(), strLocalFilename.getData(), LoadResStr("IDS_MSG_UPDATENOTAVAILABLE"))) { // Download failed, open browser so the user can download a full package RedirectToDownloadPage(); // return success, because error message has already been shown return true; } // Apply downloaded update return ApplyUpdate(strLocalFilename.getData(), true, pScreen); }
nsresult ProcessUpdates(nsIFile *greDir, nsIFile *appDir, nsIFile *updRootDir, int argc, char **argv, const char *&appVersion) { nsresult rv; nsCOMPtr<nsIFile> updatesDir; rv = updRootDir->Clone(getter_AddRefs(updatesDir)); if (NS_FAILED(rv)) return rv; rv = updatesDir->AppendNative(NS_LITERAL_CSTRING("updates")); if (NS_FAILED(rv)) return rv; rv = updatesDir->AppendNative(NS_LITERAL_CSTRING("0")); if (NS_FAILED(rv)) return rv; PRBool exists; rv = updatesDir->Exists(&exists); if (NS_FAILED(rv) || !exists) return rv; nsCOMPtr<nsILocalFile> statusFile; if (GetStatusFile(updatesDir, statusFile) && IsPending(statusFile)) { nsCOMPtr<nsILocalFile> versionFile; // Remove the update if the update application version file doesn't exist // or if the update's application version is less than the current // application version. if (!GetVersionFile(updatesDir, versionFile) || IsOlderVersion(versionFile, appVersion)) { updatesDir->Remove(PR_TRUE); } else { ApplyUpdate(greDir, updatesDir, statusFile, appDir, argc, argv); } } return NS_OK; }
void gfxVars::Initialize() { if (sInstance) { return; } // sVarList must be initialized first since it's used in the constructor for // sInstance. sVarList = new nsTArray<gfxVars::VarBase*>(); sInstance = new gfxVars; // Like Preferences, we want content to synchronously get initial data on // init. Note the GPU process is not handled here - it cannot send sync // messages, so instead the initial data is pushed down. if (XRE_IsContentProcess()) { InfallibleTArray<GfxVarUpdate> vars; dom::ContentChild::GetSingleton()->SendGetGfxVars(&vars); for (const auto& var : vars) { ApplyUpdate(var); } } }
nsresult ProcessUpdates(nsIFile *greDir, nsIFile *appDir, nsIFile *updRootDir, int argc, char **argv) { nsresult rv; nsCOMPtr<nsIFile> updatesDir; rv = updRootDir->Clone(getter_AddRefs(updatesDir)); if (NS_FAILED(rv)) return rv; rv = updatesDir->AppendNative(NS_LITERAL_CSTRING("updates")); if (NS_FAILED(rv)) return rv; PRBool exists; rv = updatesDir->Exists(&exists); if (NS_FAILED(rv) || !exists) return rv; nsCOMArray<nsIFile> dirEntries; rv = ScanDir(updatesDir, &dirEntries); if (NS_FAILED(rv)) return rv; if (dirEntries.Count() == 0) return NS_OK; // look for the first update subdirectory with a status of pending for (int i = 0; i < dirEntries.Count(); ++i) { nsCOMPtr<nsILocalFile> statusFile; if (GetStatusFile(dirEntries[i], statusFile) && IsPending(statusFile)) { ApplyUpdate(greDir, dirEntries[i], statusFile, appDir, argc, argv); break; } } return NS_OK; }
void Solver<Dtype>::Step(int iters) { const int start_iter = iter_; const int stop_iter = iter_ + iters; int average_loss = this->param_.average_loss(); losses_.clear(); smoothed_loss_ = 0; while (iter_ < stop_iter) { // zero-init the params net_->ClearParamDiffs(); if (param_.test_interval() && iter_ % param_.test_interval() == 0 && (iter_ > 0 || param_.test_initialization()) && Caffe::root_solver()) { TestAll(); if (requested_early_exit_) { // Break out of the while loop because stop was requested while testing. break; } } for (int i = 0; i < callbacks_.size(); ++i) { callbacks_[i]->on_start(); } const bool display = param_.display() && iter_ % param_.display() == 0; net_->set_debug_info(display && param_.debug_info()); // accumulate the loss and gradient Dtype loss = 0; for (int i = 0; i < param_.iter_size(); ++i) { loss += net_->ForwardBackward(); } loss /= param_.iter_size(); // average the loss across iterations for smoothed reporting UpdateSmoothedLoss(loss, start_iter, average_loss); if (display) { LOG_IF(INFO, Caffe::root_solver()) << "Iteration " << iter_ << ", loss = " << smoothed_loss_; const vector<Blob<Dtype>*>& result = net_->output_blobs(); int score_index = 0; for (int j = 0; j < result.size(); ++j) { const Dtype* result_vec = result[j]->cpu_data(); const string& output_name = net_->blob_names()[net_->output_blob_indices()[j]]; const Dtype loss_weight = net_->blob_loss_weights()[net_->output_blob_indices()[j]]; for (int k = 0; k < result[j]->count(); ++k) { ostringstream loss_msg_stream; if (loss_weight) { loss_msg_stream << " (* " << loss_weight << " = " << loss_weight * result_vec[k] << " loss)"; } LOG_IF(INFO, Caffe::root_solver()) << " Train net output #" << score_index++ << ": " << output_name << " = " << result_vec[k] << loss_msg_stream.str(); } } } for (int i = 0; i < callbacks_.size(); ++i) { callbacks_[i]->on_gradients_ready(); } ApplyUpdate(); // Increment the internal iter_ counter -- its value should always indicate // the number of times the weights have been updated. ++iter_; SolverAction::Enum request = GetRequestedAction(); // Save a snapshot if needed. if ((param_.snapshot() && iter_ % param_.snapshot() == 0 && Caffe::root_solver()) || (request == SolverAction::SNAPSHOT)) { Snapshot(); } if (SolverAction::STOP == request) { requested_early_exit_ = true; // Break out of training loop. break; } } }