Skip to content

Commit 42f014e

Browse files
Merge pull request #459 from hsm207/patch-1
Fix deprecation warning
2 parents e8a80e1 + 49c55d6 commit 42f014e

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Diff for: Chapter1_Introduction/Ch1_Introduction_TFP.ipynb

+7-7
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,8 @@
395395
"cumulative_headcounts = tf.gather(tf.cumsum(coin_flip_data), num_trials)\n",
396396
"\n",
397397
"rv_observed_heads = tfp.distributions.Beta(\n",
398-
" concentration1=tf.to_float(1 + cumulative_headcounts),\n",
399-
" concentration0=tf.to_float(1 + num_trials - cumulative_headcounts))\n",
398+
" concentration1=tf.cast(1 + cumulative_headcounts, tf.float32),\n",
399+
" concentration0=tf.cast(1 + num_trials - cumulative_headcounts, tf.float32))\n",
400400
"\n",
401401
"probs_of_heads = tf.linspace(start=0., stop=1., num=100, name=\"linspace\")\n",
402402
"observed_probs_heads = tf.transpose(rv_observed_heads.prob(probs_of_heads[:, tf.newaxis]))"
@@ -1207,8 +1207,8 @@
12071207
"source": [
12081208
"# Set the chain's start state.\n",
12091209
"initial_chain_state = [\n",
1210-
" tf.to_float(tf.reduce_mean(count_data)) * tf.ones([], dtype=tf.float32, name=\"init_lambda1\"),\n",
1211-
" tf.to_float(tf.reduce_mean(count_data)) * tf.ones([], dtype=tf.float32, name=\"init_lambda2\"),\n",
1210+
" tf.cast(tf.reduce_mean(count_data), tf.float32) * tf.ones([], dtype=tf.float32, name=\"init_lambda1\"),\n",
1211+
" tf.cast(tf.reduce_mean(count_data), tf.float32) * tf.ones([], dtype=tf.float32, name=\"init_lambda2\", tf.float32),\n",
12121212
" 0.5 * tf.ones([], dtype=tf.float32, name=\"init_tau\"),\n",
12131213
"]\n",
12141214
"\n",
@@ -1234,7 +1234,7 @@
12341234
"\n",
12351235
" lambda_ = tf.gather(\n",
12361236
" [lambda_1, lambda_2],\n",
1237-
" indices=tf.to_int32(tau * tf.to_float(tf.size(count_data)) <= tf.to_float(tf.range(tf.size(count_data)))))\n",
1237+
" indices=tf.to_int32(tau * tf.cast(tf.size(count_data), tf.float32) <= tf.cast(tf.range(tf.size(count_data)), tf.float32)))\n",
12381238
" rv_observation = tfd.Poisson(rate=lambda_)\n",
12391239
" \n",
12401240
" return (\n",
@@ -1277,7 +1277,7 @@
12771277
" state_gradients_are_stopped=True),\n",
12781278
" bijector=unconstraining_bijectors))\n",
12791279
"\n",
1280-
"tau_samples = tf.floor(posterior_tau * tf.to_float(tf.size(count_data)))\n",
1280+
"tau_samples = tf.floor(posterior_tau * tf.cast(tf.size(count_data)), tf.float32)\n",
12811281
"\n",
12821282
"# tau_samples, lambda_1_samples, lambda_2_samples contain\n",
12831283
"# N samples from the corresponding posterior distribution\n",
@@ -1644,4 +1644,4 @@
16441644
]
16451645
}
16461646
]
1647-
}
1647+
}

0 commit comments

Comments
 (0)