[spam][crazy] advanced coding therapy
[from, if training transformers were an actual data average by tracking symbolic gradients across thresholds] something i’ve done sometimes is try to make a symbolic equation solver. this usually goes away about halfway through, but something that’s interesting about it is that it’s clearly not very complicated to do. it’s also a bit of a big work. anyway it seems it’s useful to have a symbolic algebra framework. maybe i could use a thread like this to draft such things/more. class Expression {}; class OperatorExpression {}; // an expression that is the evaluation of a parameterized operator on operands (could elide into Expression); class Operator {};
class Expression {};
class OperatorExpression {}; // an expression that is the evaluation of a parameterized operator on operands (could elide into Expression);
class Operator {};
Operator addition; Operator subtraction; template <class T> _add(T x, T y) { return x + y; } template <class T> _subtract(T x, T y) { return x - y; } Operator addition = Operator( /* here i’ll take a break to help myself remember the idea of swizzling operands rather than using inverses. if we consider the output of a function as a further operand, than an inverse is simply a different statement of the same relation between groups of numbers, and operators of different arity can be considered in the same manner. i’m sure there’s some mathematical name for this that i haven’t learned, so rather than Addition and Subtraction one approach could be to consider something that combines them, where addition is the solution for the largest operand and subtraction is the solution for one of the smaller ones … */ template <int total_arity> class ScalarRelation {}; /* so what parameterizes a scalar relation? maybe known functions between some of the operands. for addition we know x + y = z how do i specify this: how about here as a type-templated function associated with two numbered operands? i’ll want a way to refer to it, so that it can be bundled into an expression … additionally more is needed than a type-templated function, e.g. i’d want the character “+” got some confusion here */
/* - expressions that form a tree - operator objects in expressions - relation objects that connect operators and inverses to transform expressions */ struct ScalarRelation { int arity; set<Operator> operations; } struct Operator { string name, symbol; ScalarRelation & relation; vector<int> input_idxs; vector<int> output_idxs; }; struct OperatorExpression : Expression { Operator & operator; vector<Expression> inputs; }; /* :D */
participants (1)
-
Undescribed Horrific Abuse, One Victim & Survivor of Many