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
class Net(nn.Module): | |
def __init__(self): | |
super().__init__() | |
self.conv1 = nn.Conv2d(1, 10, kernel_size=5) | |
self.conv2 = nn.Conv2d(10, 20, kernel_size=5) | |
self.conv2_drop = nn.Dropout2d() | |
self.fc1 = nn.Linear(320, 50) | |
self.fc2 = nn.Linear(50, 10) | |
def forward(self, x): |
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
shift_right = lambda arr,n: arr if n == len(arr) else arr[(-1*n):] + arr[:((len(arr)-n))] | |
print(shift_right([1, 2, 3, 4, 5], 3)) | |
#[3, 4, 5, 1, 2] |
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
def multiples(input_value=10): | |
results = [] | |
while 1: | |
value = input_value if len(results) == 0 else (len(results) + 1) * input_value | |
results.append(value) | |
yield results | |
our_generator = fibonacci() | |
result = [] |
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 keras.models import Model | |
import matplotlib.pyplot as plt | |
history_object = model.fit_generator(train_generator, samples_per_epoch = | |
len(train_samples), validation_data = | |
validation_generator, | |
nb_val_samples = len(validation_samples), | |
nb_epoch=5, verbose=1) | |
### print the keys contained in the history object |
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
#Cleanup downloaded libraries (remove tarballs and packages): | |
conda clean -tp |
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
#https://dev.to/schwamster/docker-tutorial-with-for-aspnet-core | |
dotnet new webapi | |
dotnet restore | |
dotnet publish -o ./publish | |
#IN DOCKERFILE |
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
#show all stopped containers | |
docker ps --filter "status=exited" | |
docker ps -f "status=exited" | |
#remove image | |
docker rmi image-id | |
#remove container | |
docker rm container-id |
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
data = [(1, ('a','a')), (2, ('z','z')), (3, ('c','c')), (4,('d','d'))] | |
result = sorted(data, reverse=True) | |
print(result) | |
#[(4, ('d', 'd')), (3, ('c', 'c')), (2, ('z', 'z')), (1, ('a', 'a'))] |
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 collections | |
input = [1,2,3,2,1,5,6,5,5,5] | |
result = [item for item, count in collections.Counter(input).items() if count > 1] | |
print(result) | |
#[1, 2, 5] |
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
def tanh(x): | |
return (1.0 - numpy.exp(-2*x))/(1.0 + numpy.exp(-2*x)) | |
def tanh_derivative(x): | |
return (1 + tanh(x))*(1 - tanh(x)) |
NewerOlder