This was actually a bug caused by a small change in numpy between 1.12 and 1.13. We have a fix up on the Master branch of the github repository now.
Answer from Kenneth Moore on Stack OverflowThis was actually a bug caused by a small change in numpy between 1.12 and 1.13. We have a fix up on the Master branch of the github repository now.
I think you may be using an older version of numpy, under which the imag method doesn't return an array. Can you try upgrading to a later version of numpy? I am using 1.12.0 and the code works for me.
Liu: AttributeError: 'float' object has no attribute 'size'
'float' object has no attribute...(beginner)
python - Numpy AttributeError: 'float' object has no attribute 'exp' - Stack Overflow
python - Why I get AttributeError: 'float' object has no attribute '3f'? - Data Science Stack Exchange
Videos
Probably there's something wrong with the input values for X and/or T. The function from the question works ok:
import numpy as np
from math import e
def sigmoid(X, T):
return 1.0 / (1.0 + np.exp(-1.0 * np.dot(X, T)))
X = np.array([[1, 2, 3], [5, 0, 0]])
T = np.array([[1, 2], [1, 1], [4, 4]])
print(X.dot(T))
# Just to see if values are ok
print([1. / (1. + e ** el) for el in [-5, -10, -15, -16]])
print()
print(sigmoid(X, T))
Result:
[[15 16]
[ 5 10]]
[0.9933071490757153, 0.9999546021312976, 0.999999694097773, 0.9999998874648379]
[[ 0.99999969 0.99999989]
[ 0.99330715 0.9999546 ]]
Probably it's the dtype of your input arrays. Changing X to:
X = np.array([[1, 2, 3], [5, 0, 0]], dtype=object)
Gives:
Traceback (most recent call last):
File "/[...]/stackoverflow_sigmoid.py", line 24, in <module>
print sigmoid(X, T)
File "/[...]/stackoverflow_sigmoid.py", line 14, in sigmoid
return 1.0 / (1.0 + np.exp(-1.0 * np.dot(X, T)))
AttributeError: exp
You convert type np.dot(X, T) to float32 like this:
z=np.array(np.dot(X, T),dtype=np.float32)
def sigmoid(X, T):
return (1.0 / (1.0 + np.exp(-z)))
Hopefully it will finally work!
Try this instead,
print(
"{:.3f}% {} ({} sentences)".format(pcent, gender, nsents)
)
Refer the latest docs for more examples and check the Py version!
You could also use {:.3%} instead of {:.3f}%.
It will transform the value into percentages automatically.
That means "{:.3%}".format(0.3) will print "30%" while you have to write "{:.3f}%".format(0.3 * 100) to get "30%" as well.
[Solved - thanks to DisasterArt]
https://codeshare.io/246gXj
I keep getting this error:
AttributeError: 'float' object has no attribute 'time'
I don't see anything wrong? Thanks!
Would you please check your function code. It's not like openerp function code.
Can you check this question link: How add a function in openERP 7?
def _invoiced_rate(self, cr, uid, ids, name, args, context):
amount_untaxed = 1
record_id=ids[0]
res={record_id: 0.0}
if amount_untaxed == 0:
res[record_id] = 100.0
else:
res[record_id] = 50.0
print (res)
return res
I had need to return result in the form of dictionary object. and key should be id of that record. Just replace My function
Credits need to go to Mr.Parth Gajjar @ http://help.openerp.com forum