Hello,
All functions prior have passed tests but I keep getting the same error of a vanishing loss and wrong output. I think I might be calculating idx ( (j+1) % len(examples) ) incorrectly but iβm not sure.
Hello,
All functions prior have passed tests but I keep getting the same error of a vanishing loss and wrong output. I think I might be calculating idx ( (j+1) % len(examples) ) incorrectly but iβm not sure.
Hello!
First, your title says this is assignment 1 but you shared the content from assignment 2. Please correct that.
So, I am not sure which caused you this error but to set the idx
correctly, let me give you an example:
Suppose we have 10 examples (dinosaur names) and want to iterate through them one by one. For iteration 0, we want index 0; for iteration 1, index 1; and so on. Letβs say we have 100 iterations and 10 examples, in the loop for j in range(num_iterations):
If we do like idx = j
, for loop 0, j is 0 and idx is also 0, for loop 1, j is 1 and idx is also 1, and so on till loop 10 where j becomes 10 but our number of examples is 10 so there is no such idx which is 10. So, we want to make the idx 0 at this point. How?
If I divide 1 by 10, the remainder will be 1, if I divide 2 by 10, the remainder will be 2 and If I divide 10 by 10, the remainder will be 0 and hence the loop begins from 0 again.
Yep, we want this. We want the idx should be the remainder of the current iteration divided by the length of examples.
I am setting my idx variable to j % length of examples. Is that not correct? I also keep getting the same error output
This is the expected code for that line in the model() function:
idx = j % len(examples)
The tricky bit in this function is how you calculate these values:
So you may have been focusing on the wrong part of the code.
So then the error lies somewhere else in my codeβ¦all tests have passed in the previous exercises and Iβve restarted the kernel and cleared output several times. Iβll look at my code and review but if I cant find the error can I send my code to you privately for review?
Update for those who find this thread later.
The code for X = ...
and Y = ...
needed some adjustments.
Experiencing a similar problem.
The values of βsingle_exampleβ etc seem to be fine, but the output is incorrect:
j = 0 idx = 0
single_example = turiasaurus
single_example_chars [βtβ, βuβ, βrβ, βiβ, βaβ, βsβ, βaβ, βuβ, βrβ, βuβ, βsβ]
single_example_ix [20, 21, 18, 9, 1, 19, 1, 21, 18, 21, 19]
X = [20, 21, 18, 9, 1, 19, 1, 21, 18, 21, 19]
Y = [20, 21, 18, 9, 1, 19, 1, 21, 18, 21, 19, 0]
Iteration: 0, Loss: 23.084047
single_example = turiasaurus
single_example_chars = [βtβ, βuβ, βrβ, βiβ, βaβ, βsβ, βaβ, βuβ, βrβ, βuβ, βsβ]
single_example_ix = [20, 21, 18, 9, 1, 19, 1, 21, 18, 21, 19]
Nkzxwtdmfqoeyhsqwasjkjvu
Kneb
Kzxwtdmfqoeyhsqwasjkjvu
Neb
Zxwtdmfqoeyhsqwasjkjvu
Eb
Xwtdmfqoeyhsqwasjkjvu
j = 1535 idx = 1535
j = 1536 idx = 0
Iteration: 2000, Loss: 8.299936
single_example = kentrurosaurus
single_example_chars = [βkβ, βeβ, βnβ, βtβ, βrβ, βuβ, βrβ, βoβ, βsβ, βaβ, βuβ, βrβ, βuβ, βsβ]
single_example_ix = [11, 5, 14, 20, 18, 21, 18, 15, 19, 1, 21, 18, 21, 19]
Mmyyyyggggggyuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
Jmllggkyoooooooooooooooooooooooooooooooooooooooooo
Kyyyyggggggyuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
Mmdbdkymeeeeeeeeeeeeeppppppppppppppppppppppppppppp
Yyyyggggggyuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
Ddaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Xyyggggggyuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
Iteration: 4000, Loss: 2.055703
single_example = barosaurus
single_example_chars = [βbβ, βaβ, βrβ, βoβ, βsβ, βaβ, βuβ, βrβ, βuβ, βsβ]
single_example_ix = [2, 1, 18, 15, 19, 1, 21, 18, 21, 19]
Mmmmmmmmmmmmmmmmmmmmmmmmjkwkzkkbbbbxbbbbbbbbbbwvhh
Kkkbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Kzyyyyyyyyyyyyyyfwkkkwwaaaaaaaaaaaaaaaaaaaaaaaaaaa
Mmmbblllllllllllllllllllllllllllllllllllllllllllll
Zyyyyyyyyyyyyyyfwkkkwwaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
Xxxbbbbbbyyyyyfwkkkwwaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
β¦
Iteration: 20000, Loss: 0.045345
single_example = nothronychus
single_example_chars = [βnβ, βoβ, βtβ, βhβ, βrβ, βoβ, βnβ, βyβ, βcβ, βhβ, βuβ, βsβ]
single_example_ix = [14, 15, 20, 8, 18, 15, 14, 25, 3, 8, 21, 19]
Qqzzzzzzzzzzzzzzzwwwwwwwffjjwwwffffuuuuuuuuuuuuuuu
Kkkkkkkkkkkkkkkkkkkkkkwwwwwqfuuuuuuuuuuuuuuuuuuuuu
Llllllllllllllllllllllllllllllllllllllllllllllllll
Qiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
Zzzzzzzzzzzzzzzwwwwwwwffjjwwwffffuuuuuuuuuuuuuuuuu
Fffffqjjjjjjjjjjoooooooooooooooooooooooooooooooooo
Yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
Iteration: 22000, Loss: 0.034120
single_example = nedoceratops
single_example_chars = [βnβ, βeβ, βdβ, βoβ, βcβ, βeβ, βrβ, βaβ, βtβ, βoβ, βpβ, βsβ]
single_example_ix = [14, 5, 4, 15, 3, 5, 18, 1, 20, 15, 16, 19]
Qqzzzzzzzzzzzzzzzwwwwwwwffffwwwffffqffffffffffqqjj
Llllllllllllllllllllllllllllllllllllllllllllllllll
Llllllllllllllllllllllllllllllllllllllllllllllllll
Qjjffffffffjjjjjjjjjjwwwwwqfssssssssssssssssssssss
Zzzzzzzzzzzzzzzwwwwwwwffffwwwffffqffffffffffqqjjjj
Ffffffffffjjjjjjjjjjwwwwwqfsssssssssssssssssssssss
Xxxxxxxxxxxxxxwwwwwwwffffwwwffffqffffffffffqqjjjjj
AssertionError Traceback (most recent call last)
in
1 parameters, last_name = model(data.split(β\nβ), ix_to_char, char_to_ix, 22001, verbose = True)
2
----> 3 assert last_name == βTrodonosaurus\nβ, βWrong expected outputβ
4 print(β\033[92mAll tests passed!β)
AssertionError: Wrong expected output
Hints are appreciated!
Sorry, Iβm unable to reply on this thread in depth at this time. Hopefully another mentor will reply, or you might consider starting a new thread.