简体   繁体   中英

How to implement a custom loss function with canned estimators in Tensorflow?

I am new to tensorflow.

Question : How can I add a custom loss function to a canned estimator like DNNLinearCombinedRegressor ?

Thank you in advance for your help!

I did not find a loss_fn argument to pass in to DNNLinearCombinedRegressor . But it looks straightforward to define any custom estimator:

A good reference is the code for DNNLinearCombinedRegressor .

I believe you need following steps:

  1. define a custom loss_fn (what ever you like)
  2. define or use a RegressionHead that uses the custom loss_fn defined above.
  3. pass the custom head to your own Regressor . Of course, you might need to copy/build your own model_fn as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM