Logisim 7 segment display that display 4 bits binary after doing 2’s complement

I’m new to this website i was interested by this topic and i want to post my question which is as follows: Design a combinational logic circuit BCD to 7 segment display that displays the 9’s complement of the BCD code on the input. Example if the BCD is 0000 the 7 segment display should display 9 0001 the 7 segment display should display 8 0010 the 7 segment display should display 7 … ….. ….. 0110 the 7 segment display should display 3 … ….. …..

So i tried implementing 4 inputs to a negator to transform the 4 bits into forexample 1111 to 0000 the negation using the not gate to transform into 2’s complement before adding 1 then i implemented 4 full adders to add 1 to the input then im stuck at displaying at the 7 segment display i dont how to connect wires i need help please see the image of my work

please let me know if i have a mistake implementing the full adder wires im not good with wires. its been 4 hours since iam working on this but i found this beautiful site so i said why not try it. ur response is much appreciated.

Using cross-validation to select optimal threshold: binary classification in Keras

I have a Keras model that takes a transformed vector x as input and outputs probabilities that each input value is 1.

I would like to take the predictions from this model and find an optimal threshold. That is, maybe the cutoff value for “this value is 1” should be 0.23, or maybe it should be 0.78, or something else. I know cross-validation is a good tool for this.

My question is how to work this in to training. For example, say I have the following model (taken from here):

def create_baseline():     # create model     model = Sequential()     model.add(Dense(60, input_dim=60, kernel_initializer='normal', activation='relu'))     model.add(Dense(1, kernel_initializer='normal', activation='sigmoid'))     # Compile model     model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])     return model 

I train the model and get some output probabilities:

model.fit(train_x, train_y) predictions = model.predict(train_y) 

Now I want to learn the threshold for the value of each entry in predictions that would give the best accuracy, for example. How can I learn this parameter, instead of just choosing one after training is complete?

Ошибка : Uncaught TypeError: Error in invocation of serial.send(integer connectionId, binary data, function callback): No matching signature

Вылетает ошибка Uncaught TypeError: Error in invocation of serial.send(integer connectionId, binary data, function callback): No matching signature.

