parameters

How to specify type for function parameter (Python)

How to specify type for function parameter (Python) Question: I want to restrict scope of functions that can be passed as parameter to another function. For example, to restrict functions to be only one from two specified, or from particular module, or by signature. I tried the code below but in it there is now …

Total answers: 3

How do I add a value to a parameter in an init function in python

How do I add a value to a parameter in an init function in python Question: Would it work if I added these values in this way or do I need to add double quotes to the values like "ENGR", "ARTS", …etc"? Also am I supposed to use curly brackets or square brackets? def __init__(self, …

Total answers: 1

Perceptron algorithm does not converge correctly

Perceptron algorithm does not converge correctly Question: Given the following labelled data: feature_matrix = np.array ( [ [ 1, 1], [ 2, 3], [ 3, 4], [-0.5, -0.5], [ -1, -2], [ -2, -3], [ -3, -4], [ -4, -3] ] ) labels = np.array ( [ 1, 1, 1, -1, -1, -1, -1, -1 …

Total answers: 2

How to get a specif parameter matrix (tensor) of a model by its name in pytorch?

How to get a specific parameter matrix (tensor) of a model by its name in pytorch? Question: I have trained my model in pytorch. Now I want to extract a specific parameters tensor by its name (not all tensors). How can I do that? print(myModel.parameters) OUTPUT: <bound method Module.parameters of ANN( (fc1): Linear(in_features=2, out_features=4, bias=True) …

Total answers: 1

Is there a way to convert a string into a function parameter and send it like this?

Is there a way to convert a string into a function parameter and send it like this? Question: Consider the following function: def config(text=None, background=None, foreground=None): # Configures text, background and foreground. # Reconfiguration example config(text=’Hello’, foreground=’#000000′) # Would reconfigure text and fg, but not bg. Now, supposing I had a list of what to …

Total answers: 2

PyTorch and Neural Networks: How many parameters in a layer?

PyTorch and Neural Networks: How many parameters in a layer? Question: Ive seen many sources talk about the number of parameters in a neural network and mention that it is calculated as: num parameters = ((shape of width of the filter * shape of height of the filter * number of filters in the previous …

Total answers: 4

Execute Stored Procedure with Parameters in python

Execute Stored Procedure with Parameters in python Question: I am trying to execute a stored procedure but it is getting complicated, my code in python is: import pyodbc as pyodbc import pandas as pd server = ‘server’ bd = ‘bd’ usuario = ‘usuario’ contrasena = ‘contrasena’ try: conexion = pyodbc.connect(‘DRIVER={ODBC DRIVER 17 for SQL Server};SERVER=’+server+’;DATABASE=’+bd+’;UID=’+usuario+’;PWD=’+contrasena, …

Total answers: 1

Rewrite a pay computation with time-and-a-half for overtime and create a function called computepay which takes two parameters(hours and rate0

Rewrite a pay computation with time-and-a-half for overtime and create a function called computepay which takes two parameters(hours and rate0 Question: Here is my code (btw I am new to Stackoverflow and coding in general so forgive me if I made some mistakes in formatting this question): hours = int(input(‘Enter hours:’)) rate = int(input(‘Enter rate:’)) …

Total answers: 5