User contributions for Davrot
From Master of Neuroscience Wiki
21 October 2025
- 14:2514:25, 21 October 2025 diff hist +26,299 N Layers Created page with "Layers, layers, everywhere. If you understand PyTorch layers then you understand most of PyTorch. Well, and torch.tensor… Questions to [mailto:davrot@uni-bremen.de David Rotermund] Open Book & Website recommendation If you don’t know what these layers mean then don’t be ashamed and check out these resources: Dive into Deep Learning https://d2l.ai/ as well as corresponding Youtube channel from [https://www.youtube.com/playlist?list=PLZSO_6-bSqHQHBCoGaObUlj..." current Tag: Visual edit
- 14:2314:23, 21 October 2025 diff hist −91 Data augmentation →torchvision.transforms.RandomApply(transforms, p=0.5) current Tag: Visual edit
- 14:2214:22, 21 October 2025 diff hist +5 N File:20 17.png No edit summary current
- 14:2214:22, 21 October 2025 diff hist +5 N File:20 18.png No edit summary current
- 14:2214:22, 21 October 2025 diff hist +5 N File:20 19.png No edit summary current
- 14:2114:21, 21 October 2025 diff hist +5 N File:20 20.png No edit summary current
- 14:2114:21, 21 October 2025 diff hist +5 N File:20 21.png No edit summary current
- 14:2014:20, 21 October 2025 diff hist +5 N File:20 22.png No edit summary current
- 14:2014:20, 21 October 2025 diff hist +5 N File:20 23.png No edit summary current
- 14:2014:20, 21 October 2025 diff hist +5 N File:20 24.png No edit summary current
- 14:1914:19, 21 October 2025 diff hist +5 N File:20 25.png No edit summary current
- 10:0110:01, 21 October 2025 diff hist −148 Data augmentation No edit summary Tag: Visual edit
- 10:0010:00, 21 October 2025 diff hist +5 N File:20 16.png No edit summary current
- 09:5909:59, 21 October 2025 diff hist +5 N File:20 15.png No edit summary current
- 09:5909:59, 21 October 2025 diff hist +5 N File:20 13.png No edit summary current
- 09:5809:58, 21 October 2025 diff hist +5 N File:20 12.png No edit summary current
- 09:5809:58, 21 October 2025 diff hist +5 N File:20 11.png No edit summary current
- 09:5709:57, 21 October 2025 diff hist +5 N File:20 10.png No edit summary current
- 09:5709:57, 21 October 2025 diff hist +4 N File:20 9.png No edit summary current
- 09:5609:56, 21 October 2025 diff hist +4 N File:20 8.png No edit summary current
- 09:5609:56, 21 October 2025 diff hist +5 N File:20 14.png No edit summary current
- 09:5609:56, 21 October 2025 diff hist +4 N File:20 7.png No edit summary current
- 09:5509:55, 21 October 2025 diff hist +4 N File:20 6.png No edit summary current
- 09:5509:55, 21 October 2025 diff hist +4 N File:20 5.png No edit summary current
- 09:5509:55, 21 October 2025 diff hist +4 N File:20 4.png No edit summary current
- 09:5409:54, 21 October 2025 diff hist +4 N File:20 3.png No edit summary current
- 09:5409:54, 21 October 2025 diff hist +4 N File:20 2.png No edit summary current
- 09:5209:52, 21 October 2025 diff hist +28 N File:Data augmentation test image.jpg No edit summary current
- 09:5109:51, 21 October 2025 diff hist +19,449 N Data augmentation Created page with "What is available as data augmentation methods in torchvision? Questions to [mailto:davrot@uni-bremen.de David Rotermund] Initial Image: Initial Image Photo by Udo Ernst == Loading an example image (with opencv2) == Load it via [https://docs.opencv.org/4.5.3/d4/da8/group__imgcodecs.html#ga288b8b3da0892bd651fce07b3bbd3a56 cv2.imread( filename[, flags]) -> retval]<syntaxhighlight lang="python">import cv2 import matplotlib...." Tag: Visual edit
- 09:5109:51, 21 October 2025 diff hist +4 N File:20 1.png No edit summary current
- 09:5009:50, 21 October 2025 diff hist +4 N File:20 0.png No edit summary current
- 09:4809:48, 21 October 2025 diff hist +3,648 N Interfacing Data Created page with "We need to handle our data and make it accessible for PyTorch. Questions to [mailto:davrot@uni-bremen.de David Rotermund] There are options to interface your data. == [https://pytorch.org/docs/stable/data.html#torch.utils.data.TensorDataset torch.utils.data.TensorDataset] == <syntaxhighlight lang="python">CLASS torch.utils.data.TensorDataset(*tensors)</syntaxhighlight><blockquote>Dataset wrapping tensors. Each sample will be retrieved by indexing tensors along the fi..." current Tag: Visual edit
- 09:4709:47, 21 October 2025 diff hist +6,981 N Converting the original MNIST files into numpy Created page with "Questions to [mailto:davrot@uni-bremen.de David Rotermund] '''I will use Linux. You will need a replacement for gzip under Windows.''' == Download the files == We need to download the MNIST database files * t10k-images.idx3-ubyte.gz * t10k-labels.idx1-ubyte.gz * train-images.idx3-ubyte.gz * train-labels.idx1-ubyte.gz A source for that is for example https://www.kaggle.com/datasets/hojjatk/mnist-dataset?resource=download == Unpack the gz files == In a terminal:<synta..." current Tag: Visual edit
- 09:4609:46, 21 October 2025 diff hist +4,667 N Get CUDA ready! Created page with "Convince PyTorch and Nvidia’s GPUs working together. '''I assume you installed the PyTorch and/or TensorFlow version for CUDA. (see Python installation instructions on this site…)''' Questions to [mailto:davrot@uni-bremen.de David Rotermund] == Windows / Linux == * Download and install [https://developer.nvidia.com/cuda-downloads CUDA driver] * Download and install [https://developer.nvidia.com/rdp/cudnn-download cuDNN toolkit] (you will need to create an account..." current Tag: Visual edit
- 09:4409:44, 21 October 2025 diff hist +957 Python Tutorial →PyTorch Tag: Visual edit
- 09:3909:39, 21 October 2025 diff hist +93 Python Tutorial →OpenCV2 and Python Tag: Visual edit
- 09:3709:37, 21 October 2025 diff hist +1 Python Tutorial →Python: Questions of spectral nature Tag: Visual edit
- 09:3509:35, 21 October 2025 diff hist +1,751 N How to read a webcam with CV2 Created page with "We want to capture the webcam via CV2. Questions to [mailto:davrot@uni-bremen.de David Rotermund]<syntaxhighlight lang="shell">pip install opencv-contrib-python</syntaxhighlight><syntaxhighlight lang="python">import numpy as np import cv2 def record_video( camera_index: int, n_frames: int, fps: float = 20.0, framesize: tuple[int, int] = (640, 480), display: bool = False, ) -> tuple[bool, np.ndarray]: cap = cv2.VideoCapture(camera_index) asse..." current Tag: Visual edit
- 09:3009:30, 21 October 2025 diff hist +4,654 N OpenCV2: Play, write, read a video Created page with "How to playback a video? Howto save it into a mp4 file? Howto load from a mp4 file? Questions to [mailto:davrot@uni-bremen.de David Rotermund] == Write the video into a mp4 file == <syntaxhighlight lang="python"> import numpy as np import cv2 # type: ignore import tqdm # type: ignore def write_video(frames: np.ndarray, filename: str = "test", fps: float = 20.0) -> None: assert len(filename) > 0, "write_video: Filename is empty." assert frames.size > 0, "wri..." current Tag: Visual edit
- 09:2709:27, 21 October 2025 diff hist +1,824 N Austin: Time and memory profiling Created page with "We want to see where your Python program requires the most processing time and memory. For this we will use a time- and memory profiler called Austin. Questions to [mailto:davrot@uni-bremen.de David Rotermund] == Installing Austin == Obviously, first we need to get [https://github.com/p403n1x87/austin Austin]. On the Austin website, there a several methods described how to install it. === Linux as user === Compiling<syntaxhighlight lang="shell">git clone --depth=1 htt..." current Tag: Visual edit
- 09:2709:27, 21 October 2025 diff hist +4 N File:19 2.png No edit summary current
- 09:2709:27, 21 October 2025 diff hist +4 N File:19 1.png No edit summary current
- 09:2609:26, 21 October 2025 diff hist +4 N File:19 0.png No edit summary current
- 09:2609:26, 21 October 2025 diff hist +4 N File:19 3.png No edit summary current
- 09:2509:25, 21 October 2025 diff hist +4 N File:19 4.png No edit summary current
- 09:2409:24, 21 October 2025 diff hist +6,127 N ZeroMQ: Microservices as well as connecting computers via message queue Created page with "[https://zeromq.org/get-started/ ZeroMQ] is a simple to implement way to transfer data between server & client application. It is available for a vast range of programming languages. Including Python [https://pyzmq.readthedocs.io/en/latest/index.html PyZMQ]. It has a [https://zguide.zeromq.org/ lot of options], including broadcasting. I will only present a very simple example because most of it we don’t need. Questions to [mailto:davrot@uni-bremen.de David Roterm..." current Tag: Visual edit
- 09:2209:22, 21 October 2025 diff hist +1,574 N Psutil vs os.cpu count: How many "CPUs" do I have? Created page with "How man “CPUs” do I have in this computer? We need this information for multi-processing. Questions to [mailto:davrot@uni-bremen.de David Rotermund] == os.cpu_count == We get the core count inclusive the virtual hyper threading cores. But it is included in Python:<syntaxhighlight lang="python">import os # If -1 then it looks up the amount of available CPU HT cores number_of_cpu_processes: int = -1 number_of_cpu_processes_temp = os.cpu_..." current Tag: Visual edit
- 09:2109:21, 21 October 2025 diff hist +3,627 N Argh: Organize your command line arguments Created page with "Argh helps to handle command line arguments in a big way. Don’t use the build-in Python stuff for that. Questions to [mailto:davrot@uni-bremen.de David Rotermund]<syntaxhighlight lang="shell">pip install argh</syntaxhighlight> == Simple example == === No argument is required === The arguments are now only optional for the function call:<syntaxhighlight lang="python">import argh def main(first_parameter: int = 1, second_parameter: int = 2, third_parameter: bool = T..." current Tag: Visual edit
- 09:2009:20, 21 October 2025 diff hist +568 N TQDM: Make your progress visible Created page with "[https://tqdm.github.io/ TQDM] : Introducing a nice progress bar for for loops. Questions to [mailto:davrot@uni-bremen.de David Rotermund]<syntaxhighlight lang="shell">pip install tqdm</syntaxhighlight> == trange == You can just replace range by trange:<syntaxhighlight lang="python">from tqdm import trange import time for i in trange(0, 10): time.sleep(1)</syntaxhighlight><syntaxhighlight lang="python"> 30%|███ | 3/10 [00:03<00:07, 1.12s/it]</syntaxhi..." current Tag: Visual edit
- 09:1609:16, 21 October 2025 diff hist +8,437 N Linearize the spectral coherence Created page with "Questions to [mailto:davrot@uni-bremen.de David Rotermund] Let us assume we have two time series (white in spectrum) <math display="inline">x_1(t)</math> and <math display="inline">x_2(t)</math>. Both are linearly mixed together via a mixing coefficient <math display="inline">\alpha</math>: <math display="block">y(t) = (1- \alpha) x_1(t) + \alpha * x_2(t)</math> Wouldn’t it to be nice if the spectral coherence would be <math display="inline">\alpha</math>? For whit..." current Tag: Visual edit