Create a scalar multiplication node from the left and right leaf dictionaries, each containing id and data.
z=xyHere x and y are the left and right data values, and z is their product.
Return a new dictionary with exactly id, data, grad, op, and parents: id is output_id, data is z as a Python float, grad is 0.0, op is the string "*", and parents is a list containing the original left and right objects in that order.
Input: left={'id':'a','data':2.0}, right={'id':'b','data':3.0}, output_id='c'
Output: {'id':'c','data':6.0,'grad':0.0,'op':'*','parents':[{'id':'a','data':2.0},{'id':'b','data':3.0}]}
Explanation: The output stores the product and retains the exact two input records as its ordered parents.
Input: left={'id':'x','data':-4.0}, right={'id':'y','data':1.5}, output_id='product'
Output: {'id':'product','data':-6.0,'grad':0.0,'op':'*','parents':[{'id':'x','data':-4.0},{'id':'y','data':1.5}]}
Input: left={'id':'zero','data':0.0}, right={'id':'scale','data':-8.0}, output_id='zero_product'
Output: {'id':'zero_product','data':-0.0,'grad':0.0,'op':'*','parents':[{'id':'zero','data':0.0},{'id':'scale','data':-8.0}]}
Dictionary indexing gives access to each leaf’s data field.
A list stores references to its items without copying the dictionaries.
Accepts: object
Accepts: object
Accepts: string
Create a scalar multiplication node from the left and right leaf dictionaries, each containing id and data.
z=xyHere x and y are the left and right data values, and z is their product.
Return a new dictionary with exactly id, data, grad, op, and parents: id is output_id, data is z as a Python float, grad is 0.0, op is the string "*", and parents is a list containing the original left and right objects in that order.
Input: left={'id':'a','data':2.0}, right={'id':'b','data':3.0}, output_id='c'
Output: {'id':'c','data':6.0,'grad':0.0,'op':'*','parents':[{'id':'a','data':2.0},{'id':'b','data':3.0}]}
Explanation: The output stores the product and retains the exact two input records as its ordered parents.
Input: left={'id':'x','data':-4.0}, right={'id':'y','data':1.5}, output_id='product'
Output: {'id':'product','data':-6.0,'grad':0.0,'op':'*','parents':[{'id':'x','data':-4.0},{'id':'y','data':1.5}]}
Input: left={'id':'zero','data':0.0}, right={'id':'scale','data':-8.0}, output_id='zero_product'
Output: {'id':'zero_product','data':-0.0,'grad':0.0,'op':'*','parents':[{'id':'zero','data':0.0},{'id':'scale','data':-8.0}]}
Dictionary indexing gives access to each leaf’s data field.
A list stores references to its items without copying the dictionaries.
Accepts: object
Accepts: object
Accepts: string