Files
FYS-STK4155/doc/LectureNotes/_build/html/reports/chapter4.log
T
Morten Hjorth-Jensen ad8e128548 update chp 4
2021-09-13 14:14:52 +02:00

85 lines
7.5 KiB
Plaintext

Traceback (most recent call last):
File "/Users/mhjensen/opt/anaconda3/lib/python3.8/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
executenb(
File "/Users/mhjensen/opt/anaconda3/lib/python3.8/site-packages/nbclient/client.py", line 1087, in execute
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
File "/Users/mhjensen/opt/anaconda3/lib/python3.8/site-packages/nbclient/util.py", line 74, in wrapped
return just_run(coro(*args, **kwargs))
File "/Users/mhjensen/opt/anaconda3/lib/python3.8/site-packages/nbclient/util.py", line 53, in just_run
return loop.run_until_complete(coro)
File "/Users/mhjensen/opt/anaconda3/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "/Users/mhjensen/opt/anaconda3/lib/python3.8/site-packages/nbclient/client.py", line 540, in async_execute
await self.async_execute_cell(
File "/Users/mhjensen/opt/anaconda3/lib/python3.8/site-packages/nbclient/client.py", line 832, in async_execute_cell
self._check_raise_for_error(cell, exec_reply)
File "/Users/mhjensen/opt/anaconda3/lib/python3.8/site-packages/nbclient/client.py", line 740, in _check_raise_for_error
raise CellExecutionError.from_cell_and_msg(cell, exec_reply['content'])
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
------------------
import autograd.numpy as np
from autograd import grad
def f8(x): # Assume x is an array
x[2] = 3
return x*2
f8_grad = grad(f8)
x = 8.4
print("The derivative of f8 is:",f8_grad(x))
------------------
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-29-cabc613b8702> in <module>
 9 x = 8.4
 10 
---> 11 print("The derivative of f8 is:",f8_grad(x))

~/opt/anaconda3/lib/python3.8/site-packages/autograd/wrap_util.py in nary_f(*args, **kwargs)
 18 else:
 19 x = tuple(args[i] for i in argnum)
---> 20 return unary_operator(unary_f, x, *nary_op_args, **nary_op_kwargs)
 21 return nary_f
 22 return nary_operator
~/opt/anaconda3/lib/python3.8/site-packages/autograd/differential_operators.py in grad(fun, x)
 23 arguments as `fun`, but returns the gradient instead. The function `fun`
 24 should be scalar-valued. The gradient has the same type as the argument."""
---> 25 vjp, ans = _make_vjp(fun, x)
 26 if not vspace(ans).size == 1:
 27 raise TypeError("Grad only applies to real scalar-output functions. "
~/opt/anaconda3/lib/python3.8/site-packages/autograd/core.py in make_vjp(fun, x)
 8 def make_vjp(fun, x):
 9 start_node = VJPNode.new_root()
---> 10 end_value, end_node = trace(start_node, fun, x)
 11 if end_node is None:
 12 def vjp(g): return vspace(x).zeros()
~/opt/anaconda3/lib/python3.8/site-packages/autograd/tracer.py in trace(start_node, fun, x)
 8 with trace_stack.new_trace() as t:
 9 start_box = new_box(x, t, start_node)
---> 10 end_box = fun(start_box)
 11 if isbox(end_box) and end_box._trace == start_box._trace:
 12 return end_box._value, end_box._node
~/opt/anaconda3/lib/python3.8/site-packages/autograd/wrap_util.py in unary_f(x)
 13 else:
 14 subargs = subvals(args, zip(argnum, x))
---> 15 return fun(*subargs, **kwargs)
 16 if isinstance(argnum, int):
 17 x = args[argnum]
<ipython-input-29-cabc613b8702> in f8(x)
 2 from autograd import grad
 3 def f8(x): # Assume x is an array
----> 4 x[2] = 3
 5 return x*2
 6 
TypeError: 'ArrayBox' object does not support item assignment
TypeError: 'ArrayBox' object does not support item assignment