Programming Flashcards
(85 cards)
Advanced indexing (PyTorch)
A powerful feature that allows users to access and manipulate specific elements or subsets of a tensor using advanced indexing techniques. This includes boolean masking, integer array indexing, and using tensor indices to select elements along specific dimensions.
Application Programming Interface (API)
Set of rules and protocols that allows different software applications to communicate and interact with each other. APIs define the methods and data formats that applications can use to request and exchange information. They facilitate the development of software by providing a standardized way for developers to access functionality or services provided by other applications, libraries, or platforms.
Array
A data structure that stores a collection of elements of the same data type in contiguous memory locations. Arrays offer efficient access to elements using index-based retrieval and support various operations such as insertion, deletion, and traversal. They are fundamental in programming and are used to represent vectors, matrices, and multidimensional data structures in languages like Python, Java, and C++.
Arrays in Python are data structures that store collections of elements of the same data type in contiguous memory locations. Unlike traditional arrays in languages like C or Java, Python arrays are implemented using the array module or the more versatile numpy library. Arrays in Python provide efficient access to elements through index-based retrieval and support various operations such as insertion, deletion, and traversal. They are commonly used to represent vectors, matrices, and multidimensional data structures.
Arrays are created by calling a method, not just constructed when used [] as this is reserved for lists
array = array.arrray[0,4,0,9,1]
Assert
Programming construct used to test assumptions or conditions within code. It evaluates a Boolean expression and throws an exception or raises an error if the condition is false, indicating a violation of expected behavior. Assert statements are commonly employed in unit testing to validate program correctness and identify errors early in the development process.
Atribute
Represents a piece of data associated with an object. Attributes describe the state of an object. For example, in a Car class, color could be an attribute representing the color of the car.
We call an atribute like this:
object.atribute
Autograd (PyTorch)
Built in function in PyTorch. Autograd in PyTorch is the heart of its deep learning capabilities. It’s a powerful automatic differentiation engine that allows you to efficiently compute gradients (rates of change) for any operation performed on tensors. Here’s a breakdown:
Automatic Differentiation: Imagine building a complex mathematical equation with tensors. Normally, calculating the gradients for each variable involved would be tedious and error-prone. Autograd automates this process.
Computational Graph: When you perform operations on tensors with requires_grad=True, PyTorch creates a computational graph behind the scenes. This graph tracks all the operations performed, essentially showing how each tensor depends on others.
Backpropagation: During training, when you calculate a loss function (how well your model performs), autograd uses the computational graph to efficiently backpropagate the error. It starts from the loss and works backward through the graph, calculating the gradients for each tensor involved.
Optimizer: These gradients are then used by an optimizer (like SGD) to update the weights and biases in your neural network, allowing it to learn and improve its predictions.
In simpler terms: Autograd acts like a magical bookkeeper, meticulously tracking every step in your calculations and then efficiently calculating the gradients you need to train your neural network effectively.
Boolean
Named after the mathematician George Boole, refers to a data type or algebraic system that represents two possible values: True and False. In Boolean algebra, these values are typically denoted as 1 for True and 0 for False. Boolean values are fundamental in computer science for logical operations, decision-making, and binary state representation. In Python, boolean values are represented by the bool type, and logical operations such as AND, OR, and NOT are performed using the keywords and, or, and not, respectively.
Buffer
A temporary storage area in computer memory used to hold data temporarily during input/output operations or between different processes. In the context of neural networks, a buffer refers to a temporary storage area used to hold intermediate or temporary data during the forward and backward passes of the training process. Buffers are commonly used to store activations, gradients, and other intermediate computations at different layers of the network. During the forward pass, input data is propagated through the network, and intermediate results are stored in buffers for subsequent computation. During the backward pass (backpropagation), gradients are computed with respect to the loss function, and intermediate gradients are stored in buffers to update the network parameters (weights and biases) through optimization algorithms such as gradient descent. Buffers play a crucial role in managing data flow and optimizing memory usage in neural network implementations, especially for large-scale models with many layers and parameters.
Casting
Casting in Python, with functions like int(), float(), and str(), ensures data type compatibility and facilitates manipulation. Explicit conversion is common, while implicit casting occurs, such as in arithmetic operations. Handling errors, like incompatible type conversions, is essential for smooth execution. Python provides built-in functions for type conversion, allowing seamless transition between different data types. Care should be taken to ensure data integrity and prevent runtime issues. Overall, casting is a fundamental aspect of Python programming, enabling flexibility and versatility in data processing tasks.
Class
A class is a blueprint for creating objects with specific attributes and behaviors. It encapsulates data (attributes) and behavior (methods) into a cohesive unit, promoting code organization and reusability. Objects are instances of classes, created using the class’s constructor method. Classes support inheritance, allowing subclasses to inherit attributes and methods from their superclass. This enables hierarchical organization of code and facilitates code reuse and modularity, essential principles in object-oriented programming.
Think of an object as a blueprint (class) brought to life. For example, a “Car” blueprint has properties (color, make, model) and behaviors (accelerate, brake, turn). A specific car you see on the street is an object—an instance of the “Car” class.
Code interpreter
A software component responsible for executing code statements or instructions interactively. Interpreters translate and execute code directly, line by line, without the need for compilation. In machine learning, code interpreters facilitate rapid prototyping, debugging, and experimentation with algorithms and models, enhancing the development workflow and productivity of practitioners.
Code layouts
Code layout refers to the organization and structure of code within a file or project. It encompasses various aspects such as indentation, spacing, and commenting styles, which significantly affect code readability and maintainability. An effective code layout enhances collaboration among developers and reduces the likelihood of introducing errors during code modifications. Properly structured code layouts adhere to consistent conventions and principles, making it easier for developers to understand, debug, and extend the codebase over time.
Command line argparse
A module in Python’s standard library that facilitates the parsing of command-line arguments passed to Python scripts. It provides a user-friendly interface for creating powerful and flexible command-line interfaces. By defining arguments, options, and their corresponding actions, developers can effortlessly handle user inputs from the command line. Command line argparse simplifies argument parsing by automatically generating help messages and error handling mechanisms. It supports a wide range of argument types and validation rules, making it suitable for building robust and interactive command-line applications.
Command lines
Command lines serve as the primary interface for users to interact with computer programs by entering text commands into a terminal or command prompt. These commands typically instruct the operating system to execute specific actions or run programs. Command lines provide a versatile and efficient means of performing tasks such as file manipulation, system configuration, and program execution. Users can leverage command lines to navigate file systems, install software packages, manage processes, and automate repetitive tasks through scripting. Despite the prevalence of graphical user interfaces (GUIs), command lines remain indispensable for advanced users and system administrators due to their flexibility and scripting capabilities.
Example: Running Python scripts or executing system commands using the terminal or command prompt.
Compiler
A software tool that translates source code written in a high-level programming language into machine-readable binary code or executable files. Compilers analyze, optimize, and transform source code into an efficient form that can be executed on a target platform. In machine learning and artificial intelligence, compilers are used to optimize and accelerate code execution, particularly for performance-critical tasks such as training deep neural networks and executing inference on edge devices.
Comprehentions
Comprehensions are concise and expressive syntax constructs in programming languages, such as list comprehensions, dictionary comprehensions, and set comprehensions. Comprehensions enable developers to create new data structures by iterating over existing ones and applying transformations or filters in a single line of code.
even_numbers = [number for number in numbers if number % 2 == 0]
Conditional breakpoint
A debugging feature that allows developers to pause program execution at specific points in the code only when certain conditions are met. Unlike regular breakpoints, which halt execution unconditionally, conditional breakpoints provide more flexibility by allowing developers to specify criteria for triggering the breakpoint. Common use cases include debugging loops, conditional branches, or complex logic where developers need to inspect variables or evaluate expressions under specific conditions. By setting conditional breakpoints, developers can streamline the debugging process and focus their attention on relevant code paths, thereby accelerating the identification and resolution of software bugs.
Context managers
Objects that enable the management of resources within a block of code by automatically allocating and releasing them. They are typically used with the with statement, which ensures that the necessary setup and teardown actions are performed in a predictable and consistent manner. Context managers abstract away resource management complexities and help prevent resource leaks or conflicts by encapsulating resource-related logic within context manager objects. Common examples of context managers include file handles (open()), database connections, and locks. By using context managers, developers can write cleaner, more robust code that is easier to read, understand, and maintain.
Control Flow
Control flow refers to the order in which instructions or statements are executed in a program or algorithm. In coding, control flow structures, such as loops, conditional statements, and function calls, govern the flow of execution and decision-making in algorithms and models. Control flow mechanisms enable the implementation of complex logic, iteration, and branching behavior in code, facilitating algorithmic design and problem-solving strategies.
Data Frame
A two-dimensional labeled data structure used for storing and manipulating tabular data in programming languages like Python (Pandas), R, and Julia. It consists of rows and columns, where each column can be of a different data type (e.g., numerical, categorical, or text).
DataLoader library
Library in PyTorch equiped allowing for loading and assembling many data inputs into batches
Debugging
Process of identifying, isolating, and resolving errors, or bugs, in computer programs. It plays a crucial role in software development by ensuring that programs behave as intended and meet the specified requirements. Debugging techniques range from simple print statements and logging to sophisticated debugging tools and techniques provided by integrated development environments (IDEs). Developers use debugging to trace the execution flow, inspect variable values, analyze stack traces, and identify the root causes of software defects. Effective debugging requires a systematic approach, critical thinking skills, and a deep understanding of the programming language and environment.
Decorators
A higher-order functions in Python that modify or enhance the behavior of other functions or methods without altering their core implementation. They achieve this by wrapping the target function with additional functionality, such as logging, caching, authentication, or error handling. Decorators are commonly used to enforce cross-cutting concerns, such as security policies or performance optimizations, across multiple functions within a codebase. They promote code reuse, modularity, and separation of concerns by allowing developers to encapsulate common functionalities within reusable decorator functions. Decorators are a powerful tool in Python’s arsenal, enabling developers to write clean, concise, and expressive code with minimal boilerplate.
Dictionary
Dictionaries are sometimes found in other languages as “associative memories” or “associative arrays”. Dictionary is a set of key: value pairs, with the requirement that the keys are unique (within one dictionary).
Unlike sequences, which are indexed by a range of numbers, dictionaries are indexed by keys, which can be any immutable type; strings and numbers can always be keys. Tuples can be used as keys if they contain only strings, numbers, or tuples; if a tuple contains any mutable object either directly or indirectly, it cannot be used as a key. You can’t use lists as keys, since lists can be modified in place using index assignments, slice assignments, or methods like append() and extend().
A pair of braces creates an empty dictionary: {}.