text stringlengths 81 47k | source stringlengths 59 147 |
|---|---|
Question: <p>I have implemented Logistic Regression with Gradient Descent in Java. It doesn't seem to work well (It does not classify records properly; the probability of y=1 is a lot.) I don't know whether my implementation is correct.I have gone through the code several times and i am unable to find any bug. I have... | https://stackoverflow.com/questions/28824327/implementation-of-logistic-regression-with-gradient-descent-in-java |
Question: <p>I'm trying to implement a very naive gradient descent in python. However, it looks like it goes into an infinite loop. Could you please help me debug it? </p>
<pre><code>y = lambda x : x**2
dy_dx = lambda x : 2*x
def gradient_descent(function,derivative,initial_guess):
optimum = initial_guess
whil... | https://stackoverflow.com/questions/41202817/implementing-naive-gradient-descent-in-python |
Question: <p>I am beginner in gradient descent concept . I implemented a multivariate linear regression with gradient descent optimization algorithm. but my program doesn't converge and just early iteration has small changes!
my methods(in my class) is following below :</p>
<pre><code>def gradientDescent(self, X, y, t... | https://stackoverflow.com/questions/70010085/gradient-descent-doesnt-change-in-my-linear-regression-implementation |
Question: <p>I'm trying to implement stochastic gradient descent in MATLAB however I am not seeing any convergence. Mini-batch gradient descent worked as expected so I think that the cost function and gradient steps are correct.</p>
<p>The two main issues I am having are:</p>
<ol>
<li>Randomly shuffling the data in t... | https://stackoverflow.com/questions/55757307/how-do-i-implement-stochastic-gradient-descent-correctly |
Question: <p>I am trying to implement gradient descent after transforming some random data using sklearns polynomial transformer. My code works when not using polynomial features, but gives really high coefficients when transforming.</p>
<p>Is there an issue with my code (below)?</p>
<pre><code> l= 20
np.random... | https://stackoverflow.com/questions/62625339/gradient-descent-with-polynomial-features-implementation-issue |
Question: <p>I copied the hinge loss function from <a href="https://code.google.com/p/java-statistical-analysis-tool/source/browse/trunk/JSAT/src/jsat/lossfunctions/HingeLoss.java?r=762" rel="nofollow">here</a> (also LossC and LossFunc upon which it's based. Then I included it in my gradient descent algorithm like so: ... | https://stackoverflow.com/questions/28988732/correct-implementation-of-hinge-loss-minimization-for-gradient-descent |
Question: <p>Linear Regression Using Gradient Descent</p>
<p>Reference: <a href="https://towardsdatascience.com/linear-regression-using-gradient-descent-in-10-lines-of-code-642f995339c0" rel="nofollow noreferrer">Linear Regression Using Gradient Descent in 10 Lines of Code</a></p>
<p>Dataset:</p>
<p>House price No. ... | https://stackoverflow.com/questions/63861962/implementation-of-linear-regression-using-gradient-descent |
Question: <p>I'm taking the Machine Learning class by Prof. Ng.
There is a homework need to implement logistic regression gradient descent.
And here is my code:</p>
<pre><code>function [J, grad] = costFunction(theta, X, y)
%COSTFUNCTION Compute cost and gradient for logistic regression
% J = COSTFUNCTION(theta, X, y)... | https://stackoverflow.com/questions/63046676/logistic-regression-gradient-descent-octave-implementation |
Question: <p>I've been trying to implement stochastic gradient descent as part of a recommendation system following these equations:</p>
<p><a href="https://i.sstatic.net/mIzbi.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/mIzbi.jpg" alt="enter image description here" /></a></p>
<p>I have:</p>
<pre><co... | https://stackoverflow.com/questions/44344006/implementing-stochastic-gradient-descent-python |
Question: <p>I am trying to implement gradient descent on a dataset. Even though I tried everything, I couldn't make it work. So, I created a test case. I am trying my code on a random data and try to debug. </p>
<p>More specifically, what I am doing is, I am generating random vectors between 0-1 and random labels for... | https://stackoverflow.com/questions/27009256/gradient-descent-with-random-input-implementation |
Question: <p>I'm trying to implement linear regression using the gradient descent method from scratch for learning purposes. One part of my code is really bugging me. For some reason the variable <code>x</code> is being altered after I run a line of code and I'm not sure why. </p>
<p>The variables are as follow. <code... | https://stackoverflow.com/questions/14993454/linear-regression-gradient-descent-python-implementation |
Question: <p>I'm implementing SVM with hinge loss (linear SVM, soft margin), and try to minimize the loss using gradient descent.<br />
Here's my current gradient descent, in Julia:</p>
<pre><code>for i in 1:max_iter
if n_cost_no_change <= 0 && early_stop
break
end
learn!(X_data, Y_data, ... | https://stackoverflow.com/questions/64126137/better-gradient-descent-implementation-for-linear-svm-with-varying-loss |
Question: <p>This is an assignment for a convex optimization class that I'm taking. The assignment is as follows:</p>
<blockquote>
<p>Implement the gradient descent algorithm with backtracking line search to find the optimal step size. Your implementation will be compared to Python's <a href="https://docs.scipy.org/doc... | https://stackoverflow.com/questions/56586436/self-implementation-of-gradient-descent-compared-to-scipy-minimize |
Question:
<p>I am trying to implement a gradient descent algorithm for simple linear regression. For some reason it doesn't seem to be working. </p>
<pre class="lang-py prettyprint-override"><code>from __future__ import division
import random
def error(x_i,z_i, theta0,theta1):
return z_i - theta0 - theta1 * x_... | https://stackoverflow.com/questions/30745627/python-implementation-of-gradient-descent-algorithm-isnt-working |
Question: <p>I am trying to implement gradient descent in python. Though my code is returning result by I think results I am getting are completely wrong. </p>
<p>Here is the code I have written:</p>
<pre><code>import numpy as np
import pandas
dataset = pandas.read_csv('D:\ML Data\house-prices-advanced-regression-te... | https://stackoverflow.com/questions/56887503/implement-gradient-descent-in-python |
Question: <h1>Vectorized implementation of gradient descent</h1>
<pre><code>for iter = 1:num_iters
theta = theta - (alpha / m) * X' * (X * theta - y);
J_history(iter) = computeCostMulti(X, y, theta);
end
</code></pre>
<h1>Implementation of computeCostMulti()</h1>
<pre><code>function J = computeCostMulti(X, y,... | https://stackoverflow.com/questions/44347215/gradient-descent-and-normal-equation-give-different-theta-values-for-multivariat |
Question: <p>I am trying to implement the gradient descent in python. The data is that of housing prices and i want to predict the house price. But the problem is that the gradient is becoming larger and larger until python cannot process it anymore.</p>
<pre><code>import numpy as np
import sys
from numpy import genfr... | https://stackoverflow.com/questions/48348275/gradient-becoming-larger-and-larger-while-implementing-gradient-descent |
Question: <p>I have tried to use a toy problem of linear regression for implanting the optimisation on the MSE function using the algorithm of gradient decent.</p>
<pre><code>import numpy as np
# Data points
x = np.array([1, 2, 3, 4])
y = np.array([1, 1, 2, 2])
# MSE function
f = lambda a, b: 1 / len(x) * np.sum(np.p... | https://stackoverflow.com/questions/65609277/simple-gradient-descent-implementation-error |
Question: <p>In <a href="https://share.coursera.org/wiki/index.php/ML:Linear_Regression_with_Multiple_Variables#Gradient_Descent_for_Multiple_Variables" rel="nofollow noreferrer">this Coursera course</a> for machine learning, it says gradient descent should converge.</p>
<p>I'm using Linear regression from scikit learn... | https://stackoverflow.com/questions/34469237/linear-regression-and-gradient-descent-in-scikit-learn |
Question: <p>I am trying to train an autoencoder NN (3 layers - 2 visible, 1 hidden) using numpy and scipy for the MNIST digits images dataset. The implementation is based on the notation given <a href="http://ufldl.stanford.edu/wiki/index.php/Neural_Networks" rel="nofollow noreferrer">here</a> Below is my code:</p>
<... | https://stackoverflow.com/questions/47579719/implementing-backpropagation-gradient-descent-using-scipy-optimize-minimize |
Question: <p>I learned the Batch gradient descent algorithm recently and tried implementing it in Python. I used a data set which is not random. When I tried running the below code, the process is converging after 3 iterations but with a big error. Can someone guide me in a right way?
Sample Data set:(original data set... | https://stackoverflow.com/questions/47593225/batch-gradient-descent-algorithm-implementation-in-python |
Question: <p>I have tried to implement gradient descent here in python but the cost J just seems to be increasing irrespective of lambda ans alpha value, i am unable to figure out what the issue over here is. It'll be great if someone can help me out with this. The input is a matrix Y and R with same dimensions. Y is a... | https://stackoverflow.com/questions/19889918/python-implementation-of-gradient-descent-machine-learning |
Question: <p>I tried to implement linear regresion with gradient descent, but my error diverges to infinity. I've read over my code and still cannot figure out where I went wrong. I'm hoping someone can help me debug why this implementation of linear regression isn't working. </p>
<p>When <code>N=100</code> then ther... | https://stackoverflow.com/questions/41349806/what-is-the-issue-with-this-implementation-of-gradient-descent |
Question: <p>I am implementing my own/custom Gradient descent algorithm using python but the weights and biases that are returned by my algorithm has 10 values (shape=(10, )) but my input data has only 1 column so I am expecting it to return <strong>1 Weight and 1 Bias</strong></p>
<p>Code:</p>
<pre><code>import numpy ... | https://stackoverflow.com/questions/67266157/issue-implementing-custom-gradient-descent-function |
Question: <p>I'm currently working on Andrew Ng's gradient descent exercise using python but keeps getting me the wrong optimal theta. I followed this vectorization cheatsheet for gradient descent --- <a href="https://medium.com/ml-ai-study-group/vectorized-implementation-of-cost-functions-and-gradient-vectors-linear-r... | https://stackoverflow.com/questions/56520284/my-vectorization-implementation-of-gradient-descent-does-not-get-me-the-right-an |
Question: <p>I'm attempting to implement gradient descent using code from : </p>
<p><a href="https://stackoverflow.com/questions/10591343/gradient-descent-implementation-in-octave">Gradient Descent implementation in octave</a></p>
<p>I've amended code to following : </p>
<pre><code>X = [1; 1; 1;]
y = [1; 0; 1;]
m =... | https://stackoverflow.com/questions/37845650/gradient-descent-values-not-correct |
Question: <h2>Gradient Descent and Overflow Error</h2>
<p>I am currently implementing vectorized gradient descent in python. However, I continue to get an overflow error. The numbers in my dataset are not extremely large though. I am using this formula:</p>
<p><a href="https://i.sstatic.net/wPecc.png" rel="nofollow n... | https://stackoverflow.com/questions/49865952/implementing-gradient-descent-in-python-and-receiving-an-overflow-error |
Question: <p>I'm trying to implement the multivariate gradient descent algorithm in Java (from AI coursera course), and I cannot figure where is the fault located in my code.</p>
<p>This is the output of the below program:</p>
<pre><code>Before train: parameters := [0.0, 0.0, 0.0] -> cost function := 2.5021875E9
A... | https://stackoverflow.com/questions/41144206/java-implementation-of-multivariate-gradient-descent |
Question: <p>I've been trying to implement gradient descent in Octave. This is the code I have so far:</p>
<pre><code>function [theta, J_history] = gradientDescent(X, y, theta, alpha, num_iters)
%GRADIENTDESCENT Performs gradient descent to learn theta
% theta = GRADIENTDESCENT(X, y, theta, alpha, num_iters) upd... | https://stackoverflow.com/questions/42944688/trouble-implementing-gradient-descent-in-octave |
Question: <p>From what I understand, using <code>feed_dict</code> is a computationally expensive process and should be avoided according to <a href="https://towardsdatascience.com/how-to-use-dataset-in-tensorflow-c758ef9e4428" rel="nofollow noreferrer">this article</a>. Tensorflow's input pipelines are supposedly bette... | https://stackoverflow.com/questions/51091129/how-to-implement-minibatch-gradient-descent-in-tensorflow-without-using-feeddict |
Question: <p>I have problems implementing a gradient descent in R for an exponential function.</p>
<p>Let's say</p>
<pre><code>foo <- function(x) {
y = -2 + 2.5 * exp(0.1*x^2-0.7*x)
return(y) }
</code></pre>
<p>is my exponential function then</p>
<pre><code> grad <- function(x) {
y = 2.5*exp(0.1*x^2-... | https://stackoverflow.com/questions/50249691/issue-when-implementing-gradient-descent-in-r |
Question: <p>Why are the outputs from the code getting slow with every successive iteration?</p>
<p>I want to write a working code , that implements Gradient descent and Newton's method on same function and I want to compare the speeds and iterations for both the methods to arrive at the approximate solution.</p>
<p>... | https://stackoverflow.com/questions/55357592/why-is-my-implementation-of-gradient-descent-on-python-producing-outputs-so-slow |
Question: <p>I was trying to build a gradient descent function in python. I have used the binary-crossentropy as the loss function and sigmoid as the activation function.</p>
<pre><code>def sigmoid(x):
return 1/(1+np.exp(-x))
def binary_crossentropy(y_pred,y):
epsilon = 1e-15
y_pred_new = np.array([max(i,e... | https://stackoverflow.com/questions/66494060/implementing-gradient-descent-in-python |
Question: <p>Using the vectorized version of gradient as described at :
<a href="https://stackoverflow.com/questions/10479353/gradient-descent-seems-to-fail">gradient descent seems to fail</a></p>
<pre><code>theta = theta - (alpha/m * (X * theta-y)' * X)';
</code></pre>
<p>The theta values are not being updated, so... | https://stackoverflow.com/questions/37229574/gradient-descent-not-updating-theta-values |
Question: <p>It seems that the following code finds the gradient descent correctly:</p>
<pre><code>def gradientDescent(x, y, theta, alpha, m, numIterations):
xTrans = x.transpose()
for i in range(0, numIterations):
hypothesis = np.dot(x, theta)
loss = hypothesis - y
cost = np.sum(loss ... | https://stackoverflow.com/questions/33629734/understanding-gradient-descent-for-multivariate-linear-regression-python-impleme |
Question: <p>I have a loss function I would like to try and minimize:</p>
<pre><code>def lossfunction(X,b,lambs):
B = b.reshape(X.shape)
penalty = np.linalg.norm(B, axis = 1)**(0.5)
return np.linalg.norm(np.dot(X,B)-X) + lambs*penalty.sum()
</code></pre>
<p>Gradient descent, or similar methods, might b... | https://stackoverflow.com/questions/42587696/can-i-implement-a-gradient-descent-for-arbitrary-convex-loss-function |
Question: <p>I'm doing Andrew Ng's course on Machine Learning and I'm trying to wrap my head around the vectorised implementation of gradient descent for multiple variables which is an optional exercise in the course.</p>
<p>This is the algorithm in question (taken from <a href="http://www.holehouse.org/mlclass/04_Lin... | https://stackoverflow.com/questions/35945445/implementing-gradient-descent-for-multiple-variables-in-octave-using-sum |
Question: <p>I've implemented a gradient descent algorithm in python and it is just not converging when it runs. When I debugging it, I have to make the alpha very small to let it 'seems' to converge. The alpha is like, have to be 1e-12 that small.</p>
<p>Here is my code</p>
<pre><code> def batchGradDescent(dataMa... | https://stackoverflow.com/questions/30221211/python-implemented-gradient-descent-algorithm-wont-converge |
Question: <p>As a part of my homework I was asked to implement a stochastic gradient descent in order to solve a linear regression problem (even though I have only 200 training examples). My problem is that stochastic gradient descent converges too smoothly, almost exactly as batch gradient descent, which brings me to ... | https://stackoverflow.com/questions/42766970/stochastic-gradient-descent-converges-too-smoothly |
Question: <p>[<a href="https://docs.google.com/spreadsheets/d/1AVNrWBwn22c1QWc6X9zG8FkvTMXHXZGuZH2sPAT9a00/edit?usp=sharing" rel="nofollow noreferrer">Dataset</a>]<a href="https://docs.google.com/spreadsheets/d/1AVNrWBwn22c1QWc6X9zG8FkvTMXHXZGuZH2sPAT9a00/edit?usp=sharing" rel="nofollow noreferrer">1</a>I'm attempting ... | https://stackoverflow.com/questions/66756559/trying-to-implement-linear-regression-with-stochastic-gradient-descent |
Question: <p>I'm trying to implement gradient descent in python and my loss/cost keeps increasing with every iteration.</p>
<p>I've seen a few people post about this, and saw an answer here: <a href="https://stackoverflow.com/questions/17784587/gradient-descent-using-python-and-numpy">gradient descent using python and... | https://stackoverflow.com/questions/39771075/python-gradient-descent-cost-keeps-increasing |
Question: <p>I've recently started the AI-Class at Coursera and I've a question related to my implementation of the gradient descent algorithm.</p>
<p>Here's my current implementation (I actually just "translated" the mathematical expressions into Java code):</p>
<pre><code> public class GradientDescent {
... | https://stackoverflow.com/questions/32169988/gradient-descent-in-java |
Question: <p>The documentation for <a href="https://www.tensorflow.org/api_docs/python/tf/train/MomentumOptimizer" rel="noreferrer"><code>tf.train.MomentumOptimizer</code></a> offers a <code>use_nesterov</code> parameter to utilise Nesterov's Accelerated Gradient (NAG) method.</p>
<p>However, NAG requires the gradient... | https://stackoverflow.com/questions/50774683/how-is-nesterovs-accelerated-gradient-descent-implemented-in-tensorflow |
Question: <p>I am running gradient descent for word2vec and would like to implement numba to speed up the training. </p>
<p>EDIT: It seems the real error is this </p>
<blockquote>
<p>NotImplementedError: unsupported nested memory-managed object</p>
</blockquote>
<p>This is a subsequent error: </p>
<pre><code>rais... | https://stackoverflow.com/questions/48698936/implementing-numba-for-word2vec-gradient-descent-but-getting-loweringerror |
Question: <p>This is how I generated the training data for my Linear Regression.</p>
<pre><code>!pip install grapher, numpy
from grapher import Grapher
import matplotlib.pyplot as plt
import numpy as np
# Secret: y = 3x + 4
# x, y = [float(row[0]) for row in rows], [float(row[5]) for row in rows]
x, y = [a for a in... | https://stackoverflow.com/questions/68356680/implementation-of-gradient-descent-blowing-up-to-infinity |
Question: <p>I'm looking for some advice on how to go about implementing <a href="http://en.wikipedia.org/wiki/Gradient_descent" rel="nofollow">Gradient (steepest) Descent</a> in C. I am finding the minimum of f(x)=||Ax-y||^2, with A(n,n) and y(n) given.</p>
<p>This is difficult in C (I think) because computing the gr... | https://stackoverflow.com/questions/3950349/implementation-of-gradient-steepest-descent |
Question: <p>I'm implementing simple gradient descent in octave but its not working. Here is the data I'm using:</p>
<pre><code>X = [1 2 3
1 4 5
1 6 7]
y = [10
11
12]
theta = [0
0
0]
alpha = 0.001 and itr = 50
</code></pre>
<p>This is my gradient descent implementation:</p>
<... | https://stackoverflow.com/questions/24337887/vectorized-gradient-descent-basics |
Question: <p>Is there a way to perform hyperparameter tuning in scikit-learn by gradient descent? While a formula for the gradient of hyperparameters might be difficult to compute, numerical computation of the hyperparameter gradient by evaluating two close points in hyperparameter space should be pretty easy. Is there... | https://stackoverflow.com/questions/43420493/sklearn-hyperparameter-tuning-by-gradient-descent |
Question: <p>I'm trying to figure out the python code for multivariate gradient descent algorithm, and have found several several implementations like this:</p>
<pre><code>import numpy as np
# m denotes the number of examples here, not the number of features
def gradientDescent(x, y, theta, alpha, m, numIterations):
... | https://stackoverflow.com/questions/33621399/understanding-gradient-of-gradient-descent-algorithm-in-numpy |
Question: <p>I studied the Machine learning course taught by Prof. Andrew Ng. <a href="http://openclassroom.stanford.edu/MainFolder/DocumentPage.php?course=MachineLearning&doc=exercises/ex2/ex2.html" rel="nofollow noreferrer">This is the link</a> </p>
<p>I try to implement the 1st assignment of this course. <stro... | https://stackoverflow.com/questions/52862164/gradient-descent-search-implemented-in-matlab-theta1-incorrect |
Question: <p>I'm trying to use <code>tf.train.GradientDescentOptimizer().minimize(loss)</code> to get the minimum value of the loss function. But the loss function is very complicated and I need to use numpy to calculate the value, so I use <code>tf.py_func</code> to change the output to tensor again and try to use gra... | https://stackoverflow.com/questions/55266743/using-tf-py-func-as-loss-function-to-implement-gradient-descent |
Question: <p>I'm struggling to make the gradient descent function I already have into one for stochastic gradient descent. I have the following:</p>
<pre><code> gd <- function(f, grad, y, X, theta0, npars, ndata, a, niters) {
theta <- matrix(data=NA, nrow=niters, ncol=npars)
cost <- vector(mode="numeric"... | https://stackoverflow.com/questions/54523274/how-do-i-implement-stochastic-gradient-descent-from-the-following-gradient-desce |
Question: <p>I am trying to implement and train an SVM multi-class classifier from scratch using python and numpy in jupyter notebooks.</p>
<p>I have been using the CS231n course as my base of knowledge, especially this page: <a href="https://cs231n.github.io/optimization-1/" rel="nofollow noreferrer">https://cs231n.gi... | https://stackoverflow.com/questions/79055573/what-is-wrong-with-my-gradient-descent-implementation-svm-classifier-with-hinge |
Question: <p>I am a student learning deep learning.
These days, I am trying to see the plot of a loss function with respect to weights and bias.
Especially, I want to apply gradient descent method to get smooth lines rather than random characteristics orginated from other optimizers.</p>
<p>Keras framework offers vari... | https://stackoverflow.com/questions/58759354/how-can-i-implement-plain-gradient-descent-with-keras |
Question: <p>I need to convert a training with stochastic gradient descent in mini batch gradient descent.
I report a simple example of a neural network with only 4 training sample so we can for example implement a batch size of 2 only for understand how to change the training part.</p>
<p>This is the simple example of... | https://stackoverflow.com/questions/64172528/convert-stochastic-gradient-descent-to-mini-batch-gradient-descent |
Question: <p>I was trying to learn the gradient descent algorithm purely for fun and I made some code that seems to work event though it get stuck in a local minimum sometimes</p>
<p>but sometimes when I run it works and sometimes it gives an overflow error</p>
<h3>Output when failed:</h3>
<pre><code>[2 4 6 8]
E:\Proje... | https://stackoverflow.com/questions/74264293/numpy-overflow-error-when-implementing-gradient-descent-algorithm |
Question: <p>I am trying to implement the gradient descent algorithm with fixed step size on MATLAB.\</p>
<pre><code>syms x1 x2 x3 x4
f(x1,x2,x3,x4) = (x1+10*x2)^2 + 5*(x3-x4)^2 + (x2-2*x3)^4 + 10*(x1-x4)^4 ;
grad_f = gradient(f);
xk = [3;-1;0;1];
while euclidian(grad_f(xk(1),xk(2),xk(3),xk(4)),4) > 0.01
xk = xk... | https://stackoverflow.com/questions/67466602/trying-to-implement-gradient-descent-algorithm-with-fixed-step-size |
Question: <p>I have encountered this question in an online test. I am looking for advice on what approach to use, rather than a full solution.</p>
<p>You are walking on a mountain. You want to descend to the lowest point on the mountain and choose to apply a gradient descent to plan your route. the height at any locati... | https://stackoverflow.com/questions/70040011/implementing-a-gradient-descent-from-a-single-point-in-numpy |
Question: <p>I have gone through many codes in stack overflow and made my own on same line. there is some problem with this code I am unable to understand. I am storing the value theta1 and theta 2 and also the cost function for analysis purpose.
The data for x and Y can be downloaded from this
<a href="http://opencla... | https://stackoverflow.com/questions/21799435/gradient-descent-matlab-implementation |
Question: <p>I am supposed to implement gradient descent for linear regression. Here is the implementation:</p>
<pre><code>class SimpleLinearRegressionModel():
def __init__(self, x, y, theta, alpha):
self.x = x
self.y = y
self.theta = theta
self.alpha = alpha
'''
Equation f... | https://stackoverflow.com/questions/75255159/implementation-of-gradient-descent-is-very-inefficient-and-does-not-work-in-all |
Question: <p>I am working with the R programming language. I am trying to perform Stochastic Gradient Descent on custom defined functions.</p>
<p>For instance, here is an example of using Gradient Descent to optimize a custom function (using the well established "pracma" library):</p>
<pre><code># define func... | https://stackoverflow.com/questions/71120229/stochastic-gradient-descent-on-custom-functions |
Question: <p>I am trying to implement a basic way of the stochastic gradient desecent with multi linear regression and the L2 Norm as loss function.</p>
<p>The result can be seen in this picture:</p>
<p><a href="https://i.sstatic.net/yB5My.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/yB5My.png" alt="e... | https://stackoverflow.com/questions/64739896/implementing-stochastic-gradient-descent |
Question: <p>I am trying to create a Linear regression model that uses batch gradient descent but the error or mse value never decreases. The LinearModel is just a template class that initializes the hyperparameters (step_size=0.001, max_iter=10000, eps=0.001, theta_0=None, verbose=True)</p>
<pre><code># The data is st... | https://stackoverflow.com/questions/77095271/my-python-implementation-of-gradient-descent-is-not-working-well |
Question: <p>Here's the Jupyter Notebook I used for this practice: <a href="https://drive.google.com/file/d/18-OXyvXSit5x0ftiW9bhcqJrO_SE22_S/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/18-OXyvXSit5x0ftiW9bhcqJrO_SE22_S/view?usp=sharing</a></p>
<p>I was practicing simple Linear Regressi... | https://stackoverflow.com/questions/59406021/batch-gradient-descent-with-python-not-converging |
Question: <p>I am trying question 9.30 in the book 'Convex Optimization' by Boyd. But for some reason I can't make the backtrack line search work. Here is my code:</p>
<pre><code>import numpy as np
n, m = 100, 200
A = np.random.randn(m, n)
a, b = 0.01, 0.5
gtol = 1e-3
def f(x):
# return - np.sum(np.log(1-x*x)) -... | https://stackoverflow.com/questions/74258007/gradient-descent-algo-implementation |
Question: <p>I'm working on a machine learning project in PyTorch where I need to optimize a model using the full batch gradient descent method. The key requirement is that the optimizer should use all the data points in the dataset for each update. My challenge with the existing torch.optim.SGD optimizer is that it do... | https://stackoverflow.com/questions/78102637/how-to-implement-full-batch-gradient-descent-with-nesterov-momentum-in-pytorch |
Question: <p>The paper <a href="http://eb.host.cs.st-andrews.ac.uk/drafts/effects.pdf" rel="noreferrer" title="Edwin C. Brady (2013?): 'Programming and reasoning with algebraic effects and dependent types'">"Programming and reasoning with algebraic effects and dependent types" by Edwin C. Brady</a> on effects i... | https://stackoverflow.com/questions/31335805/monad-transformers-more-powerful-than-effects-examples |
Question: <p>Hackage has several packages for monad transformers:</p>
<ul>
<li><a href="http://hackage.haskell.org/package/mtl" rel="noreferrer">mtl</a>: Monad transformer library</li>
<li><a href="http://hackage.haskell.org/package/transformers" rel="noreferrer">transformers</a>: Concrete functor and monad transforme... | https://stackoverflow.com/questions/2769487/mtl-transformers-monads-fd-monadlib-and-the-paradox-of-choice |
Question: <p>I was referring to this answer from stackoverflow but I can't get any leads regarding my problem: [https://stackoverflow.com/questions/63141267/importerror-cannot-import-name-automodelwithlmhead-from-transformers][1]</p>
<p>This is the code that I ran:</p>
<pre><code>import transformers
from transformers i... | https://stackoverflow.com/questions/64112358/transformer-cannot-import-name-automodelwithlmhead-from-transformers |
Question: <p>Running the below code downloads a model - does anyone know what folder it downloads it to?</p>
<pre><code>!pip install -q transformers
from transformers import pipeline
model = pipeline('fill-mask')
</code></pre>
Answer: <p><strong>Update 2023-05-02:</strong> The cache location has changed again, and is... | https://stackoverflow.com/questions/61798573/where-does-hugging-faces-transformers-save-models |
Question: <p>I have a problem to which a stack of monad transformers (or even one monad transformer) over <code>IO</code>. Everything is good, except that using lift before every action is terribly annoying! I suspect there is really nothing to do about that, but I thought I'd ask anyway.</p>
<p>I am aware of lifting ... | https://stackoverflow.com/questions/9054731/avoiding-lift-with-monad-transformers |
Question: <p>Following through the <a href="https://huggingface.co/docs/transformers/main/main_classes/quantization" rel="noreferrer">Huggingface quantization guide</a>, I installed the following:</p>
<pre class="lang-bash prettyprint-override"><code>pip install transformers accelerate bitsandbytes
</code></pre>
<p>(It... | https://stackoverflow.com/questions/75563949/huggingface-transformers-cannot-import-bitsandbytesconfig-from-transformers |
Question: <p>I am new to Haskell but understand how Monad Transformers can be used.
Yet, I still have difficulties grabbing their claimed advantage over passing parameters to function calls.</p>
<p>Based on the wiki <a href="http://www.haskell.org/haskellwiki/Monad_Transformers_Explained" rel="noreferrer">Monad Transf... | https://stackoverflow.com/questions/12968351/monad-transformers-vs-passing-parameters-to-functions |
Question: <p>I want to use some of the models available through huggingface. I am having the hardest time even getting started. Can anyone help me identify and solve this problem?</p>
<p>I am using Kubuntu 24.04.</p>
<hr />
<p>First, I create and activate a virtual environment within which to install transformers.</p>
... | https://stackoverflow.com/questions/79031959/problem-loading-transformers-modulenotfounderror-no-module-named-transformers |
Question: <p>There are many different monad transformers libraries on Hackage. A few seem to get more attention than the others. To name a few: mtl (current version depending on transformers for some reason), transformers, monadLib, monads-tf, mtlx, contstuff.</p>
<p>Which one should be preferred and why? What are the... | https://stackoverflow.com/questions/5797091/monad-transformers-libraries-which-one-to-use |
Question: <p>I can't figure out how to use transformers-cli on Windows. I got it working on Google Colab, and am using it in the meantime.</p>
<p>[EDIT]</p>
<p>Here's the process that I'm going through, what I expect, and what is happening:</p>
<p><strong>I'm on a Windows System (brackets are the exact commands I'm ... | https://stackoverflow.com/questions/61579248/using-transformers-cli-on-windows |
Question: <p>I am trying out the transformers pipeline from huggingface:</p>
<p><a href="https://github.com/huggingface/transformers#installation" rel="nofollow noreferrer">https://github.com/huggingface/transformers#installation</a></p>
<p><a href="https://i.sstatic.net/j8p4E.png" rel="nofollow noreferrer"><img src="h... | https://stackoverflow.com/questions/61073049/transformers-pipeline-from-huggingface |
Question: <p>I'm following the transformer's pretrained model <a href="https://huggingface.co/joeddav/xlm-roberta-large-xnli?text=%0A&candidate_labels=&multi_class=true" rel="noreferrer">xlm-roberta-large-xnli</a> example</p>
<pre><code>from transformers import pipeline
classifier = pipeline("zero-shot-cla... | https://stackoverflow.com/questions/65431837/transformers-v4-x-convert-slow-tokenizer-to-fast-tokenizer |
Question: <p>I am trying to follow <a href="https://towardsdatascience.com/run-bloom-the-largest-open-access-ai-model-on-your-desktop-computer-f48e1e2a9a32" rel="nofollow noreferrer">this article</a> to use the <code>AutoModelForCasualLM</code> from <code>transformers</code> to generate text with bloom. But I keep gett... | https://stackoverflow.com/questions/75191536/transformers-automodelforcasuallm-cannot-be-imported |
Question: <pre><code>chaquopy {
productFlavors {
getByName("py310") { version = "3.10" }
getByName("py311") { version = "3.11" }
}
defaultConfig {
pip {
// Install only the pipeline module from transformers with version 4.12.0
... | https://stackoverflow.com/questions/78420548/transformers-in-android-studio-chaquopy |
Question: <p>conda by default installing transformers 2.x however pip installs 4.x by default which is what I want but via conda.</p>
<p>If I install by specifying the latest distribution file from conda-forge…
<code>conda install https://anaconda.org/conda-forge/transformers/4.16.2/download/noarch/transformers-4.16.2-... | https://stackoverflow.com/questions/71754258/huggingface-transformers-conda-install-issue |
Question: <p><a href="https://i.sstatic.net/wZejL.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/wZejL.png" alt="enter image description here" /></a></p>
<blockquote>
<p>1 import pandas as pd
2 import torch
----> 3 from transformers import GPT2Tokenizer, GPT2ForQuestionAnswering, AdamW
4 from transfo... | https://stackoverflow.com/questions/75617250/cannot-import-name-gpt2forquestionanswering-from-transformers |
Question: <p>Currently I am using transformers(3.0.2) and python(3.7.3) which encountered the below error:</p>
<blockquote>
<p><strong>cannot import name 'TFBertForQuestionAnswering' from 'transformers'</strong></p>
</blockquote>
<pre><code>from transformers import BertTokenizer, TFBertForQuestionAnswering
model = TFB... | https://stackoverflow.com/questions/62907901/cannot-import-name-tfbertforquestionanswering-from-transformers |
Question: <p>Is there any performance improvement if I use a custom Java transformer in place of an XSLT transformer in Mule?</p>
<p>I have a cxf proxy-service and proxy-client pattern, and my transformers are being used to change the payload so that it is a valid input for subsequent SOAP web-service calls.</p>
Ans... | https://stackoverflow.com/questions/11421379/mule-esb-xslt-transformers-or-java-transformers |
Question: <p><strong>cannot import 'AutoModelForSequenceClassification' from 'transformers'</strong></p>
<p>The code is</p>
<pre><code>from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
t = AutoTokenizer.from_pretrained('/some/directory')
m = AutoModelForSequenceClassification.from_pr... | https://stackoverflow.com/questions/66909773/cannot-import-automodelforsequenceclassification-from-transformers |
Question: <p>I have the following problem to load a transformer model. The strange thing is that it work on google colab or even when I tried on another computer, it seems to be version / cache problem but I didn't found it.</p>
<pre class="lang-py prettyprint-override"><code>from sentence_transformers import SentenceT... | https://stackoverflow.com/questions/68528187/cant-load-transformers-models |
Question: <p>I'm using the Huggingface's Transformers pipeline function to download the model and the tokenizer, my Windows PC downloaded them but I don't know where they are stored on my PC. Can you please help me? <a href="https://i.sstatic.net/eHRNO.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/eHRN... | https://stackoverflow.com/questions/64310515/transformers-pipeline-model-directory |
Question: <p>I try to train a GPT2 model on my own data</p>
<pre><code>from transformers import GPT2Tokenizer, GPT2LMHeadModel
from transformers import TextDataset, DataCollatorForLanguageModeling
from transformers import TFTrainer, TFTrainingArguments
</code></pre>
<p>but I get the error "cannot import name 'TFTr... | https://stackoverflow.com/questions/78661481/can-not-import-tftrainer-from-transformers |
Question: <p>I am trying to import BertModel from transformers, but it fails. This is code I am using</p>
<pre><code>from transformers import BertModel, BertForMaskedLM
</code></pre>
<p>This is the error I get</p>
<pre><code>ImportError: cannot import name 'BertModel' from 'transformers'
</code></pre>
<p>Can anyone... | https://stackoverflow.com/questions/62386631/cannot-import-bertmodel-from-transformers |
Question: <p>This is my first post and I am new to coding, so please let me know if you need more information. I have been running some AI to generate artwork and it has been working, but when I reloaded it the python script won't work and it is now saying "No module named 'transformers'". Can anyone help me ... | https://stackoverflow.com/questions/71012012/modulenotfounderror-no-module-named-transformers |
Question: <p>I have transformers 4.25.1 and Keras 3.4.1 with Python 3.9 under Windows.
<code>permutation_importance</code> uses <code>transformers\utils\import_utils.py</code>
which produces:</p>
<pre><code>line 1095, in _get_module
raise RuntimeError(
RuntimeError: Failed to import transformers.modeling_tf_utils
... | https://stackoverflow.com/questions/78990350/transformers-no-module-named-keras-engine |
Question: <p>I'm doing a NLP project on vscode " amazon reviews sentiment analyzer" every thing is going ok until I reached the part for importing transformers</p>
<p>when I'm installing transformers from pip Im getting this error :</p>
<pre><code>error: subprocess-exited-with-error
× Preparing metadata (p... | https://stackoverflow.com/questions/77413586/issue-installing-transformers |
Question: <p>Running below command after installing python 3.10.</p>
<p>pip3 install -U sentence-transformers</p>
<ol>
<li>List item</li>
</ol>
<p>ERROR: Cannot install sentence-transformers==0.1.0, sentence-transformers==0.2.0, sentence-transformers==0.2.1, sentence-transformers==0.2.2, sentence-transformers==0.2.3, s... | https://stackoverflow.com/questions/71083239/unable-to-install-sentence-transformers-getting-error |
Question: <p>I'm getting below error when running 'import transformers', even though I have installed in the same vitual env. I'm using python 3.8</p>
<pre><code>ModuleNotFoundError: No module named 'transformers'
</code></pre>
<p>Error:</p>
<p><a href="https://i.sstatic.net/7B3Sb.png" rel="nofollow noreferrer">enter ... | https://stackoverflow.com/questions/74607244/python-error-modulenotfounderror-no-module-named-transformers |
Question: <p>I am using Anaconda, python 3.7, windows 10.</p>
<p>I tried to install transformers by <a href="https://huggingface.co/transformers/" rel="nofollow noreferrer">https://huggingface.co/transformers/</a> on my env.
I am aware that I must have either pytorch or TF installed, I have pytorch installed - as seen ... | https://stackoverflow.com/questions/62538079/hugginface-transformers-module-not-recognized-by-anaconda |
Question: <h2 id="environment-info-f7cj">Environment info</h2>
<ul>
<li><code>transformers</code> version: 4.9.0</li>
<li>Platform: Linux-4.15.0-151-generic-x86_64-with-glibc2.27</li>
<li>Python version: 3.9.2</li>
<li>PyTorch version (GPU?): 1.7.1+cu101 (False)</li>
<li>Tensorflow version (GPU?): 2.5.0 (False)</li>
<l... | https://stackoverflow.com/questions/68499238/cannot-import-pipeline-after-successful-transformers-installation |
Question: <p>I have successfully installed transformers package in my Jupyter Notebook from Anaconda administrator console using the command '<code>conda install -c conda-forge transformers</code>'.</p>
<p>However when I try to load the transformers package in my Jupyter notebook using '<code>import transformers</code>... | https://stackoverflow.com/questions/68997701/import-of-transformers-package-throwing-value-error |
Question: <p>I am having trouble importing TFBertModel, BertConfig, BertTokenizerFast. I tried the latest version of transformers, tokenizer==0.7.0, and transformers.modeling_bert but they do not seem to work. I get the error</p>
<p><code>from transformers import TFBertModel, BertConfig, BertTokenizerFast</code></p>
... | https://stackoverflow.com/questions/64823301/from-transformers-import-tfbertmodel-bertconfig-berttokenizerfast |
Question: <p>I am new to monad transformers, so sorry easy question.
I have value <code>val :: MaybeT IO String</code> and function <code>fn :: String -> IO [String]</code>.
So after binding, I have <code>val >>= liftM fn :: MaybeT IO (IO [String])</code>. How can I remove duplicate IO monad and get result of ... | https://stackoverflow.com/questions/16637221/monad-transformers-monad-duplication |
Question: <p>Using R and the <code>reticulate</code> package I am trying to use a pre-trained model from Huggingface. This partcular model requires PyTorch and transformers. Both are available in R via reticulate, however even though I can install and load both, the transformers package can't find the PyTorch installat... | https://stackoverflow.com/questions/70262279/r-reticulate-transformers-library-cannot-find-torch |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.