user84592 - 1 year ago 75

Python Question

I am studying udacity course: deep learning. Actually it teaches Google's tensorFlow. In Python interactive shell, I define the function softmax, when I invoke it, it says syntaxt error. Why? Any hint.

I have import numpy as np

`>>> import numpy as np`

>>> import tensorflow as tf

>>> def softmax(x):

... return np.exp(x);

... softmax([1])

SyntaxError: invalid syntax

Are there requirment exact number of indention space?

Answer Source

When using interactive, make sure that the `...`

is not there. The compiler will include anything in `...`

in a function, method, while, or for block. To escape from the `...`

, just hit enter again and call the method from `>>>`

.