0% found this document useful (0 votes)
16K views4 pages

(Solved) (Vanilla RNN (Recurrent Neural Networks) For Parity Function) Let... - Course Hero

Rnn cnn Vanilla RNN (Recurrent Neural

Uploaded by

Jddj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16K views4 pages

(Solved) (Vanilla RNN (Recurrent Neural Networks) For Parity Function) Let... - Course Hero

Rnn cnn Vanilla RNN (Recurrent Neural

Uploaded by

Jddj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

11/09/2022, 11:17 [Solved] [Vanilla RNN (Recurrent Neural Networks) for parity function] Let...

| Course Hero

Engineering & Technology

Question / Computer
Answer Science
/ [Vanilla
& Explanation RNN (Recurrent
Related Questions Neural Networks)
Related Textbooks

Question 숤 Answered step-by-step

[Vanilla RNN (Recurrent Neural Networks) for parity function] Let...


[Vanilla RNN (Recurrent Neural Networks) for parity function]
Let us define a sequence parity function as a function that takes in a sequence of binary inputs and returns a sequence indicating the
number of 1's in the input so far; specifically, if at time t the 1's in the input so far is odd it returns 1, and 0 if it is even. For example, given
input sequence [0, 1, 0, 1, 1, 0], the parity sequence is [0, 1, 1, 0, 1, 1].
Let xt denote the input at time t and yt be the boolean output of this parity function at time t.
Design a vanilla recurrent neural network to implement the parity function. Your implementation should include the equations of your hidden
units and the details about activations with different input at xt (0 or 1).
Hint: think about AND and OR logic functions/ gates, which may be useful here.
This is the entire question: Can you please explain how this works? I know that the basic starting approach is that every cell is basically an
xor gate that take input of h0 and t to get ht, then run entire input sequence through xor gates, but I don't understand why this is the case,
how you would formulate it on paper, or what to do next.
RNN notes if you need more information:
http://www.cs.toronto.edu/~rgrosse/courses/csc321_2017/readings/L14%20Recurrent%20Neural%20Nets.pdf
http://www.cs.toronto.edu/~rgrosse/csc321/lec9.pdf
http://cs231n.stanford.edu/slides/2019/cs231n_2019_lecture10.pdf

Engineering & Technology Computer Science 섈 쉋

Answer & Explanation Solved


Search course by verified expert 숨
documen Expert Help Study Resources Upgrade
1
B

Find the solution below:

Step-by-step explanation

Solution:
 
 
Step 1
Algorithm Steps:-
Define objects to be used as maps to look up the mapping from digits to codings and vice versa
1. Check the data type of input using typeof() inbuilt function

2. If the data type is number, then convert it to a string and loop over each character of the string to look up the corresponding
encoding mapping and append all the encodings to the result string. After the end of loop, return the result string.

3. If the data type is a string, split it using ':' as a separator and then loop over the resulting list elements to lookup corresponding
decoded digit from predefined map object and keep appending the result to a temporary string.

4. Return the result as an Integer using parseInt() inbuilt function

5. If the data is neither number nor string, return undefined.

 
Step 2
Function Code:

https://www.coursehero.com/tutors-problems/Computer-Science/19679433-Vanilla-RNN-Recurrent-Neural-Networks-for-parity-function-Let-us-d/?justUnlocked=1 1/4
11/09/2022, 11:17 [Solved] [Vanilla RNN (Recurrent Neural Networks) for parity function] Let... | Course Hero

function oddlyEven(data) {

// Define objects to be used as maps to lookup the mapping from digits to codings and vice versa

map1 = { 0: '*', 1: '#', 2: '**', 3: '##', 4: '***', 5: '###', 6: '****', 7: '####', 8: '*****', 9: '#####' };
map2 = { '*': 0, '#': 1, '**': 2, '##': 3, '***': 4, '###': 5, '****': 6, '####': 7, '*****': 8, '#####': 9 };
Question Answer & Explanation Related Questions Related Textbooks
//Check the data type of input using typeof() inbuilt function

if ((typeof (data) == 'number') && data > 0) {

data_str = data.toString();

let result = ''; // Create empty result string

for (var i = 0; i < data_str.length; i++) {

if (i > 0) {

result += ':'

// Append to result string

result += map1[parseInt(data_str.charAt(i))];

return result

else if (typeof (data) == 'string') {

data_list = data.split(':');

//Initialize temporary string

temp = '';

for (const element of data_list) {

if (!(element in map2)) {

// If any other character is in the input, return undefined

return undefined;

// Append to temp as string

temp += map2[element].toString();

// Parse temp variable as Integer

result = parseInt(temp);

return result;

else {

return undefined;

 
 
 

Is this answer helpful? Helpful 싙 Unhelpful 싗


Report this answer

Add to library

Related Answered Questions

https://www.coursehero.com/tutors-problems/Computer-Science/19679433-Vanilla-RNN-Recurrent-Neural-Networks-for-parity-function-Let-us-d/?justUnlocked=1 2/4
11/09/2022, 11:17 [Solved] [Vanilla RNN (Recurrent Neural Networks) for parity function] Let... | Course Hero

숵 Q: 3. [When to Stop in Beam Search : 숵 Q: True or False: Data Scientists 쇴


5 points ] Beam Search is a widely - would perform a cluster analysis when
used technique for decoding the most… they know what they are looking for a…
Question Answer & Explanation Related Questions Related Textbooks
Answered over 90d ago Answered over 90d ago

숵 Q: how to solve it?. 4. (5 points) 숵 Q: True or False: Unsupervised


Assume there are p objects stored on a learning features both input variables or
p—processor machine, with each… attributes and an output or predicted…

Answered over 90d ago Answered over 90d ago 싙 100%

솩 솩 솩

Related Textbook Solutions See all

Solutions Solutions Solutions

© © © ©

Shelly Cashman Serie… Shelly Cashman Serie… Shelly Cashman Serie… Techno
Freund/Last Freund/Last Freund/Last F

솩솩솩솩

Company Get Course Hero Careers

About Us iOS Leadership


Scholarships Android Careers
Sitemap Chrome Extension Campus Rep Program
Q&A Archive Educators
Standardized Tests Tutors
Education Summit

Help Legal Connect with Us

Contact Us Copyright Policy College Life


FAQ Academic Integrity Facebook
Feedback Our Honor Code Twitter
Privacy Policy LinkedIn
Terms of Use YouTube
Attributions Instagram

https://www.coursehero.com/tutors-problems/Computer-Science/19679433-Vanilla-RNN-Recurrent-Neural-Networks-for-parity-function-Let-us-d/?justUnlocked=1 3/4
11/09/2022, 11:17 [Solved] [Vanilla RNN (Recurrent Neural Networks) for parity function] Let... | Course Hero

Copyright © 2022. Course Hero, Inc.


  Privacy
  Terms

Course Hero is not sponsored or endorsed by any college or university.

Question Answer & Explanation Related Questions Related Textbooks

https://www.coursehero.com/tutors-problems/Computer-Science/19679433-Vanilla-RNN-Recurrent-Neural-Networks-for-parity-function-Let-us-d/?justUnlocked=1 4/4

You might also like