Understanding nn.Conv2D in pytorch

I am trying to learn the basic of pytorch so I can assemble my own CNN's. One thing I am also trying to learn is navigating the API documentation. Specifically at the moment I am trying to read through nn.Conv2d. I quote the documentation: Applies a 2D convolution over an input signal composed of several input planes. In the simplest case, the output value of the layer with input size $(N,C_{in},H,W)$ and output $(N,C_{out},H_{out},W_{out})$ can be precisely described as $$ …
Category: Data Science

How to detect that sequence of points belong to some model of first order theory?

Assume that every neural network can be recast to the sequence of layers (https://arxiv.org/abs/2106.14587 has chapter how to do this). Assume that layer U has N neurons. The set of possible activities of layer U forms the N-dimensional vector space. Each concrete state of layer U (in the sense of activities) can be described by N-dimensional vector (point) in this space. Assume, that NN functions or learns and assume that some First Order Theory (set of variables and functions and …
Category: Data Science

Efficient way to write complicated algorithms

My problem is that I make mistakes writing code. For a simple function these mistakes pop out in a dramatic way usually, so I can fix them and move on. On a more complicated program this is not the case and eventually I give up. Sometimes I don't manage to fix all the mistakes and only know it because the produced result is wrong. For more complicated things I usually break it up into small chunk and and verify the …
Topic: programming
Category: Data Science

Calculation of relative standard deviation with a custom function in R

I have measured concentrations of elements in a number of samples. Each concentration is an average of three measurements. Also the standard deviation of these measurements is recorded. I tried to calculate the relative standard deviation with a custom function in R but something is wrong here... library(tidyverse) data <- tribble( ~Sample, ~Cu_conc, ~Fe_conc, ~K_conc, ~Mg_conc, ~Mn_conc, ~Cu_std, ~Fe_std, ~K_std, ~Mg_std, ~Mn_std, "A", 104.126, 0.729185, 283.741, 21.348, 440.639, 0.783757, 0.00637, 1.544, 0.100056, 4.586, "B", 32.409, 0.782756, 451.802, 43.196, 727.316, 0.774423, …
Category: Data Science

Bidirectional Encoder Representations from Transformers in R

Can anybody suggest to me, where I can find example code for R language for BERT neural network for text mining tasks. All I can see are python examples, and I need R. https://github.com/google-research/bert https://github.com/facebookresearch/XNLI https://github.com/tensorlayer/seq2seq-chatbot https://www.depends-on-the-definition.com/named-entity-recognition-with-bert/ https://github.com/huggingface/pytorch-pretrained-BERT и чат ботов https://stanfordnlp.github.io/coqa/ https://github.com/nyu-dl/bert-gen
Category: Data Science

Generating a random numpy ndarray of 0 and 1 with a specific range of 1 values

I want to generate a random numpy ndarray of 0 and 1. I want that the number of occurrences of 1 in every specific rowto range between 2 and 5. I tried:x = np.random.randint(0,2, size=(10, 10))yet i cannot control the number of ones. I tried the np. random.choice() but we only can control the probability of the number. for instance, 1 will be 0.2 of the array. Yet, I want this probability to vary and be in a specific range. …
Category: Data Science

Divide a column by itself with mutate_at dplyr

Hi I'd like to turn each non zero value of my selected columns to a 1 using mutate_at() BRAND MEDIA_TYPE INV1 INV2 <chr> <chr> <dbl> <dbl> b1 newspapers 2 27 b1 magazines 3 0 b2 newspapers 0 0 b3 tv 1 145 b4 newspapers 4 40 b5 newspapers 5 0 b1 newspapers 1 0 b2 newspapers 0 28 The final result should be like follow: BRAND MEDIA_TYPE INV1 INV2 <chr> <chr> <dbl> <dbl> b1 newspapers 1 1 b1 magazines 1 …
Category: Data Science

IDE alternatives for R programming (RStudio, IntelliJ IDEA, Eclipse, Visual Studio)

I use RStudio for R programming. I remember about solid IDE-s from other technology stacks, like Visual Studio or Eclipse. I have two questions: What other IDE-s than RStudio are used (please consider providing some brief description on them). Does any of them have noticeable advantages over RStudio? I mostly mean debug/build/deploy features, besides coding itself (so text editors are probably not a solution).
Category: Data Science

cbind doesn't attribute the name of the column

I'm trying to create a new data frame that contains the row names and the first column of an existing data : i tried this #To take the rownames of my old data New_data <- as.data.frame(row.names(old_data)) #To add the first column of my old data to a new data New_data <- cbind(old_data[,1]) When i visualize my new data using View(New_Data) i don't see the name of my the first column just V1 example > old_data NAME AGE SEXE A AQ …
Category: Data Science

Speculation regarding rising trend in softwares with a potential in diminishing the role of a data scientist

I have recently came across a demo of for a software that's built on natural language processing and its job is to convert a text the user types on a Python interpreter such as Jupyter and the software automatically converts it to a code. A detailed explanation of this software can be found here. I was wondering if such software is developed to handle cleaning and manipulating data, then what would be left for data scientist to do? At the …
Category: Data Science

Create an amortization table with SQL

I have a list of credits, let's assume they are only two for ease: Credit #1 and credit #2: One has 3 months of payments missing and the other has 6 months left of payments. It would like to obtain a table which can produce a dataset with the due date of the following payments: Original dataset: Desired dataset:
Category: Data Science

PAQ=LU pivoting factorization python programming

My code: import scipy.linalg import numpy as np (p_mtrx, q_mtrx, l_mtrx, u_mtrx) = scipy.linalg.lu( a_mtrx ) np.set_printoptions(threshold=3) np.set_printoptions(precision=3) print('l_mtrx=\n',l_mtrx) print('q_mtrx=\n',q_mtrx) print('u_mtrx=\n',u_mtrx) print('p_mtrx=\n',p_mtrx) print('verification\n',p_mtrx@l_mtrx @ u_mtrx-a_mtrx) and I got error: not enough values to unpack(expexted 4 got 3)
Category: Data Science

How to run Orange from the source code?

I'd like to contribute to Orange. To get used to the code, I tried to run the source code directly under Windows 10, so far without success. I have numpy and scipy installed, and the source code for orange3 from GitHub. If I run "python -m Orange.canvas" in the orange3 directory, I get the following error stack: Traceback (most recent call last): File "C:\Program Files (x86)\Python37-32\lib\runpy.py", line 183, in _run_module_as_main mod_name, mod_spec, code = _get_module_details(mod_name, _Error) File "C:\Program Files (x86)\Python37-32\lib\runpy.py", …
Category: Data Science

R code that gives results like Wolfram Alpha for the expectation of a function of a random variable?

When I ask Wolfram Alpha to calculate $E[f(X)]$ where $f(x) = e^{-x^2}$ and $X \sim \mathcal{N}(1,4)$, it gives the result $$ E[f(X)] = \frac{1}{3\sqrt[9]{e}} \approx 0.29828, $$ and the following plot which appears to be based on taking a number of simulations: How can I generate the same type of plot using R?
Category: Data Science

Data Science in C (or C++)

I'm an R language programmer. I'm also in the group of people who are considered Data Scientists but who come from academic disciplines other than CS. This works out well in my role as a Data Scientist, however, by starting my career in R and only having basic knowledge of other scripting/web languages, I've felt somewhat inadequate in 2 key areas: Lack of a solid knowledge of programming theory. Lack of a competitive level of skill in faster and more …
Category: Data Science

Numpy.eye() in Python 3

I'm using numpy.eye(N, M, dtype=int) to print a matrix whose diagonal elements are 1 and rest of the elements are 0. Code: import numpy import sys line = sys.stdin.readline() N, M = map(int, line.split()) print numpy.eye(N, M, dtype=int) The above runs successfully in Python 2. But in python 3 I get the following error: File "solution.py", line 7 print numpy.eye( N , M , dtype =int ) ^ SyntaxError: invalid syntax Is there an alternate package other than numpy in …
Category: Data Science

How prevalent is `C/C++` in machine learning development?

I am currently a data scientist mostly doing NLP, and I do most of my work inPython. Since I didn't get a CS degree in undergrad, I've been limited to very high level languages; Java, Python, and R. I somehow even took Data Structures and Algorithms avoiding C or C++. I'm intending to go to graduate school to study more Natural Language Processing, and I'm wondering how much C/C++ I need to know. Deep-learning frameworks like PyTorch or Tensorflow are …
Category: Data Science

How to choose tools for web dashboard?

I am working in a small sales company. Started with making relatively easy, small, static reports in Excel, but then it was required to make a lot of highly-customizable and adaptable reports, that are really troublesome to do in Excel. I do a lot of VBA, but that still doesn't meet my needs. Our ERP has no BI solution. Excel can't keep up with amount of data used (millions of lines). I am only accustomed to JS and HTML and …
Category: Data Science

Which coding language to use for very large datasets?

I have a very large panel data set (contains around 50M observations, size around 3G). I would to run an algorithm on it. The algorithm basically just loops over observations. Ideally, I would like to use functions in numpy, but I guess this would be really slow. Would R or matlab be good for this? Are there any other python packages I could use? Thanks in advance for any help.
Category: Data Science

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.