<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # 求解常微分方程組 TensorFlow 可用于許多算法實現和過程。 TensorFlow 多功能性的一個很好的例子是實現 ODE 求解器。以數字方式求解 ODE 是一種迭代過程,可以在計算圖中輕松描述。對于這個秘籍,我們將解決 Lotka-Volterra 捕食者 - 獵物系統。 ## 做好準備 該秘籍將說明如何求解常微分方程(ODE)系統。我們可以使用與前兩節類似的方法來更新值,因為我們迭代并解決 ODE 系統。 我們將考慮的 ODE 系統是著名的 Lotka-Volterra 捕食者 - 獵物系統。該系統顯示了捕食者 - 食餌系統如何在給定特定參數的情況下振蕩。 Lotka-Volterra 系統于 1920 年在一篇論文中發表(參見圖 1,標量值,我們的斜率估計,在張量板中可視化)。我們將使用類似的參數來表明可以發生振蕩系統。這是以數學上離散的方式表示的系統: ![](https://img.kancloud.cn/03/7a/037a781451b4017dfcd12c01bb6da99d_2480x220.png) ![](https://img.kancloud.cn/0b/0d/0b0d9f0d504f7626ecb9d0957d7074a5_2390x220.png) 在這里,`X`是獵物,`Y`將成為捕食者。我們通過`a`,`b`,`c`和`d`的值來確定哪個是獵物,哪個是捕食者:對于獵物,`a&gt;0`,`b&lt;0`和捕食者,`c&lt;0`,`d&gt;0`。我們將在 TensorFlow 解決方案中將此離散版本實現到系統中。 ## 操作步驟 1. 我們首先加載庫并開始圖會話: ```py import matplotlib.pyplot as plt import tensorflow as tf sess = tf.Session() ``` 1. 然后我們在圖中聲明我們的常量和變量: ```py x_initial = tf.constant(1.0) y_initial = tf.constant(1.0) X_t1 = tf.Variable(x_initial) Y_t1 = tf.Variable(y_initial) # Make the placeholders t_delta = tf.placeholder(tf.float32, shape=()) a = tf.placeholder(tf.float32, shape=()) b = tf.placeholder(tf.float32, shape=()) c = tf.placeholder(tf.float32, shape=()) d = tf.placeholder(tf.float32, shape=()) ``` 1. 接下來,我們將實現先前引入的離散系統,然后更新`X`和`Y`群體: ```py X_t2 = X_t1 + (a * X_t1 + b * X_t1 * Y_t1) * t_delta Y_t2 = Y_t1 + (c * Y_t1 + d * X_t1 * Y_t1) * t_delta # Update to New Population step = tf.group( X_t1.assign(X_t2), Y_t1.assign(Y_t2)) ``` 1. 我們現在初始化圖并運行離散 ODE 系統,并使用特定參數來說明循環行為: ```py init = tf.global_variables_initializer() sess.run(init) # Run the ODE prey_values = [] predator_values = [] for i in range(1000): # Step simulation (using constants for a known cyclic solution) step.run({a: (2./3.), b: (-4./3.), c: -1.0, d: 1.0, t_delta: 0.01}, session=sess) # Store each outcome temp_prey, temp_pred = sess.run([X_t1, Y_t1]) prey_values.append(temp_prey) predator_values.append(temp_pred) ``` A steady state (and cyclic) solution to this specific system, the Lotka-Volterra equations, very much depends on specific parameters and population values. We encourage the reader to try different parameters and values to see what can happen. 1. 現在,我們可以繪制捕食者和獵物的價值: ```py plt.plot(prey_values, label="Prey") plt.plot(predator_values, label="Predator") plt.legend(loc='upper right') plt.show() ``` 這個繪圖代碼將生成一個屏幕截圖,顯示掠食者和獵物的振蕩種群: ![](https://img.kancloud.cn/95/4c/954c2702bba886034e1995d90c0bbce2_381x256.png) 圖 6:在這里,我們繪制 ODE 解決方案的捕食者和獵物值。事實上,我們可以看到周期確實發生了 ## 工作原理 我們使用 TensorFlow 逐步求解 ODE 系統的離散版本。對于特定參數,我們看到捕食者 - 食餌系統確實可以具有循環解。這在我們的系統生物學上是有意義的,因為如果有太多的捕食者,獵物開始死亡,然后掠食者的食物就會減少,所以他們會死掉,等等。 ## 另見 Lotka,A。J.,關于有機系統中某些節奏關系的分析性說明。 PROC。納特。科學院。 6(1920)( [https://www.ncbi.nlm.nih.gov/pmc/articles/PMC1084562/](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC1084562/) )。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看