Encoding logic rules in machine learning For some problems you have certain rules that you know for a fact are true. A very simplistic example would be - 

"A grade below 40% is a failing grade" 

There is no ambiguity in the statement and for that system it will always be correct. Encoding such rules within any machine learning model should allow it to avoid simplistic mistakes and theoretically improve accuracy. 

I'm aware there are several niche libraries for this and an entire subfield as well. However how would I combine such logic rules within a typical model (CNN,LSTM ,etc) in a platform like TensorFlow, PyTorch ? 

Edit : What I'm looking forward is to add explicit label rules (similar to what Snorkel [ https://github.com/snorkel-team/snorkel ] uses to generate noisy labels) to help the model learn. These relations while present in the data might be hard for the model to learn or require large amounts of training data/time. In some scenarios a combination of deterministic rules and ML would be better than using either alone.
I would suggest you apply these rules to the output of your model after it has predicted the results.  In your example, if you are building a DNN classifier that predicts pass or fail, then before you return the prediction back to the calling application, simply check the value and update the model results based on the criteria you have established.

I have performed this in various models where the model may return negative results which are impossible.  In those cases, I would perform a simple update to the results data frame such as:

data.loc[data["y-hat"] &lt; 0, "y-hat"] = 0


You can have as many of these types of 'hard-coded' rules as you need. You can even build a dictionary for them and map the results rather than having a series of statements. That obviously depends on the complexity of the rules. 
Hope that helps.