<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ahmet Hamza Emra on Medium]]></title>
        <description><![CDATA[Stories by Ahmet Hamza Emra on Medium]]></description>
        <link>https://medium.com/@hamza.emra?source=rss-2f013ba3b69------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*W0OC8sQPcDCUvTzs9Xub4w.jpeg</url>
            <title>Stories by Ahmet Hamza Emra on Medium</title>
            <link>https://medium.com/@hamza.emra?source=rss-2f013ba3b69------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 12:40:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hamza.emra/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Introduction to Recommendation Systems with Tensorflow-Recommenders]]></title>
            <link>https://medium.com/@hamza.emra/introduction-to-recommendation-systems-with-tensorflow-recommenders-a116e5e5a940?source=rss-2f013ba3b69------2</link>
            <guid isPermaLink="false">https://medium.com/p/a116e5e5a940</guid>
            <category><![CDATA[recommendation-system]]></category>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[tensorflow-recommenders]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Ahmet Hamza Emra]]></dc:creator>
            <pubDate>Fri, 06 Aug 2021 14:27:16 GMT</pubDate>
            <atom:updated>2021-08-06T14:27:16.731Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*caSc6xgu4_OlJqxRbU7h0A.png" /><figcaption>image from: <a href="https://www.tensorflow.org/recommenders">https://www.tensorflow.org/recommenders</a></figcaption></figure><p>One of the main reasons everybody likes their mother’s or partner’s cooking is that they prepare the specific food for your taste. They know how you like your food based on the interactions that you had. They don’t put too much salt, or they add a little more butter. Of course with their love added, the meal ends up awesome every time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*gwpPVP1J916ej9DOZle2xA.gif" /></figure><p>But when it comes to finding a good movie to watch, you cannot ask your mother to direct one for you. Or you cannot ask your mother to write a book with plot twists, just because you like those. To overcome that small issue, we usually ask for recommendations from people with similar tastes. In this blog post, I will try to explain how to ask computers (AI-ML) to find good book recommendations based on previously rated books. To accomplish that I will be using the new <a href="https://www.tensorflow.org/recommenders">TensorFlow-recommenders</a> library. More importantly, I will be showing how to use your data with tfrs. If you are comfortable with that part, I highly recommend you reading their tutorial.</p><p>The basic idea for a neural-network-based ranking model is to create embeddings to represent each user and book by predicting how much each user rate each book.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*xlovSHbecFSDiDPcJq_trQ.png" /></figure><p>We are going to train the model just like training another regression model. Let’s hop on the coding side with preparing our data. For this example, I will be using Book crossing dataset from Kaggle:</p><p><a href="https://www.kaggle.com/ruchi798/bookcrossing-dataset">Book-Crossing: User review ratings</a></p><pre># Read the data<br>df <strong>=</strong> pd<strong>.</strong>read_csv(&quot;data/Preprocessed_data.csv&quot;, index_col<strong>=</strong>0)<br># Get take the columns we need for training<br>rating_data <strong>=</strong> df[[&quot;user_id&quot;,&quot;book_title&quot;, &quot;rating&quot;]]</pre><pre>dataset <strong>= </strong>tf<strong>.</strong>data<strong>.</strong>Dataset<strong>.</strong>from_tensor_slices((tf<strong>.</strong>cast(rating_data[&#39;user_id&#39;]<strong>.</strong>values<strong>.</strong>reshape(<strong>-</strong>1,1), tf<strong>.</strong>string), tf<strong>.</strong>cast(rating_data[&#39;book_title&#39;]<strong>.</strong>values<strong>.</strong>reshape(<strong>-</strong>1,1), tf<strong>.</strong>string), <br>tf<strong>.</strong>cast(rating_data[&#39;rating&#39;]<strong>.</strong>values<strong>.</strong>reshape(<strong>-</strong>1,1),tf<strong>.</strong>float32)))</pre><pre># Crea</pre><p>Tensorflow data function doesn’t work with ‘object’ datatype, Make sure you change them to proper type for the network.</p><pre>rating_data[&#39;user_id&#39;] <strong>=</strong> rating_data<strong>.</strong>user_id<strong>.</strong>astype(np<strong>.</strong>str)<br>rating_data[&#39;book_title&#39;] <strong>=</strong> rating_data<strong>.</strong>book_title<strong>.</strong>astype(np<strong>.</strong>str)<br>rating_data[&#39;rating&#39;] <strong>=</strong> rating_data<strong>.</strong>rating<strong>.</strong>astype(np<strong>.</strong>float32)</pre><p>The <a href="https://www.tensorflow.org/api_docs/python/tf/data/Dataset">tf.data.Dataset</a> API supports writing descriptive and efficient input pipelines. Let’s convert the data frame to that.</p><pre>dataset <strong>=</strong> tf<strong>.</strong>data<strong>.</strong>Dataset<strong>.</strong>from_tensor_slices((tf<strong>.</strong>cast(rating_data[&#39;user_id&#39;]<strong>.</strong>values<strong>.</strong>reshape(<strong>-</strong>1,1), tf<strong>.</strong>string),    tf<strong>.</strong>cast(rating_data[&#39;book_title&#39;]<strong>.</strong>values<strong>.</strong>reshape(<strong>-</strong>1,1), tf<strong>.</strong>string),<br>tf<strong>.</strong>cast(rating_data[&#39;rating&#39;]<strong>.</strong>values<strong>.</strong>reshape(<strong>-</strong>1,1),tf<strong>.</strong>float32)))</pre><p>This function stores the data but doesn’t name it. Naming the columns always helps in the future. Here is a simple way to do it.</p><pre>@tf<strong>.</strong>function<br><strong>def</strong> rename(x0,x1,x2):<br>    y <strong>=</strong> {}<br>    y[&quot;user_id&quot;] <strong>=</strong> x0<br>    y[&#39;book_title&#39;] <strong>=</strong> x1<br>    y[&#39;rating&#39;] <strong>=</strong> x2<br>    <strong>return</strong> y<br><br>dataset <strong>=</strong> dataset<strong>.</strong>map(rename)</pre><p>Our data is ready for training. The next step is to create our model. Since we are going to use embeddings, we need to find out how many unique userIds and booktitles.</p><pre>books <strong>=</strong> rating_data<strong>.</strong>book_title<strong>.</strong>values<br>users <strong>=</strong> rating_data<strong>.</strong>user_id<strong>.</strong>values<br><br>unique_book_titles <strong>=</strong> np<strong>.</strong>unique(list(books))<br>unique_user_ids <strong>=</strong> np<strong>.</strong>unique(list(users))</pre><p>Now, let us create the model:</p><pre><strong>class</strong> RankingModel(tf<strong>.</strong>keras<strong>.</strong>Model):<br><br>  <strong>def</strong> __init__(self):<br>    super()<strong>.</strong>__init__()<br>    embedding_dimension <strong>=</strong> 32<br><br>    <em># Compute embeddings for users.</em><br>    self<strong>.</strong>user_embeddings <strong>=</strong> tf<strong>.</strong>keras<strong>.</strong>Sequential([<br>      tf<strong>.</strong>keras<strong>.</strong>layers<strong>.</strong>experimental<strong>.</strong>preprocessing<strong>.</strong>StringLookup(<br>        vocabulary<strong>=</strong>unique_user_ids, mask_token<strong>=None</strong>),<br>      tf<strong>.</strong>keras<strong>.</strong>layers<strong>.</strong>Embedding(len(unique_user_ids) <strong>+</strong> 1, embedding_dimension)<br>    ])<br><br>    <em># Compute embeddings for books.</em><br>    self<strong>.</strong>book_embeddings <strong>=</strong> tf<strong>.</strong>keras<strong>.</strong>Sequential([<br>      tf<strong>.</strong>keras<strong>.</strong>layers<strong>.</strong>experimental<strong>.</strong>preprocessing<strong>.</strong>StringLookup(<br>        vocabulary<strong>=</strong>unique_book_titles, mask_token<strong>=None</strong>),<br>      tf<strong>.</strong>keras<strong>.</strong>layers<strong>.</strong>Embedding(len(unique_book_titles) <strong>+</strong> 1, embedding_dimension)<br>    ])<br><br>    <em># Compute predictions.</em><br>    self<strong>.</strong>ratings <strong>=</strong> tf<strong>.</strong>keras<strong>.</strong>Sequential([<br>      <em># Learn multiple dense layers.</em><br>      tf<strong>.</strong>keras<strong>.</strong>layers<strong>.</strong>Dense(256, activation<strong>=</strong>&quot;relu&quot;),<br>      tf<strong>.</strong>keras<strong>.</strong>layers<strong>.</strong>Dense(64, activation<strong>=</strong>&quot;relu&quot;),<br>      <em># Make rating predictions in the final layer.</em><br>      tf<strong>.</strong>keras<strong>.</strong>layers<strong>.</strong>Dense(1)<br>  ])<br><br>  <strong>def</strong> __call__(self, x):<br>    <br>    user_id, book_name <strong>=</strong> x<br>    user_embedding <strong>=</strong> self<strong>.</strong>user_embeddings(user_id)<br>    book_embedding <strong>=</strong> self<strong>.</strong>book_embeddings(book_name)<br><br>    <strong>return</strong> self<strong>.</strong>ratings(tf<strong>.</strong>concat([user_embedding, book_embedding], axis<strong>=</strong>1))</pre><p>One thing to mention here is TensorFlow’s experimental functions make it easy to handle string input for NN. We are going to use this network to make a recommendation but We also need to define the network what the task is. For that, we going to use the tensorflow-recommenders library.</p><pre><strong>class</strong> BooksModel(tfrs<strong>.</strong>models<strong>.</strong>Model):<br><br>  <strong>def</strong> __init__(self):<br>    super()<strong>.</strong>__init__()<br>    self<strong>.</strong>ranking_model: tf<strong>.</strong>keras<strong>.</strong>Model <strong>=</strong> RankingModel()<br>    self<strong>.</strong>task: tf<strong>.</strong>keras<strong>.</strong>layers<strong>.</strong>Layer <strong>=</strong> tfrs<strong>.</strong>tasks<strong>.</strong>Ranking(<br>      loss <strong>=</strong> tf<strong>.</strong>keras<strong>.</strong>losses<strong>.</strong>MeanSquaredError(),<br>      metrics<strong>=</strong>[tf<strong>.</strong>keras<strong>.</strong>metrics<strong>.</strong>RootMeanSquaredError()]<br>    )<br><br>  <strong>def</strong> compute_loss(self, features, training<strong>=False</strong>) <strong>-&gt;</strong> tf<strong>.</strong>Tensor:<br>    print(features)<br>    rating_predictions <strong>=</strong> self<strong>.</strong>ranking_model((features[&#39;user_id&#39;], features[&quot;book_title&quot;]))<br><br>    <em># The task computes the loss and the metrics.</em><br>    <strong>return</strong> self<strong>.</strong>task(labels<strong>=</strong>features[&quot;rating&quot;], predictions<strong>=</strong>rating_predictions)</pre><p>As you can see, when we are computing loss named data notations makes it super easy to call them. Lastly, we need to compile and train our network:</p><pre>model <strong>=</strong> BooksModel()<br>model<strong>.</strong>compile(optimizer<strong>=</strong>tf<strong>.</strong>keras<strong>.</strong>optimizers<strong>.</strong>Adagrad(learning_rate<strong>=</strong>0.1))<br># Cache the dataset <br>cache_dataset <strong>=</strong> dataset<strong>.</strong>cache()<br># Tensorboard <br>logdir <strong>=</strong> &quot;logs/scalars/&quot; <strong>+</strong> datetime<strong>.</strong>now()<strong>.</strong>strftime(&quot;%Y%m%d-%H%M%S&quot;)<br>tensorboard_callback <strong>=</strong> keras<strong>.</strong>callbacks<strong>.</strong>TensorBoard(log_dir<strong>=</strong>logdir)</pre><pre># Training <br>model<strong>.</strong>fit(cache_dataset, epochs<strong>=</strong>5,<br>                    verbose<strong>=</strong>1, callbacks<strong>=</strong>[tensorboard_callback])<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*U8LqPIvp1XMIavfmbW_obQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w_gvv5Yh5LbdORsL3nEU_g.png" /></figure><p>Now it’s time to test the network. Let’s pick a user number “8”, and see what books our network recommend:</p><pre># Create array with users id in every place on the lenght of the unique books number<br>user8 <strong>=</strong> np<strong>.</strong>array([&quot;8&quot; <strong>for</strong> i <strong>in</strong> range(len(unique_book_titles))])<br># Convert it to tf.data.Dataset <br>test_data <strong>= </strong>tf<strong>.</strong>data<strong>.</strong>Dataset<strong>.</strong>from_tensor_slices((tf<strong>.</strong>cast(user8<strong>.</strong>reshape(<strong>-</strong>1,1), tf<strong>.</strong>string), tf<strong>.</strong>cast(unique_book_titles<strong>.</strong>reshape(<strong>-</strong>1,1), tf<strong>.</strong>string)))<br># Name the columns <br>@tf<strong>.</strong>function<br><strong>def</strong> rename_test(x0,x1):<br>    y <strong>=</strong> {}<br>    y[&quot;user_id&quot;] <strong>=</strong> x0<br>    y[&#39;book_title&#39;] <strong>=</strong> x1<br>    <strong>return</strong> y<br>test_data <strong>=</strong> test_data<strong>.</strong>map(rename_test)<br># Now lets make predictions and store them in to dictionary<br>test_ratings <strong>=</strong> {}<br><strong>for</strong> b <strong>in</strong> test_data:<br>    test_ratings[b[&#39;book_title&#39;]<strong>.</strong>numpy()[0]] <strong>=</strong> model<strong>.</strong>ranking_model((b[&#39;user_id&#39;],b[&#39;book_title&#39;]))<br># sort them by score and print the titles <br><strong>for</strong> b <strong>in</strong> sorted(test_ratings, key<strong>=</strong>test_ratings<strong>.</strong>get, reverse<strong>=True</strong>):<br>    print(b)<br></pre><p>And here is the results:</p><pre>b&#39;Deep Thoughts&#39;<br>b&#39;The Wonderful Wizard of Oz (Books of Wonder)&#39;<br>b&#39;Sherlock Holmes and the Red Demon (Sherlock Holmes Mysteries (Penguin))&#39;<br>b&#39;Heat and Other Stories&#39;<br>b&#39;The Berenstain Bear Scouts Save That Backscratcher&#39;<br>b&#39;The Tao of Physics&#39;<br>b&#39;Rough Wrangler, Tender Kisses&#39;<br>b&#39;Say Cheese and Die! (Goosebumps, No 4)&#39;<br>b&#39;Autumn of the Patriarch&#39;<br>b&#39;El Senor De Los Anillos: LA Comunidad Del Anillo (Lord of the Rings (Spanish))&#39;<br>b&#39;Bon Voyage Mr President Penguin 60&#39;<br>b&#39;A Drinking Life : A Memoir&#39;<br>b&#39;The Hunt for Red October (Jack Ryan Novels)&#39;</pre><p>I haven’t read the books that he read, so it is hard to understand if we are making good or bad recommendations 😅 Also, we should have train it for longer for loss to settle, but overall, we are making some progress.</p><p>In conclusion, Tensorflow-recommenders and other high-level TensorFlow functions are amazing and make it easy to handle this problem. I wish they put some more introduction-level posts for their tutorial so everyone can learn. Well, here is something for that. I hope you like and enjoy reading this post. Until next time!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a116e5e5a940" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reinforcement learning with Tensorflow 2.0]]></title>
            <link>https://medium.com/@hamza.emra/reinforcement-learning-with-tensorflow-2-0-cca33fead626?source=rss-2f013ba3b69------2</link>
            <guid isPermaLink="false">https://medium.com/p/cca33fead626</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[reinforcement-learning]]></category>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[tensorflow2]]></category>
            <dc:creator><![CDATA[Ahmet Hamza Emra]]></dc:creator>
            <pubDate>Sat, 09 Mar 2019 20:02:54 GMT</pubDate>
            <atom:updated>2022-08-30T15:10:58.532Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*-GpYqxeC6lef8WNaOhEidw.png" /></figure><p>Reinforcement learning is a fascinating field in artificial intelligence which is really on the edge of cracking real intelligence. With the new Tensorflow update it is more clear than ever. In this series, I will try to share the most minimal and clear implementation of deep reinforcement learning algorithms.</p><p>Please check out <a href="https://medium.com/tensorflow/test-drive-tensorflow-2-0-alpha-b6dd1e522b01">this post</a> to get started with Tensorflow 2.0</p><p>Before we begin to code, let’s start with what is Reinforcement learning and what makes it different. In most general terms RL is What you do — How to map situations to actions — so as to maximize the numerical reward signals or minimize penalties. It is basically encouraging action with good reward and discouraging actions with any penalties. It is the same as how we, human, and animals learn.</p><p>Reinforcement learning is part of machine learning. Although it has some similarities with both supervised and unsupervised learning, it is a third separate field. What makes it different is not needing an external supervisor and the concept of a goal.</p><h3>Policy Gradient</h3><p>Today we will go over one of the widely used RL algorithm Policy Gradients. this method is using a neural network to complete the RL task. Let’s go over step by step to see how it works.</p><p>The neural network is one of the best practice to use in supervised learning. It can map features to labels while extracting useful new features on the way. But the challenge with reinforcement learning is we don’t know what is good output. So the agent (player) needs to figure it out by itself. Even though this is a big deal, we have something that can give us clues on determining which actions are good. which is a reward function. Now, our goal is to make actions with good reward more encouraged and actions with negative reward should be discouraged. In most vanilla approach, we can do this by adjusting our gradient according to the reward we get. If you want to learn more about policy gradient methods please check out <a href="https://www.youtube.com/watch?v=S_gwYj1Q-44">this video.</a></p><h3>Credit Assignment Problem</h3><p>One last thing before we start implementations, let’s go over the concept of credit assignment problem. The issue in here is we don’t know which action resulted in that reward. It might be because we did a really good couple of seconds ago and the reward is just delayed. There is no way of knowing which action is responsible for what but we can try to give all of them some part. So what we need to do is go back in all actions and give some degree of reward for each one. This process is called discounting rewards. Here is a small script that does it for us:</p><pre># gamma: discount rate <br>def discount_rewards(r, gamma = 0.8):<br>    discounted_r = np.zeros_like(r)<br>    running_add = 0<br>    for t in reversed(range(0, r.size)):<br>        running_add = running_add * gamma + r[t]<br>        discounted_r[t] = running_add<br>    return discounted_r</pre><h3>Implementation with Tensorflow 2.0</h3><p>With the new functions and eager execution, it is easier than ever before. Let’s start with building our network. In here we just initialize NN with one hidden layer, optimization algorithm and a loss function.</p><pre>model = tf.keras.Sequential()<br>model.add(tf.keras.layers.Dense(32, input_dim = 4, activation=&#39;relu&#39;))<br>model.add(tf.keras.layers.Dense(2, activation = &quot;softmax&quot;))<br>model.build()<br>optimizer = tf.keras.optimizers.Adam(learning_rate = 0.01)<br>compute_loss = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True)</pre><p>Before we start training we need another variable to hold our gradients when we do the backpropagation. Later this will be use-full when we want to make changes in gradients</p><pre>gradBuffer = model.trainable_variables<br>for ix,grad in enumerate(gradBuffer):<br>  gradBuffer[ix] = grad * 0</pre><p>Now our training loop:</p><pre>for e in range(n_episodes):<br>  # reset the enviroment<br>  s = env.reset()</pre><pre>  ep_memory = []<br>  ep_score = 0<br>  done = False </pre><pre>  while not done: </pre><pre>s = s.reshape([1,4])<br>    with tf.GradientTape() as tape:<br>      #forward pass<br>      logits = model(s)<br>      a_dist = logits.numpy()<br>      # Choose random action with p = action dist<br>      a = np.random.choice(a_dist[0],p=a_dist[0])<br>      a = np.argmax(a_dist == a)<br>      loss = compute_loss([a], logits)<br>    grads = tape.gradient(loss, model.trainable_variables)<br>    # make the choosen action <br>    s, r, done, _ = env.step(a)<br>    ep_score +=r<br>    if done: r-=10 # small trick to make training faster<br>    <br>    ep_memory.append([grads,r])</pre><pre>  scores.append(ep_score)<br>  # Discound the rewards <br>  ep_memory = np.array(ep_memory)<br>  ep_memory[:,1] = discount_rewards(ep_memory[:,1])<br>  <br>  for grads, r in ep_memory:<br>    for ix,grad in enumerate(grads):<br>      gradBuffer[ix] += grad * r<br>  <br>  if e % update_every == 0:<br>    optimizer.apply_gradients(zip(gradBuffer, model.trainable_variables))<br>    for ix,grad in enumerate(gradBuffer):<br>      gradBuffer[ix] = grad * 0<br>      <br>  if e % 100 == 0:<br>    print(&quot;Episode  {}  Score  {}&quot;.format(e, np.mean(scores[-100:])))</pre><p>Lets explain the code little bit:</p><pre>s = s.reshape([1,4])<br>with tf.GradientTape() as tape:<br>  logits = model(s)<br>  a_dist = logits.numpy()<br>  # Choose random action with p = action dist<br>  a = np.random.choice(a_dist[0],p=a_dist[0])<br>  a = np.argmax(a_dist == a)<br>  loss = compute_loss([a], logits)<br>grads = tape.gradient(loss, model.trainable_variables)</pre><p>This part is forward propagation and action selection part. The reason we do random action selection is an exploration of the environment. If we choose the best action every time, we cannot be sure to know that is the optimal solution. Also, please note that we calculate the gradients but not apply them.</p><p>Next part is applying the gradient:</p><pre>  # Discound the rewards <br>  ep_memory = np.array(ep_memory)<br>  ep_memory[:,1] = discount_rewards(ep_memory[:,1])<br>  <br>  for grads, r in ep_memory:<br>    for ix,grad in enumerate(grads):<br>      gradBuffer[ix] += grad * r<br>  <br>  if e % update_every == 0:<br>    optimizer.apply_gradients(zip(gradBuffer, model.trainable_variables))<br>    for ix,grad in enumerate(gradBuffer):<br>      gradBuffer[ix] = grad * 0</pre><p>Before we apply the gradient we need to calculate the advantage score. Advantage score is discounted reward for this case. Ergo, the discounted score is calculated then we multiply those scores with our gradient. After a couple of episodes of collecting gradient, we apply and change the weights of our network.</p><p>Lastly, we check the average 100 episodes mean score:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*43v5bIKKIsORik0CMgI3VA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p_S90VBL5k6L0dHPqzrd4Q.gif" /><figcaption>Rendering the result :D</figcaption></figure><p>So this is it, folks! It is really simple and you can apply this to any problem you want. You can find the code in the link below. Also if you want to read more about reinforcement learning using other libraries <a href="https://neptune.ai/blog/the-best-tools-for-reinforcement-learning-in-python">neptune.ai has a great blog post</a>. Check them out!Until next time…</p><p><a href="https://colab.research.google.com/drive/1OBZMWLSU-jZuXWCps16EDNbxnv4Gl-wr">Google Colaboratory</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cca33fead626" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>