Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7892465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:52:36+00:00 2026-06-03T06:52:36+00:00

fminunc is returning ‘User objective function returned complex; trying a new point…’ when ‘iter-detailed’

  • 0

fminunc is returning ‘User objective function returned complex; trying a new point…’ when ‘iter-detailed’ is on. I know it is because of my cost function, for some reason it is returning a complex component (to be precise it’s returning J = NaN + NaNi). Any ideas as to why it is doing this, and how I can fix it?
P.S. I have a very large set features(about 1000), could it be that it’s going over the max value or accuracy?
P.s. cost function & gradient:

hyp = sigmoid(X * theta);
reg = (lambda/(2*m))*sum((theta(2:end).^2));

J = (1/m * sum((-y .* log(hyp)) - ((1-y) .* log(1-hyp)))) + reg;

grad(1) = (1/m * ((hyp-y)' * X(:,1)))';
grad(2:end) = (1/m * ((hyp-y)' * X(:,2:end)))' + (lambda/m * theta(2:end));
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T06:52:38+00:00Added an answer on June 3, 2026 at 6:52 am

    Any chance you’re hitting a weird confluence of bugs where:

    • sigmoid(X*theta) is negative OR greater than one (which would give you the complex part when you take its log in line 3 ); and
    • either m or y is NaN?

    I hadn’t noticed this before, but if a NaN interacts with a complex number, you get a “complex” NaN.

    >> (1+2i) * nan
    
    ans =
    
          NaN +    NaNi
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a complex objective function I am looking to optimize. The optimization problem
I have developed a program in Octave to which I would like to add
f = @(w) sum(log(1 + exp(-t .* (phis * w'))))/size(phis, 1) + coef *
I there any way I can get the the cost history or the values
I'm performing machine learning on a 25 x 125 image set. After getting the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.