1/5
A quick reference set covering common mistakes in Python coding practice, including tensor definitions, bias usage, and handling multiple conditions.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What is the correct way to define a tensor with torch.tensor
?
Use a tuple with a single argument, enclosed in brackets ( )
.
What common mistake happens when defining a tensor?
Forgetting that torch.tensor
expects a tuple with just one argument.
How should you check for bias in a class method?
Use if self.bias:
— always include self
for class functions.
What is the role of self
in Python class methods?
It ensures the method has access to the instance’s attributes and functions.
What should you be careful of when using multiple and
and or
statements?
Verify all possible cases and ensure logic is grouped correctly.
What happens if one of the conditions in a complex and
/or
chain isn’t satisfied?
The result may not behave as expected — test each case explicitly.