Files
FYS-STK4155/doc/LectureNotes/_build/html/reports/week40.log
T
Morten Hjorth-Jensen 77d85c179c minor update
2023-11-09 17:52:38 +01:00

85 lines
6.6 KiB
Plaintext

Traceback (most recent call last):
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
executenb(
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 1204, in execute
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 84, in wrapped
return just_run(coro(*args, **kwargs))
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 62, in just_run
return loop.run_until_complete(coro)
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 663, in async_execute
await self.async_execute_cell(
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 965, in async_execute_cell
await self._check_raise_for_error(cell, cell_index, exec_reply)
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 862, 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)
Input In [13], in <cell line: 11>()
 7 f8_grad = grad(f8)
 9 x = 8.4
---> 11 print("The derivative of f8 is:",f8_grad(x))
File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/wrap_util.py:20, in unary_to_nary.<locals>.nary_operator.<locals>.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)
File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/differential_operators.py:25, in grad(fun, x)
 18 @unary_to_nary
 19 def grad(fun, x):
 20  """
 21  Returns a function which computes the gradient of `fun` with respect to
 22  positional argument number `argnum`. The returned function takes the same
 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. "
 28 "Try jacobian, elementwise_grad or holomorphic_grad.")
File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/core.py:10, 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()
File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/tracer.py:10, 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
File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/wrap_util.py:15, in unary_to_nary.<locals>.nary_operator.<locals>.nary_f.<locals>.unary_f(x)
 13 else:
 14 subargs = subvals(args, zip(argnum, x))
---> 15 return fun(*subargs, **kwargs)
Input In [13], in f8(x)
 3 def f8(x): # Assume x is an array
----> 4 x[2] = 3
 5 return x*2
TypeError: 'ArrayBox' object does not support item assignment
TypeError: 'ArrayBox' object does not support item assignment