Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bugs on Tensorflow tutorials #1738

Merged
merged 1 commit into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
</table>

<p>The following image shows the time difference between the features and labels:</p>
<img class="docs-image" alt="Features and labels for training" src="https://cdn.quantconnect.com/i/tu/ml-keras-function.png">
<img class="docs-image" alt="Features and labels for training" src="https://cdn.quantconnect.com/i/tu/ml-tf.png">

<p>Follow these steps to create a method to build the model:</p>
<ol>
<li>Define some parameters, including the number of factors, neurons, and epochs.</li>
<div class="section-example-container">
<pre class="python">num_factors = 5
num_neurons_1 = 10
num_neurons_2 = 20
num_neurons_2 = 10
num_neurons_3 = 5
self.epochs = 20
self.learning_rate = 0.0001</pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<h4>Warm Up Training Data</h4>
<p>You need historical data to initially train the model at the start of your algorithm. To get the initial training data, in the <code class="csharp">Initialize</code><code class="python">initialize</code> method, make a <a href="/docs/v2/writing-algorithms/historical-data/history-requests">history request</a>.</p>
<div class="section-example-container">
<pre class="python">training_length = 252*2
<pre class="python">training_length = 300
self.training_data = RollingWindow[float](training_length)
history = self.history[TradeBar](self._symbol, training_length, Resolution.DAILY)
for trade_bar in history:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
<div class="section-example-container">
<pre class="python">if prediction > 0:
self.SetHoldings(self._symbol, 1)
else:
elif prediction < 0:
self.SetHoldings(self._symbol, -1)</pre>
</div>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="qc-embed-frame" style="display: inline-block; position: relative; width: 100%; min-height: 100px; min-width: 300px;">
<div class="qc-embed-dummy" style="padding-top: 56.25%;"></div>
<div class="qc-embed-element" style="position: absolute; top: 0; bottom: 0; left: 0; right: 0;">
<iframe class="qc-embed-backtest" height="100%" width="100%" style="border: 1px solid #ccc; padding: 0; margin: 0;" src="https://www.quantconnect.com/terminal/processCache?request=embedded_backtest_01de7b4c0cf9740cbbd43a4542a882a2.html"></iframe>
<iframe class="qc-embed-backtest" height="100%" width="100%" style="border: 1px solid #ccc; padding: 0; margin: 0;" src="https://www.quantconnect.com/terminal/processCache?request=embedded_backtest_036ce75f20b3e7162f5179fd08947bcb.html"></iframe>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
<li>Loop through the DataFrame of historical prices and collect the features.</li>

<div class="section-example-container">
<pre class="python">lookback = 5
<pre class="python">data = history

lookback = 5
lookback_series = []
for i in range(1, lookback + 1):
df = data['close'].diff(i)[lookback:-1]
Expand All @@ -36,7 +38,7 @@
</div>

<p>The following image shows the format of the features DataFrame:</p>
<img class="docs-image" src="https://cdn.quantconnect.com/i/tu/tf-x.png" alt="Features and labels for training">
<img class="docs-image" src="https://cdn.quantconnect.com/i/tu/ml-tf.png" alt="Features and labels for training">

<li>Select the close column and then call the <code>shift</code> method to collect the labels.</li>
<div class="section-example-container">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ <h4>Build the Model</h4>
<div class="section-example-container">
<pre class="python">num_factors = X_test.shape[1]
num_neurons_1 = 10
num_neurons_2 = 20
num_neurons_2 = 10
num_neurons_3 = 5
epochs = 20
learning_rate = 0.0001</pre>
Expand Down