Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

Revision 66ac0fc496a31633f9ddf9b8f24152af603a3956 authored by sucugunes on 18 July 2025, 13:12:30 UTC, committed by GitHub on 18 July 2025, 13:12:30 UTC
Update README.md
1 parent 367a306
  • Files
  • Changes
  • 815c7ea
  • /
  • src
  • /
  • fannet
  • /
  • layers_classification.py
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • revision
  • directory
  • content
revision badge
swh:1:rev:66ac0fc496a31633f9ddf9b8f24152af603a3956
directory badge
swh:1:dir:abe6322f5e50803e82ebbb8d06119bda6d340411
content badge
swh:1:cnt:b97e7c66b88d2cfb930919311974042504b0551f

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • revision
  • directory
  • content
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
layers_classification.py
import sys
import os
import random
import scipy
import scipy.sparse.linalg as sla
import numpy as np
import torch
import torch.nn as nn
from .utils import toNP
from .geometry import to_basis, from_basis

import torch.nn.functional as F

from fannet.fanconv import FanConv
        
class Net(torch.nn.Module):
    def __init__(self, in_channels, num_classes, seq_length):    
        super(Net, self).__init__()

        #original network
        self.fc0 = nn.Linear(in_channels, 128)
        self.conv1 = FanConv(128, 256, seq_length)
        self.conv2 = FanConv(256, 256, seq_length)
        self.conv3 = FanConv(256, 256, seq_length)
        self.fc1 = nn.Linear(256, 256)
        self.fc2 = nn.Linear(256, num_classes)
    
        self.reset_parameters()

    def reset_parameters(self):
        self.conv1.reset_parameters()
        self.conv2.reset_parameters()
        self.conv3.reset_parameters()
        nn.init.xavier_uniform_(self.fc0.weight, gain=1)
        nn.init.xavier_uniform_(self.fc1.weight, gain=1)
        nn.init.xavier_uniform_(self.fc2.weight, gain=1)
        nn.init.constant_(self.fc0.bias, 0)
        nn.init.constant_(self.fc1.bias, 0)
        nn.init.constant_(self.fc2.bias, 0)

    def forward(self, x, indices, mass):

        x = x.unsqueeze(0)
        mass = mass.unsqueeze(0)
        indices = indices.unsqueeze(0)

        x = F.elu(self.fc0(x))
        x = F.elu(self.conv1(x, indices))
        x = F.elu(self.conv2(x, indices))
        x = F.elu(self.conv3(x, indices))

        x = F.elu(self.fc1(x))
        x = F.dropout(x, training=self.training)
        x = self.fc2(x)
        
        x = torch.sum(x * mass.unsqueeze(-1), dim=-2) / torch.sum(mass, dim=-1, keepdim=True)
        
        x = x.squeeze(0)
  
        return F.log_softmax(x, dim=-1)
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API