Skip to content

Instantly share code, notes, and snippets.

View skaae's full-sized avatar

Søren Kaae Sønderby skaae

View GitHub Profile
import tensorflow as tf
data_arr = [
{
"img": np.random.randn(10, 30)
},
{
"img": np.random.randn(10, 30)
}
]
@skaae
skaae / data.py
Created August 29, 2019 14:01
tf.data
# Skriv records fil med et sample og forsoeg at loade det igen med tf.data
import numpy as np
import tensorflow as tf
## WRITE SINGLE EXAMPLE
label = 1
FILEPATH = "TEST_RECORDS"
@skaae
skaae / gist:f434450b16df01739bada8a92fcfba97
Created March 18, 2017 12:57
build cudnn 6.05 -> torch report 5.15
(pytorch_build) sorson@hyperion:~$ git clone https://github.com/pytorch/pytorch.git
Cloning into 'pytorch'...
remote: Counting objects: 24898, done.
remote: Compressing objects: 100% (38/38), done.
remote: Total 24898 (delta 8), reused 0 (delta 0), pack-reused 24860
Receiving objects: 100% (24898/24898), 15.81 MiB | 7.68 MiB/s, done.
Resolving deltas: 100% (18207/18207), done.
Checking connectivity... done.
(pytorch_build) sorson@hyperion:~$ cd pytorch
(pytorch_build) sorson@hyperion:~/pytorch$ export CUDA_HOME=/usr/local/cuda
import numpy as np
import theano
import theano.tensor as T
from lasagne import nonlinearities
from lasagne import init
from lasagne.utils import unroll_scan
from lasagne.layers import MergeLayer, Layer, InputLayer, DenseLayer
from lasagne.layers import helper
from lasagne.layers import Gate
def fasta_names_to_dict(fasta_filename):
handin6.py
"""Extract FASTA IDs from file to dictionary"""
names_dict = {}
fasta_file = open(fasta_filename)
for line in fasta_file:
def fasta_names_to_list(fasta_filename):
'''Extract FASTA IDs from file to list'''
names = []
# Open fasta file
fasta_file = open(fasta_filename)
# Iterate over lines
for line in fasta_file:
def find_prot2(fasta_dict, re_str):
'''Search through a dictionary of fasta entries using a regular expression'''
# Import re module
import re # typically imported at top of module file
# Create pattern object
pattern = re.compile(re_str)
# Create empty list to store results
def find_prot(fasta_dict, protein_name):
'''Function to find protein in fasta_dictionary'''
# Check if fasta_dict contains the protein name key
if protein_name in fasta_dict:
# Return biological sequence
return fasta_dict[protein_name]
else:
def read_fasta(fasta_filename):
'''Function to parse a fasta sequence file'''
# Initialize dictionary
fasta_dict = {}
# Open file and iterate over lines
for line in open(fasta_filename):
# Remove newline and other whitespace from end of line
# Initialize column sums
column_sums = [0., 0.]
# Iterate over all rows
for row in row_list:
# For each of the two column values, add to the corresponding sum
column_sums[0] += row[0]
column_sums[1] += row[1]
# Calculate the average by dividing by the length