Saturday, June 5, 2021

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow


When a button is clicked in one activity the progress bar should be updated which is in another activity

Posted: 05 Jun 2021 08:36 AM PDT

I've two activities : Activity1 and Activity2. I want the progress bar to be updated to 20% when a button is clicked in another activity. The progress bar is in Activity1 and the button is in Activity2. I'm trying to do this, but I couldn't because I'm new to App Development. Can anyone please help me with this?

Thanks in advance!

How to calculate the percentage of which kind the given image is after machine learning in pytorch?

Posted: 05 Jun 2021 08:36 AM PDT

I trained my machine with custom vgg model with CIFAR10 data set, and tested with some images in same data set.

airplane :  -16.972412  automobile :  -18.719894  bird :  -6.989656  cat :  -3.8386667  deer :  -7.622768  dog :  0.37765026  frog :  -8.165334  horse :  -7.4519434  sheep :  -21.241518  truck :  -18.978928  

This is one of how I got the value of what kind the test image is. Below is what I implemented to print above:

kind = ["airplane", "automobile", "bird", "cat", "deer", "dog", "frog", "horse", "sheep", "truck"]  for k in kind:        print(k,": ", output.cpu().detach().numpy()[0][kind.index(k)])  

Here, it is correct that given test image is dog, which is the highest value, yet I want to print every values as percentage, which the sum of all is 100. How could I do this? I used pytorch for code.

I have an error in the climate of gnome manjaro extension, can someone help me?

Posted: 05 Jun 2021 08:36 AM PDT

hi i got this bug in gnome weather and i cant get it to work

The settings of extension weather-extension@xeked.com had an error:

TypeError: GWeather.Location.new_world is not a function  

Stack trace:

@/home/mrmateo/.local/share/gnome-shell/extensions/weather-extension@xeked.com/prefs.js:100:28  _init@resource:///org/gnome/Shell/Extensions/js/extensionsService.js:204:33  OpenExtensionPrefsAsync/<@resource:///org/gnome/Shell/Extensions/js/extensionsService.js:122:28  asyncCallback@resource:///org/gnome/gjs/modules/core/overrides/Gio.js:115:22  run@resource:///org/gnome/Shell/Extensions/js/dbusService.js:177:20  main@resource:///org/gnome/Shell/Extensions/js/main.js:19:13  run@resource:///org/gnome/gjs/modules/script/package.js:206:19  start@resource:///org/gnome/gjs/modules/script/package.js:190:8  @/usr/share/gnome-shell/org.gnome.Shell.Extensions:1:17  

What is the shortest path to implement the 'or' function [ | ] without disturbing the rest of the operations?

Posted: 05 Jun 2021 08:36 AM PDT

This is a simple C++ implementation of regular expressions that takes a regular expression and a string and see if they match supporting the following functions:

  • '+' (Match once more)
  • '*' (Match more than 0 times)
  • '?' (Match 0 or 1 time)
  • '.' (Matches any character)
  • '\d \w 0-3' this kind of symbol

What is the shortest path to implement the or function '|' with them? Can I implement it without implementing the group construct?

#ifndef RE_H  #define RE_H    #include <string>  #include <set>  #include <stdexcept>      struct info {      bool flag1;  };    bool match(const std::string& re_exp, const std::string& str, size_t i, size_t j, info* last_info = nullptr) {      using namespace std;      size_t len1 = re_exp.size(), len2 = str.size();      if(i==len1 && j!=len2) return false;      if(i==len1 && j==len2) return true;      set<char> chars;      size_t k = i;      auto process1 = [&re_exp, &chars](size_t k) {          if(re_exp[k] == '\\') {              if(re_exp[k+1] == 'w') {                  for(char c='a';c<='z';c++) chars.insert(c);                  for(char c='A';c<='Z';c++) chars.insert(c);                  for(char c='0';c<='9';c++) chars.insert(c);              } else if(re_exp[k+1] == 'd') {                  for(char c='0';c<='9';c++) chars.insert(c);              } else if(re_exp[k+1] == '+' || re_exp[k+1] == '-' || re_exp[k+1] == '*' ||                        re_exp[k+1] == '(' || re_exp[k+1] == ')' ||                        re_exp[k+1] == '{' || re_exp[k+1] == '}')                  chars.insert(re_exp[k+1]);              else                  throw runtime_error("bad expression");          }      };      if(re_exp[i] == '(' ) {          for(k=i+1;re_exp[k]!=')'&&k<len1;k++) {              if (re_exp[k] == '\\') {                  process1(k);                  k++;              } else if((k+2 < len1 &&                         (isalpha(re_exp[k]) && re_exp[k+1] == '-' && isalpha(re_exp[k+2]))) ||                        (isdigit(re_exp[k]) && re_exp[k+1] == '-' && isalpha(re_exp[k+2]))) {                  char k1 = re_exp[k], k2 = re_exp[k+2];                  if(k1 > k2) throw  runtime_error("k1 > k2");                  for(char c=k1;c<=k2;c++) chars.insert(c);              } else {                  chars.insert(re_exp[k]);              }          }      } else if(re_exp[i] == '\\') {          process1(i);          k = k+1;      } else {          chars.insert(re_exp[i]);      }      if(re_exp[k+1] == '*' || re_exp[k+1] == '+') {          if(chars.find(str[j]) != chars.end() || (re_exp[k] == '.' && j != len2) ) {              info s{true};              bool res1 = match(re_exp, str, i, j+1, &s);              if(re_exp[k+1] == '*')                  return res1 ||  match(re_exp, str, k+2, j+1) || match(re_exp, str, k+2, j);              else {                  if(res1)                      return res1;                  if(last_info != nullptr && last_info->flag1)                      return match(re_exp, str, k+2, j+1);                  return false;              }          } else {              if(re_exp[k+1] == '*')                  return match(re_exp, str, k+2, j);              else                  return false;          }      } else if(re_exp[k+1] == '?') {          if(chars.find(str[j]) != chars.end() || (re_exp[k] == '.' && j != len2) )              return match(re_exp, str, k+2, j+1) || match(re_exp, str, k+2, j);          else              return match(re_exp, str, k+2, j);      }      else {          if(chars.find(str[j]) != chars.end() || (re_exp[k] == '.' && j != len2) ) {              return match(re_exp, str, k+1, j+1);          } else {              return false;          }      }  }    

No comments:

Post a Comment