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

85 lines
6.8 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 f9(a): # Assume a is an array with 2 elements
b = np.array([1.0,2.0])
return a.dot(b)
f9_grad = grad(f9)
x = np.array([1.0,0.0])
print("The derivative of f9 is:",f9_grad(x))
------------------
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Input In [23], in <cell line: 11>()
 7 f9_grad = grad(f9)
 9 x = np.array([1.0,0.0])
---> 11 print("The derivative of f9 is:",f9_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 [23], in f9(a)
 3 def f9(a): # Assume a is an array with 2 elements
 4 b = np.array([1.0,2.0])
----> 5 return a.dot(b)
AttributeError: 'ArrayBox' object has no attribute 'dot'
AttributeError: 'ArrayBox' object has no attribute 'dot'