Skip to content

Instantly share code, notes, and snippets.

View saeedizadi's full-sized avatar

Saeed Izadi saeedizadi

  • Simon Fraser University
  • Vancouver, BC
View GitHub Profile
@saeedizadi
saeedizadi / main.py
Last active May 29, 2019 19:45
python-sample-vsc
def main():
print("hello world!")
if __name__ == "__main__":
main()
model = dict()
optimizer = dict()
criterion = dict()
model['gen'] = UncertaintyNet(ndense=12, nconvs=8, growth_rate=8, scale=scale).cuda()
optimizer['gen'] = optim.Adam(model['gen'].parameters(), lr=lr, weight_decay=weight_decay)
criterion['gen'] = nn.L1Loss().cuda()
model['disc'] = Discriminator().cuda()
optimizer['disc'] = optim.Adam(model['disc'].parameters(), lr=lr, weight_decay=weight_decay)
criterion['disc'] = nn.BCELoss().cuda()
@saeedizadi
saeedizadi / binary_jaccard_index.py
Last active May 11, 2018 23:52
Binary Jaccard Index in Lasagne
def binary_jaccard_index(predictions,targets):
"""Computes the binary (generalized) Jaccard index between predictions and targets.
.. math:: L_i = \\sum_i{\\min(p_i,t_i} / \\sum_i{\\max(p_i,t_i}
Parameters
----------
predictions : Theano tensor
Predictions in [0, 1], such as a sigmoidal output of a neural network,
giving the probability of the positive class
targets : Theano tensor
Targets in {0, 1}, such as ground truth labels.