Change in snippet

I was adviced that Due to some changes in matplotlib’s new version, there’s some changes needed to be done in this snippet. Use
"plt.plot(list(loss.values()))".
Working . Thanks
Only for multiple inputs this change in snippet it is NOT working . Pl guide
e.g. exercise 413 …
"plt.plot(list(loss.values(), '-o', markersize=5))"
e.g. exercise 417
"plt.plot(list(train_accuracies.values(),label="Train accuracy"))"
"plt.plot(list(val_accuracies.values(),label="Validation accuracy"))"

Hi @droy1967,
As plt.plot() is a function which takes in a number of args, whereas only the first argument, i.e loss values needs to be passed as a list. Rest of the args don’t need to be added in the list.
Please try the following:

plt.plot(list(loss.values()), '-o', markersize=5)

Please do let me know if the error still persists.

Working fine in both 413 and 417 .Thanks & Regards

I am getting another error with a snippet … pl help Regards
`out = infer(net_attn, ‘INDIA’, 30)’

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-18-2f3cc3230c26> in <module>()
----> 1 out = infer(net_attn, 'INDIA', 30)

NameError: name 'infer' is not defined

Also for 0518_HyperparameterTuning_MLFlow (Integrating Google colab with a local runtime (config in Google colab, Browser, Jupyter notebook) while using as per instructions … Pl advice

jupyter notebook \
  --NotebookApp.allow_origin='https://colab.research.google.com' \
  --port=8888 \
  --NotebookApp.port_retries=0

Getting following error ( prt screen attached )

Hi @droy1967,
It’s because the infer function was mistakenly missed in the notebook.
Paste the following snippet before calling infer.
SmartSelect_20200524-062518_Mighty Networks

Thanks that solved the issue. However I am facing another issue going forward … pl help

print(len(out))
for i in range(len(out)):
    print(out[i].shape, list(hindi_alpha2index.keys())[list(hindi_alpha2index.values()).index(torch.argmax(out[i]))])

Receiving error…

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-21-8262f93df3c4> in <module>()
----> 1 for i in range(len(out)):
      2     print(out[i].shape, list(hindi_alpha2index.keys())[list(hindi_alpha2index.values()).index(torch.argmax(out[i]))])

TypeError: object of type 'NoneType' has no len()

I have corrected this error but still not able to connect over local runtime … can you help please

Awaiting a help on this … Regards

print(len(out))
for i in range(len(out)):
    print(out[i].shape, list(hindi_alpha2index.keys())[list(hindi_alpha2index.values()).index(torch.argmax(out[i]))])
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-21-8262f93df3c4> in <module>()
----> 1 for i in range(len(out)):
      2     print(out[i].shape, list(hindi_alpha2index.keys())[list(hindi_alpha2index.values()).index(torch.argmax(out[i]))])

TypeError: object of type 'NoneType' has no len()

Hi @droy1967,
It seems that out is not a list object which can be iterated or applied len().
Can you please try printing the type(out)

Thanks for the input …I am still getting an error

print(type(out))
for i in range(type(out)):
    print(out[i].shape, list(hindi_alpha2index.keys())[list(hindi_alpha2index.values()).index(torch.argmax(out[i]))])
<class 'NoneType'>
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-24-86c3774dc205> in <module>()
      1 print(type(out))
----> 2 for i in range(type(out)):
      3     print(out[i].shape, list(hindi_alpha2index.keys())[list(hindi_alpha2index.values()).index(torch.argmax(out[i]))])

TypeError: 'type' object cannot be interpreted as an integer

Also connecting to local Machine is just not happening though Jupyter over ws is loaded as well as Server authetication is done … pl advice where am I going wrong


That’s a NoneType object, and you can’t access it anyway. Because there’s nothing been assigned to this object.
Please try going through your code once again to spot any discrepency by comparing it with original code.

I’m not sure about the reason behind this, maybe you can check with Jupyter updates or try following all the steps once again from the beginning.

Thanks for the advice. It is working now. Regards