This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| x = np.array([[0,0], | |
| [0,1], | |
| [1,0], | |
| [1,1],]) | |
| y = np.array([[1], | |
| [0], | |
| [0], | |
| [1]]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| np.random.seed(1) | |
| w1 = np.random.normal(scale=0.1,size=(nb_inp,nb_h1)) | |
| w2 = np.random.normal(scale=0.1,size=(nb_h1,nb_h2)) | |
| w3 = np.random.normal(scale=0.1,size=(nb_h2,nb_out)) | |
| b1 = np.zeros(nb_h1) | |
| b2 = np.zeros(nb_h2) | |
| b3 = np.zeros(nb_out) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| learning_rate = 0.01 | |
| nb_inp = 2 | |
| nb_h1 = 150 | |
| nb_h2 = 150 | |
| nb_out = 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.db.models.signals import post_save | |
| from django.dispatch import receiver | |
| @receiver(post_save, sender=Article) | |
| def set_analytic_to_article(sender, instance, created, **kwargs): | |
| if created : | |
| analytic_obj = Analytic.objects.create(views=0) | |
| instance.analytic = analytic_obj | |
| instance.save() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.db import models | |
| class Article(models.Model): | |
| analytic = models.OneToOneField(on_delete=models.SET_NULL,null=Yrue) | |
| title = models.CharField(max_length=255) | |
| description = models.TextField() | |
| def __str__(self): | |
| return self.title |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.contrib import admin | |
| from .models import Door | |
| admin.site.register(Door) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| INSTALLED_APPS = [ | |
| ... , | |
| 'Door', | |
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.conf.urls import include | |
| from django.urls import path | |
| from rest_framework import routers | |
| from .views import DoorViewSet | |
| router = routers.DefaultRouter() | |
| router.register('door', DoorViewSet) | |
| urlpatterns = [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.shortcuts import render | |
| from rest_framework import viewsets,status | |
| from rest_framework.response import Response | |
| from rest_framework.decorators import action | |
| from .serializers import DoorSerializer | |
| from .models import Door | |
| from .permissions import IsOwnerAndAuthenticated | |
| class DoorViewSet(viewsets.ModelViewSet): | |
| serializer_class = DoorSerializer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from rest_framework import serializers | |
| from .models import Door | |
| class DoorSerializer(serializers.ModelSerializer): | |
| class Meta : | |
| model = Door | |
| fields = ['id','name','opened'] |