py-why / py-why/EconML

DeepIV negative loss function

Open
#628 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jupyter Notebook
Stars
4.8k
Forks
827
PR merge metrics
No merged PRs in 30d

Description

Hi,
I tried to use the deepiv function with the microsoft tutorial and find the loss value is negative at first and then turns to positive. Here are also two reminders that "output model_344 and model_350 missing from loss dictionary".

How should I fixed this problem? Your help is much appreciated!
Here's my code, I have tried the model with my original data and normalized data:

treatment_model = keras.Sequential([keras.layers.Dense(128, activation='relu', input_shape=(5,)),
keras.layers.Dropout(0.0001),
keras.layers.Dense(64, activation='relu'),
keras.layers.Dropout(0.0001),
keras.layers.Dense(32, activation='relu'),
keras.layers.Dropout(0.0001)])

response_model = keras.Sequential([keras.layers.Dense(128, activation='relu', input_shape=(5,)),
keras.layers.Dropout(0.0001),
keras.layers.Dense(64, activation='relu'),
keras.layers.Dropout(0.0001),
keras.layers.Dense(32, activation='relu'),
keras.layers.Dropout(0.0001),
keras.layers.Dense(1)])

deepIvEst = DeepIV(n_components = 10, # number of gaussians in our mixture density network
m = lambda z, x : treatment_model(keras.layers.concatenate([z,x])), # treatment model
h = lambda t, x : response_model(keras.layers.concatenate([t,x])), # response model
n_samples = 1, # number of samples to use to estimate the response
use_upper_bound_loss = False, # whether to use an approximation to the true loss
n_gradient_samples = 1, # number of samples to use in second estimate of the response (to make loss estimate unbiased)
optimizer='Adagrad', # Keras optimizer to use for training - see https://keras.io/optimizers/
first_stage_options = keras_fit_options, # options for training treatment model
second_stage_options = keras_fit_options) # options for training response model

deepIvEst.fit(Y=y,T=t,X=x,Z=z)

截屏2022-05-27 下午10 09 23

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The report uses DeepIV with Keras models and the Microsoft tutorial; first reproduce it with the provided treatment_model, response_model, and DeepIV.fit call, then inspect the DeepIV loss path and the reported missing model entries. Done means establishing whether the initial negative loss and warnings are expected, or documenting a confirmed bug with a clear validation case.

Written by the indexing model from the issue text.

Assessment

Tech stack
keras, python, tensorflow
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.