This file contains 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 tensorflow as tf | |
data_arr = [ | |
{ | |
"img": np.random.randn(10, 30) | |
}, | |
{ | |
"img": np.random.randn(10, 30) | |
} | |
] |
This file contains 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
# 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" |
This file contains 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
(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 |
This file contains 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 | |
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 |
This file contains 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
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: |
This file contains 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
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: |
This file contains 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
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 |
This file contains 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
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: |
This file contains 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
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 |
This file contains 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
# 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 |
NewerOlder