var bb;  var onConnect = function(connectionInfo) {   this.connectionId = connectionInfo.connectionId;   bb = connectionId; }  chrome.serial.connect("COM3", {bitrate: 115200}, onConnect);   function arrayBufferToString (buffer) {     var string = '';     var bytes = new Uint8Array( buffer );     var len = bytes.byteLength;     for (var i = 0; i < len; i++) {         string += String.fromCharCode( bytes[ i ] )     }     return string; }   var stringReceived = '';  var onReceiveCallback = function(info) {     if (info.connectionId == expectedConnectionId && info.data) {       var str = convertArrayBufferToString(info.data);       if (str.charAt(str.length-1) === '\n') {         stringReceived += str.substring(0, str.length-1);         onLineReceived(stringReceived);         stringReceived = '';       } else {         stringReceived += str;       }     }   };  chrome.serial.onReceive.addListener(onReceiveCallback);  var onSend = function(){     console.log("sss"); }   var writeSerial=function(str) {   chrome.serial.send(bb, convertStringToArrayBuffer(str), onSend);//Ошибка на эту строчку } var convertStringToArrayBuffer=function(str) {   var buf=new ArrayBuffer(str.length);   var bufView=new Uint8Array(buf);   for (var i=0; i<str.length; i++) {     bufView[i]=str.charCodeAt(i);   }   return buf; }   var x = writeSerial(); 

Random walks on Complete Binary Trees

Let $ T$ be a complete binary tree of height $ n$ and root $ r$ .

A random walk starts at $ r$ , and at each step uniformly at random moves on a neighbor.

There are $ m$ random walkers all starting at $ r$ and let denote with $ H_1,\dots,H_m$ , the heights reached by the walkers after $ n$ steps.

Show that, for some constant $ C$ which do not have to depend on $ n$ and $ m$ , it holds that

$ \mathbb{P}\left(\underset{i \in [m]}\max\left|H_i – \frac{n}{3}\right| \le C \sqrt{n\ln m}\right) \ge 1 – \frac{1}{m}$

I have been trying several strategies, to appropriately define $ H_i$ as sum of random variables and similar, but no one turned out to work. Do you have any idea/suggestion to attach this problem?

Thanks in advance!

Binary genetic programming image classifier’s fitness function improvement

I am trying to figure out how to improve my binary image genetic programming classifier’s fitness. It takes images and classifies them if it has some feature X or not in it.

These are the main points:

  1. It takes an image and looks at the first 8 x 8 pixel values (called window).
  2. It saves these 8 x 8 values into an array and runs decodeIndividual on them.
  3. decodeIndividual simply runs the individual’s function and retrieves the first and last registers. Last register is the scratchVariable that is updated per each window throughout an image.
  4. The first register is the main identifier per window and it adds it to the y_result which is kept for one image.
  5. When all the windows have been evaluated, y_result is compared to the ground truth and the difference is added to the error. Then the same steps are repeated for another image.

Heres the code:

float GeneticProgramming::evaluateIndividual(Individual individualToEvaluate) {     float y_result = 0.0f;     float error = 0.0f;      for (int m = 0; m < number; m++)     {         int scratchVariable = SCRATCH_VAR;          for (int row = 0; row <= images[m].rows - WINDOW_SIZE; row += STEP)         {             for (int col = 0; col <= images[m].cols - WINDOW_SIZE; col += STEP)             {                 int registers[NUMBER_OF_REGISTERS] = {0};                  for (int i = 0; i < NUMBER_OF_REGISTERS-1; i++)                 {                     for (int y = 0; y < row + STEP; y++)                     {                         for (int x = 0; x < col + STEP; x++)                         {                             registers[i] = images[m].at<uchar>(y,x);                         }                     }                 }                 registers[NUMBER_OF_REGISTERS-1] = scratchVariable;                 // we run individual on a separate small window of size 8x8                 std::pair<float, float> answer = decodeIndividual(individualToEvaluate, registers);                 y_result += answer.first;                          scratchVariable = answer.second;              }         }          float diff = y_groundtruth - y_result;         // want to look at squared error         error += pow(diff, 2);         // restart the y_result per image         float y_result = 0.0f;     }      cout << "Done with individual " << individualToEvaluate.index << endl;     return error; } 

images is just a vector where I stored all of my images. I also added the decodeIndividual function which just looks at instructions and the given registers from the window and runs the list of instructions.

std::pair<float, float> GeneticProgramming::decodeIndividual(Individual individualToDecode, int *array)     {            for(int i = 0; i < individualToDecode.getSize(); i++)  // MAX_LENGTH         {             Instruction currentInstruction = individualToDecode.getInstructions()[i];              float operand1 = array[currentInstruction.op1];             float operand2 = array[currentInstruction.op2];             float result = 0;              switch(currentInstruction.operation)             {                 case 0: //+                     result = operand1 + operand2;                     break;                 case 1: //-                     result = operand1 - operand2;                     break;                 case 2: //*                     result = operand1 * operand2;                     break;                 case 3: /// (division)                     if (operand2 == 0)                     {                         result = SAFE_DIVISION_DEF;                         break;                     }                     result = operand1 / operand2;                     break;                 case 4: // square root                     if (operand1 < 0)                     {                         result = SAFE_DIVISION_DEF;                         break;                     }                     result = sqrt(operand1);                     break;                 case 5:                     if (operand2 < 0)                     {                         result = SAFE_DIVISION_DEF;                         break;                     }                     result = sqrt(operand2);                     break;                 default:                     cout << "Default" << endl;                     break;              }              array[currentInstruction.reg] = result;         }         return std::make_pair(array[0], array[NUMBER_OF_REGISTERS-1]);     }    

The problem is that I have:

  • 6 grey scale images reduced to size 60 x 80
  • The window size is 8 x 8
  • Step is 2
  • Number of registers is 65

Yet it takes over 3 seconds to evaluate these 6 incredibly small images. How do I improve my code? I would appreciate anyone pointing out some mistakes or at least providing some guidance. I am thinking of using threads to evaluate each individual separately.

Finding the upper and lower bound using binary search

I am trying to solve this InterviewBit question https://www.interviewbit.com/problems/search-for-a-range/.

My code for this seems to be working properly and it does give me the correct answers on my IDE and on all the sample test cases online but it gives me a TLE on the online judge. It runs in O(log n) time, just a variation of simple binary search.

I am trying to understand what aspect of my code could be made more efficient and faster.

Here’s my code:

int findBound(vector<int> a, int b, bool lower){ int low=0, high=a.size()-1, mid; while(low<=high){     mid=low+(high-low)/2;     if(a[mid]==b){         if(lower){             if((mid != (a.size()-1)) && a[mid+1]==b)                 low=mid+1;             else                 return mid;         }         else{             if(mid != 0 && a[mid-1]==b)                 high=mid-1;             else                 return mid;         }     }     else if(a[mid]>b)         high=mid-1;     else if(a[mid]<b)         low=mid+1; } return -1; }  vector<int> Solution::searchRange(const vector<int> &A, int B) {     vector<int> ans(2);     ans[0]=findBound(A, B, true);     ans[1]=findUpper(A, B, false);     return ans; } 

A binary hook-length formula?

This is purely exploratory and inspired by curiosity.

Setup: For an integer $ k>0$ , let $ k=\sum_{j\geq0}k_j2^j$ be its binary expansion and denote the sum of its digits by $ \eta(k):=\sum_jk_j$ . Further, introduce a binary factorial $ $ [n]!_b:=\eta(1)\eta(2)\cdots\eta(n).$ $ Given an integer partition $ \lambda$ , let $ Y_{\lambda}$ be the corresponding Young diagram. If $ \square$ a cell in $ Y_{\lambda}$ , construct its hook-length $ h_{\square}$ in the usual manner but replace it by $ \eta(h_{\square})$ .

For example, take $ \lambda=(3,2,1)$ then its multiset of hooks is $ \{h_{\square}:\square\in Y_{\lambda}\}=\{5,3,1,3,1,1\}$ which shall be replaced by $ \{\eta(h_{\square}):\square\in Y_{\lambda}\}=\{2,2,1,2,1,1\}$ .

Naturally, we define the (new) product of hook-lengths and denote (with an abuse of notation) $ $ H_{\lambda}=\prod_{\square\in\lambda}\eta(h_{\square}).$ $ If $ \lambda\vdash n$ , it is easy to verify that $ \frac{[n]!_b}{H_{\lambda}}$ is an integer.

QUESTION. What do these integer count? $ $ \sum_{\lambda\vdash n}\frac{[n]!_b}{H_{\lambda}}.$ $

The first few values are: $ 1, 2, 3, 7, 10, 23, 52, 82, 117, 258, \dots$ but not listed on OEIS.

Why my Google earth exported KMZ file is not a XML file but a binary one?

According to wikipedia, kmz is a:

DescriptionKeyhole Markup Language is an XML notation for expressing geographic annotation and visualization within Internet-based, two-dimensional maps and three-dimensional Earth browsers. KML was developed for use with Google Earth, which was originally named Keyhole Earth Viewer.

However, the KMZ file got exported by Google Earth is not a XML one. It’s even not a XML file but a binary file.

How can I see the XML content?

Thanks