max_stars_repo_path
stringlengths 4
245
| max_stars_repo_name
stringlengths 7
115
| max_stars_count
int64 101
368k
| id
stringlengths 2
8
| content
stringlengths 6
1.03M
|
---|---|---|---|---|
PyObjCTest/test_nsimage.py
|
Khan/pyobjc-framework-Cocoa
| 132 |
49671
|
<reponame>Khan/pyobjc-framework-Cocoa<gh_stars>100-1000
from PyObjCTools.TestSupport import *
import AppKit
from AppKit import *
try:
unicode
except NameError:
unicode = str
class TestNSImageHelper (NSObject):
def image_didLoadRepresentation_withStatus_(self, i, r, s): pass
def image_didLoadPartOfRepresentation_withValidRows_(self, i, r, c): pass
class TestNSImage (TestCase):
def test_compositePoint(self):
# comes straight from ReSTedit. Works on PPC, not on Intel (as of r1791)
ws = AppKit.NSWorkspace.sharedWorkspace()
txtIcon = ws.iconForFileType_("txt")
txtIcon.setSize_( (16,16) )
htmlIcon = ws.iconForFileType_("html")
htmlIcon.setSize_( (16,16) )
comboIcon = AppKit.NSImage.alloc().initWithSize_( (100,100) )
comboIcon.lockFocus()
txtIcon.compositeToPoint_fromRect_operation_((0,0), ((0,0),(16,16)), AppKit.NSCompositeCopy)
htmlIcon.compositeToPoint_fromRect_operation_((8,0), ((8,0),(8,16)), AppKit.NSCompositeCopy)
comboIcon.unlockFocus()
def testConstants(self):
self.assertEqual(NSImageLoadStatusCompleted, 0)
self.assertEqual(NSImageLoadStatusCancelled, 1)
self.assertEqual(NSImageLoadStatusInvalidData, 2)
self.assertEqual(NSImageLoadStatusUnexpectedEOF, 3)
self.assertEqual(NSImageLoadStatusReadError, 4)
self.assertEqual(NSImageCacheDefault, 0)
self.assertEqual(NSImageCacheAlways, 1)
self.assertEqual(NSImageCacheBySize, 2)
self.assertEqual(NSImageCacheNever, 3)
@min_os_level("10.5")
def testConstants10_5(self):
self.assertIsInstance( NSImageNameQuickLookTemplate, unicode)
self.assertIsInstance( NSImageNameBluetoothTemplate, unicode)
self.assertIsInstance( NSImageNameIChatTheaterTemplate, unicode)
self.assertIsInstance( NSImageNameSlideshowTemplate, unicode)
self.assertIsInstance( NSImageNameActionTemplate, unicode)
self.assertIsInstance( NSImageNameSmartBadgeTemplate, unicode)
self.assertIsInstance( NSImageNameIconViewTemplate, unicode)
self.assertIsInstance( NSImageNameListViewTemplate, unicode)
self.assertIsInstance( NSImageNameColumnViewTemplate, unicode)
self.assertIsInstance( NSImageNameFlowViewTemplate, unicode)
self.assertIsInstance( NSImageNamePathTemplate, unicode)
self.assertIsInstance( NSImageNameInvalidDataFreestandingTemplate, unicode)
self.assertIsInstance( NSImageNameLockLockedTemplate, unicode)
self.assertIsInstance( NSImageNameLockUnlockedTemplate, unicode)
self.assertIsInstance( NSImageNameGoRightTemplate, unicode)
self.assertIsInstance( NSImageNameGoLeftTemplate, unicode)
self.assertIsInstance( NSImageNameRightFacingTriangleTemplate, unicode)
self.assertIsInstance( NSImageNameLeftFacingTriangleTemplate, unicode)
self.assertIsInstance( NSImageNameAddTemplate, unicode)
self.assertIsInstance( NSImageNameRemoveTemplate, unicode)
self.assertIsInstance( NSImageNameRevealFreestandingTemplate, unicode)
self.assertIsInstance( NSImageNameFollowLinkFreestandingTemplate, unicode)
self.assertIsInstance( NSImageNameEnterFullScreenTemplate, unicode)
self.assertIsInstance( NSImageNameExitFullScreenTemplate, unicode)
self.assertIsInstance( NSImageNameStopProgressTemplate, unicode)
self.assertIsInstance( NSImageNameStopProgressFreestandingTemplate, unicode)
self.assertIsInstance( NSImageNameRefreshTemplate, unicode)
self.assertIsInstance( NSImageNameRefreshFreestandingTemplate, unicode)
self.assertIsInstance( NSImageNameBonjour, unicode)
self.assertIsInstance( NSImageNameDotMac, unicode)
self.assertIsInstance( NSImageNameComputer, unicode)
self.assertIsInstance( NSImageNameFolderBurnable, unicode)
self.assertIsInstance( NSImageNameFolderSmart, unicode)
self.assertIsInstance( NSImageNameNetwork, unicode)
self.assertIsInstance( NSImageNameMultipleDocuments, unicode)
self.assertIsInstance( NSImageNameUserAccounts, unicode)
self.assertIsInstance( NSImageNamePreferencesGeneral, unicode)
self.assertIsInstance( NSImageNameAdvanced, unicode)
self.assertIsInstance( NSImageNameInfo, unicode)
self.assertIsInstance( NSImageNameFontPanel, unicode)
self.assertIsInstance( NSImageNameColorPanel, unicode)
self.assertIsInstance( NSImageNameUser, unicode)
self.assertIsInstance( NSImageNameUserGroup, unicode)
self.assertIsInstance( NSImageNameEveryone, unicode)
def testMethods(self):
self.assertResultIsBOOL(NSImage.setName_)
self.assertArgIsBOOL(NSImage.setScalesWhenResized_, 0)
self.assertResultIsBOOL(NSImage.scalesWhenResized)
self.assertArgIsBOOL(NSImage.setDataRetained_, 0)
self.assertResultIsBOOL(NSImage.isDataRetained)
self.assertArgIsBOOL(NSImage.setCachedSeparately_, 0)
self.assertResultIsBOOL(NSImage.isCachedSeparately)
self.assertArgIsBOOL(NSImage.setCacheDepthMatchesImageDepth_, 0)
self.assertResultIsBOOL(NSImage.cacheDepthMatchesImageDepth)
self.assertArgIsBOOL(NSImage.setUsesEPSOnResolutionMismatch_, 0)
self.assertResultIsBOOL(NSImage.usesEPSOnResolutionMismatch)
self.assertArgIsBOOL(NSImage.setPrefersColorMatch_, 0)
self.assertResultIsBOOL(NSImage.prefersColorMatch)
self.assertArgIsBOOL(NSImage.setMatchesOnMultipleResolution_, 0)
self.assertResultIsBOOL(NSImage.matchesOnMultipleResolution)
self.assertResultIsBOOL(NSImage.drawRepresentation_inRect_)
self.assertResultIsBOOL(NSImage.isValid)
self.assertResultIsBOOL(NSImage.canInitWithPasteboard_)
self.assertResultIsBOOL(NSImage.isFlipped)
self.assertArgIsBOOL(NSImage.setFlipped_, 0)
self.assertResultIsBOOL(NSImage.isTemplate)
self.assertArgIsBOOL(NSImage.setTemplate_, 0)
def testProtocols(self):
self.assertArgHasType(TestNSImageHelper.image_didLoadPartOfRepresentation_withValidRows_, 2, objc._C_NSInteger)
self.assertArgHasType(TestNSImageHelper.image_didLoadRepresentation_withStatus_, 2, objc._C_NSUInteger)
@min_os_level('10.6')
def testMethods10_6(self):
self.assertArgHasType(NSImage.drawInRect_fromRect_operation_fraction_respectFlipped_hints_,
0, NSRect.__typestr__)
self.assertArgIsBOOL(NSImage.drawInRect_fromRect_operation_fraction_respectFlipped_hints_, 4)
self.assertArgIsBOOL(NSImage.lockFocusFlipped_, 0)
self.assertArgHasType(NSImage.initWithCGImage_size_, 1, NSSize.__typestr__)
self.assertArgHasType(NSImage.CGImageForProposedRect_context_hints_, 0, b'o^' + NSRect.__typestr__)
self.assertArgHasType(NSImage.bestRepresentationForRect_context_hints_, 0, NSRect.__typestr__)
self.assertResultIsBOOL(NSImage.hitTestRect_withImageDestinationRect_context_hints_flipped_)
self.assertArgHasType(NSImage.hitTestRect_withImageDestinationRect_context_hints_flipped_, 0, NSRect.__typestr__)
self.assertArgHasType(NSImage.hitTestRect_withImageDestinationRect_context_hints_flipped_, 1, NSRect.__typestr__)
@min_os_level('10.7')
def testMethods10_7(self):
self.assertResultIsBOOL(NSImage.matchesOnlyOnBestFittingAxis)
self.assertArgIsBOOL(NSImage.setMatchesOnlyOnBestFittingAxis_, 0)
@min_os_level('10.8')
def testMethods10_8(self):
self.assertArgIsBOOL(NSImage.imageWithSize_flipped_drawingHandler_, 1)
self.assertArgIsBlock(NSImage.imageWithSize_flipped_drawingHandler_, 2,
objc._C_NSBOOL + NSRect.__typestr__)
@min_os_level('10.6')
def testConstants10_6(self):
self.assertIsInstance(NSImageHintCTM, unicode)
self.assertIsInstance(NSImageHintInterpolation, unicode)
self.assertIsInstance(NSImageNameFolder, unicode)
self.assertIsInstance(NSImageNameMobileMe, unicode)
self.assertIsInstance(NSImageNameUserGuest, unicode)
self.assertIsInstance(NSImageNameMenuOnStateTemplate, unicode)
self.assertIsInstance(NSImageNameMenuMixedStateTemplate, unicode)
self.assertIsInstance(NSImageNameApplicationIcon, unicode)
self.assertIsInstance(NSImageNameTrashEmpty, unicode)
self.assertIsInstance(NSImageNameTrashFull, unicode)
self.assertIsInstance(NSImageNameHomeTemplate, unicode)
self.assertIsInstance(NSImageNameBookmarksTemplate, unicode)
self.assertIsInstance(NSImageNameCaution, unicode)
self.assertIsInstance(NSImageNameStatusAvailable, unicode)
self.assertIsInstance(NSImageNameStatusPartiallyAvailable, unicode)
self.assertIsInstance(NSImageNameStatusUnavailable, unicode)
self.assertIsInstance(NSImageNameStatusNone, unicode)
@min_os_level('10.8')
def testConstants10_8(self):
self.assertIsInstance(NSImageNameShareTemplate, unicode)
if __name__ == "__main__":
main()
|
19. Backtracking/subsets of an array.py
|
Ujjawalgupta42/Hacktoberfest2021-DSA
| 225 |
49678
|
#Input: nums = [1,2,3]
#Output: [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]]
def subsets(self, nums: List[int]) -> List[List[int]]:
self.result = []
self.helper(nums, 0, [])
return self.result
def helper(self, nums, start, subset):
self.result.append(subset[::])
for i in range(start, len(nums)):
subset.append(nums[i])
self.helper(nums, i + 1, subset)
subset.pop()
|
server/amberalertcn/api/v1/lib/__init__.py
|
fuzhouch/amberalertcn
| 151 |
49689
|
<filename>server/amberalertcn/api/v1/lib/__init__.py
"""
lib
"""
|
python/app/plugins/port/Mysql/Mysql_Weakpwd.py
|
taomujian/linbing
| 351 |
49704
|
#!/usr/bin/env python3
import pymysql
from urllib.parse import urlparse
class Mysql_Weakpwd_BaseVerify:
def __init__(self, url):
self.info = {
'name': 'Mysql 弱口令漏洞',
'description': 'Mysql 弱口令漏洞',
'date': '',
'exptype': 'check',
'type': 'Weakpwd'
}
self.url = url
url_parse = urlparse(self.url)
self.host = url_parse.hostname
self.port = url_parse.port
if not self.port:
self.port = '3306'
def check(self):
"""
检测是否存在漏洞
:param:
:return bool True or False: 是否存在漏洞
"""
for pwd in open('app/password.txt', 'r', encoding = 'utf-8').readlines():
if pwd != '':
pwd = <PASSWORD>.strip()
try:
conn = pymysql.connect(host = self.host, port = int(self.port), user = 'root', password = <PASSWORD>, database = 'mysql')
print ('存在Mysql弱口令,弱口令为:', pwd)
conn.close()
return True
except Exception as e:
print(e)
pass
finally:
pass
print('不存在Mysql弱口令')
return False
if __name__ == "__main__":
Mysql_Weakpwd = Mysql_Weakpwd_BaseVerify('http://10.4.33.38:3306')
Mysql_Weakpwd.check()
|
mathematics_dataset/util/probability.py
|
PhysicsTeacher13/Mathematics_Dataset
| 1,577 |
49728
|
# Copyright 2018 DeepMind Technologies Limited.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Functionality for working with probability spaces and random variables.
Basic recap of probability theory, and thus of classes in this file:
* A probability space is a (finite or infinite) set Omega with a probability
measure defined on this.
* A random variable is a mapping from a probability space to another measure
space.
* An event is a measurable set in a sample space.
For example, suppose a bag contains 3 balls: two red balls, and one white ball.
This could be represented by a discrete probability space of size 3 with
elements {1, 2, 3}, with equal measure assigned to all 3 elements; and a random
variable that maps 1->red, 2->red, and 3->white. Then the probability of drawing
a red ball is the measure in the probability space of the inverse under the
random variable mapping of {red}, i.e., of {1, 2}, which is 2/3.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import abc
import itertools
# Dependency imports
import six
from six.moves import zip
import sympy
@six.add_metaclass(abc.ABCMeta)
class Event(object):
"""Represents an event in a measure space."""
@six.add_metaclass(abc.ABCMeta)
class ProbabilitySpace(object):
"""Represents a probability space."""
@abc.abstractmethod
def probability(self, event):
"""Returns the probability of an event."""
@six.add_metaclass(abc.ABCMeta)
class RandomVariable(object):
"""Random variable; a mapping from a probability space to a measure space."""
@abc.abstractmethod
def __call__(self, event):
"""Maps an `_Event` in the probability space to one in the sample space."""
@abc.abstractmethod
def inverse(self, event):
"""Maps event in the sample space back to the inverse in the prob. space."""
class DiscreteEvent(Event):
"""Set of discrete values."""
def __init__(self, values):
self._values = values
@property
def values(self):
return self._values
class FiniteProductEvent(Event):
"""Event consisting of cartesian product of events."""
def __init__(self, events):
"""Initializes a `FiniteProductEvent`.
Args:
events: Tuple of `Event`s; resulting event will be cartesian product of
these.
"""
self._events = events
@property
def events(self):
return self._events
def all_sequences(self):
"""Returns iterator of sequences by selecting a single event in each coord.
This assumes that every component event is an instance of `DiscreteEvent`.
Returns:
Iterator over tuples of values.
Raises:
ValueError: If one of the component events is not a `DiscreteEvent`.
"""
if not all(isinstance(event, DiscreteEvent) for event in self._events):
raise ValueError('Not all component events are DiscreteEvents')
values_list = [event.values for event in self._events]
return itertools.product(*values_list)
class CountLevelSetEvent(Event):
"""Event of all sequences with fixed number of different values occurring."""
def __init__(self, counts):
"""Initializes `CountLevelSetEvent`.
E.g., to construct the event of getting two red balls and one green ball,
pass `counts = {red: 2, green: 1}`. (Then `all_sequences()` would return
`[(red, red, green), (red, green, red), (green, red, red)]`.
Args:
counts: Dictionary mapping values to the number of times they occur in a
sequence.
"""
self._counts = counts
self._all_sequences = None
@property
def counts(self):
return self._counts
def all_sequences(self):
"""Returns all sequences generated by this level set."""
if self._all_sequences is None:
# Generate via dynamic programming.
cache = {} # dict mapping tuple -> list of tuples
labels = list(self._counts.keys())
def generate(counts):
"""Returns list of tuples for given `counts` of labels."""
if sum(counts) == 0:
return [()]
counts = tuple(counts)
if counts in cache:
return cache[counts]
generated = []
for i, count in enumerate(counts):
if count == 0:
continue
counts_minus = list(counts)
counts_minus[i] -= 1
counts_minus = tuple(counts_minus)
extensions = generate(counts_minus)
generated += [tuple([labels[i]] + list(extension))
for extension in extensions]
cache[counts] = generated
return generated
self._all_sequences = generate(list(self._counts.values()))
return self._all_sequences
class SequenceEvent(Event):
"""Collection of sequences."""
def __init__(self, sequences):
self._sequences = sequences
def all_sequences(self):
return self._sequences
def normalize_weights(weights):
"""Normalizes the weights (as sympy.Rational) in dictionary of weights."""
weight_sum = sum(six.itervalues(weights))
return {
i: sympy.Rational(weight, weight_sum)
for i, weight in six.iteritems(weights)
}
class DiscreteProbabilitySpace(ProbabilitySpace):
"""Discrete probability space."""
def __init__(self, weights=None):
"""Initializes an `DiscreteProbabilitySpace`.
Args:
weights: Dictionary mapping values to relative probability of selecting
that value. This will be normalized.
"""
self._weights = normalize_weights(weights)
def probability(self, event):
if isinstance(event, DiscreteEvent):
return sum(self._weights[value]
for value in event.values if value in self._weights)
else:
raise ValueError('Unhandled event type {}'.format(type(event)))
@property
def weights(self):
"""Returns dictionary of probability of each element."""
return self._weights
class FiniteProductSpace(ProbabilitySpace):
"""Finite cartesian product of probability spaces."""
def __init__(self, spaces):
"""Initializes a `FiniteProductSpace`.
Args:
spaces: List of `ProbabilitySpace`.
"""
self._spaces = spaces
def all_spaces_equal(self):
return all([self._spaces[0] == space for space in self._spaces])
def probability(self, event):
# Specializations for optimization.
if isinstance(event, FiniteProductEvent):
assert len(self._spaces) == len(event.events)
return sympy.prod([
space.probability(event_slice)
for space, event_slice in zip(self._spaces, event.events)])
if isinstance(event, CountLevelSetEvent) and self.all_spaces_equal():
space = self._spaces[0]
counts = event.counts
probabilities = {
value: space.probability(DiscreteEvent({value}))
for value in six.iterkeys(counts)
}
num_events = sum(six.itervalues(counts))
assert num_events == len(self._spaces)
# Multinomial coefficient:
coeff = (
sympy.factorial(num_events) / sympy.prod(
[sympy.factorial(i) for i in six.itervalues(counts)]))
return coeff * sympy.prod([
pow(probabilities[value], counts[value])
for value in six.iterkeys(counts)
])
raise ValueError('Unhandled event type {}'.format(type(event)))
@property
def spaces(self):
"""Returns list of spaces."""
return self._spaces
class SampleWithoutReplacementSpace(ProbabilitySpace):
"""Probability space formed by sampling discrete space without replacement."""
def __init__(self, weights, n_samples):
"""Initializes a `SampleWithoutReplacementSpace`.
Args:
weights: Dictionary mapping values to relative probability of selecting
that value. This will be normalized.
n_samples: Number of samples to draw.
Raises:
ValueError: If `n_samples > len(weights)`.
"""
if n_samples > len(weights):
raise ValueError('n_samples is more than number of discrete elements')
self._weights = normalize_weights(weights)
self._n_samples = n_samples
@property
def n_samples(self):
"""Number of samples to draw."""
return self._n_samples
def probability(self, event):
try:
all_sequences = event.all_sequences()
except AttributeError:
raise ValueError('Unhandled event type {}'.format(type(event)))
probability_sum = 0
for sequence in all_sequences:
if len(sequence) != len(set(sequence)):
continue # not all unique, so not "without replacement".
p_sequence = 1
removed_prob = 0
for i in sequence:
p = self._weights[i] if i in self._weights else 0
if p == 0:
p_sequence = 0
break
p_sequence *= p / (1 - removed_prob)
removed_prob += p
probability_sum += p_sequence
return probability_sum
class IdentityRandomVariable(RandomVariable):
"""Identity map of a probability space."""
def __call__(self, event):
return event
def inverse(self, event):
return event
class DiscreteRandomVariable(RandomVariable):
"""Specialization to discrete random variable.
This is simply a mapping from a discrete space to a discrete space (dictionary
lookup).
"""
def __init__(self, mapping):
"""Initializes `DiscreteRandomVariable` from `mapping` dict."""
self._mapping = mapping
self._inverse = {}
for key, value in six.iteritems(mapping):
if value in self._inverse:
self._inverse[value].add(key)
else:
self._inverse[value] = set([key])
def __call__(self, event):
if isinstance(event, DiscreteEvent):
return DiscreteEvent({self._mapping[value] for value in event.values})
else:
raise ValueError('Unhandled event type {}'.format(type(event)))
def inverse(self, event):
if isinstance(event, DiscreteEvent):
set_ = set()
for value in event.values:
if value in self._inverse:
set_.update(self._inverse[value])
return DiscreteEvent(set_)
else:
raise ValueError('Unhandled event type {}'.format(type(event)))
class FiniteProductRandomVariable(RandomVariable):
"""Product random variable.
This has the following semantics. Let this be X = (X_1, ..., X_n). Then
X(w) = (X_1(w_1), ..., X_n(w_n))
(the sample space is assumed to be of sequence type).
"""
def __init__(self, random_variables):
"""Initializes a `FiniteProductRandomVariable`.
Args:
random_variables: Tuple of `RandomVariable`.
"""
self._random_variables = random_variables
def __call__(self, event):
if isinstance(event, FiniteProductEvent):
assert len(event.events) == len(self._random_variables)
zipped = list(zip(self._random_variables, event.events))
return FiniteProductEvent(
[random_variable(sub_event)
for random_variable, sub_event in zipped])
else:
raise ValueError('Unhandled event type {}'.format(type(event)))
def inverse(self, event):
# Specialization for `FiniteProductEvent`; don't need to take all sequences.
if isinstance(event, FiniteProductEvent):
assert len(event.events) == len(self._random_variables)
zipped = list(zip(self._random_variables, event.events))
return FiniteProductEvent(tuple(
random_variable.inverse(sub_event)
for random_variable, sub_event in zipped))
# Try fallback of mapping each sequence separately.
try:
all_sequences = event.all_sequences()
except AttributeError:
raise ValueError('Unhandled event type {}'.format(type(event)))
mapped = set()
for sequence in all_sequences:
assert len(sequence) == len(self._random_variables)
zipped = list(zip(self._random_variables, sequence))
mapped_sequence = FiniteProductEvent(tuple(
random_variable.inverse(DiscreteEvent({element}))
for random_variable, element in zipped))
mapped.update(mapped_sequence.all_sequences())
return SequenceEvent(mapped)
|
pygears/lib/rounding.py
|
bogdanvuk/pygears
| 120 |
49732
|
from pygears import gear, datagear, alternative, module
from pygears.typing.qround import get_out_type, get_cut_bits
from pygears.typing import Uint, code, Bool, Int, Fixp, Ufixp
@datagear
def qround(din,
*,
fract=0,
cut_bits=b'get_cut_bits(din, fract)',
signed=b'din.signed') -> b'get_out_type(din, fract)':
res = code(din, Int if signed else Uint) + (Bool(1) << (cut_bits - 1))
return code(res >> cut_bits, module().tout)
# @datagear
# def qround_even(din,
# *,
# fract=0,
# cut_bits=b'get_cut_bits(din, fract)',
# signed=b'din.signed') -> b'get_out_type(din, fract)':
# val_coded = code(din, Int if signed else Uint)
# round_bit = val_coded[cut_bits]
# res = val_coded + Uint([round_bit] + [~round_bit] * (cut_bits - 1))
# return code(res[cut_bits:])
@gear
def truncate(din, *, nbits=2) -> b'din':
pass
@gear
def round_half_up(din, *, nbits=2) -> b'din':
pass
@gear
def round_to_zero(din, *, nbits=2) -> b'din':
pass
@gear
async def round_to_even(din, *, nbits=2) -> b'din':
async with din as d:
return round(float(d) / (2**nbits)) * (2**nbits)
|
mne/tests/test_ola.py
|
rylaw/mne-python
| 1,953 |
49761
|
import numpy as np
from numpy.testing import assert_allclose
import pytest
from mne._ola import _COLA, _Interp2, _Storer
def test_interp_2pt():
"""Test our two-point interpolator."""
n_pts = 200
assert n_pts % 50 == 0
feeds = [ # test a bunch of feeds to make sure they don't break things
[n_pts],
[50] * (n_pts // 50),
[10] * (n_pts // 10),
[5] * (n_pts // 5),
[2] * (n_pts // 2),
[1] * n_pts,
]
# ZOH
values = np.array([10, -10])
expected = np.full(n_pts, 10)
for feed in feeds:
expected[-1] = 10
interp = _Interp2([0, n_pts], values, 'zero')
out = np.concatenate([interp.feed(f)[0] for f in feed])
assert_allclose(out, expected)
interp = _Interp2([0, n_pts - 1], values, 'zero')
expected[-1] = -10
out = np.concatenate([interp.feed(f)[0] for f in feed])
assert_allclose(out, expected)
# linear and inputs of different sizes
values = [np.arange(2)[:, np.newaxis, np.newaxis], np.array([20, 10])]
expected = [
np.linspace(0, 1, n_pts, endpoint=False)[np.newaxis, np.newaxis, :],
np.linspace(20, 10, n_pts, endpoint=False)]
for feed in feeds:
interp = _Interp2([0, n_pts], values, 'linear')
outs = [interp.feed(f) for f in feed]
outs = [np.concatenate([o[0] for o in outs], axis=-1),
np.concatenate([o[1] for o in outs], axis=-1)]
assert_allclose(outs[0], expected[0], atol=1e-7)
assert_allclose(outs[1], expected[1], atol=1e-7)
# cos**2 and more interesting bounds
values = np.array([10, -10])
expected = np.full(n_pts, 10.)
expected[-5:] = -10
cos = np.cos(np.linspace(0, np.pi / 2., n_pts - 9,
endpoint=False))
expected[4:-5] = cos ** 2 * 20 - 10
for feed in feeds:
interp = _Interp2([4, n_pts - 5], values, 'cos2')
out = np.concatenate([interp.feed(f)[0] for f in feed])
assert_allclose(out, expected, atol=1e-7)
out = interp.feed(10)[0]
assert_allclose(out, [values[-1]] * 10, atol=1e-7)
# hann and broadcasting
n_hann = n_pts - 9
expected[4:-5] = np.hanning(2 * n_hann + 1)[n_hann:-1] * 20 - 10
expected = np.array([expected, expected[::-1] * 0.5])
values = np.array([values, values[::-1] * 0.5]).T
for feed in feeds:
interp = _Interp2([4, n_pts - 5], values, 'hann')
out = np.concatenate([interp.feed(f)[0] for f in feed], axis=-1)
assert_allclose(out, expected, atol=1e-7)
# one control point and None support
values = [np.array([10]), None]
for start in [0, 50, 99, 100, 1000]:
interp = _Interp2([start], values, 'zero')
out, none = interp.feed(n_pts)
assert none is None
expected = np.full(n_pts, 10.)
assert_allclose(out, expected)
@pytest.mark.parametrize('ndim', (1, 2, 3))
def test_cola(ndim):
"""Test COLA processing."""
sfreq = 1000.
rng = np.random.RandomState(0)
def processor(x):
return (x / 2.,) # halve the signal
for n_total in (999, 1000, 1001):
signal = rng.randn(n_total)
out = rng.randn(n_total) # shouldn't matter
for _ in range(ndim - 1):
signal = signal[np.newaxis]
out = out[np.newaxis]
for n_samples in (99, 100, 101, 102,
n_total - n_total // 2 + 1, n_total):
for window in ('hann', 'bartlett', 'boxcar', 'triang'):
# A few example COLA possibilities
n_overlaps = ()
if window in ('hann', 'bartlett') or n_samples % 2 == 0:
n_overlaps += ((n_samples + 1) // 2,)
if window == 'boxcar':
n_overlaps += (0,)
for n_overlap in n_overlaps:
# can pass callable or ndarray
for storer in (out, _Storer(out)):
cola = _COLA(processor, storer, n_total, n_samples,
n_overlap, sfreq, window)
n_input = 0
# feed data in an annoying way
while n_input < n_total:
next_len = min(rng.randint(1, 30),
n_total - n_input)
cola.feed(signal[..., n_input:n_input + next_len])
n_input += next_len
assert_allclose(out, signal / 2., atol=1e-7)
|
tests/test_04_dxf_high_level_structs/test_410_table.py
|
Gmadges/ezdxf
| 515 |
49865
|
<gh_stars>100-1000
# Copyright (c) 2011-2021, <NAME>
# License: MIT License
import pytest
import ezdxf
from ezdxf.tools.test import load_entities
from ezdxf.sections.table import Table
from ezdxf.lldxf.tagwriter import TagCollector
@pytest.fixture(scope="module")
def table():
doc = ezdxf.new()
return doc.appids
def test_table_entry_dxf_type(table):
assert table.entry_dxftype == "APPID"
def test_ac1009_load_table():
doc = ezdxf.new("R12")
entities = list(load_entities(AC1009TABLE, "TABLES"))
table = Table(doc, entities[1:-1]) # without SECTION tags and ENDTAB
assert len(table) == 10
def test_load_table_with_invalid_table_entry():
"""This LAYERS table has an invalid APPID table entry, which should be
ignored at the loading stage.
"""
doc = ezdxf.new("R12")
entities = list(load_entities(INVALID_TABLE_ENTRY, "TABLES"))
table = Table(doc, entities[1:-1]) # without SECTION tags and ENDTAB
assert len(table) == 0
def test_ac1009_write(table):
collector = TagCollector(dxfversion="AC1009")
table.export_dxf(collector)
tags = collector.tags
assert tags[0] == (0, "TABLE")
assert tags[1] == (2, "APPID")
# exporting table entries is tested by associated class tests
assert tags[-1] == (0, "ENDTAB")
def test_ac1024_load_table():
doc = ezdxf.new("R2010")
entities = list(load_entities(AC1024TABLE, "TABLES"))
table = Table(doc, entities[1:-1]) # without SECTION tags and ENDTAB
assert 10 == len(table)
def test_ac1024_write(table):
collector = TagCollector(dxfversion="R2004")
table.export_dxf(collector)
tags = collector.tags
assert tags[0] == (0, "TABLE")
assert tags[1] == (2, "APPID")
# exporting table entries is tested by associated class tests
assert tags[-1] == (0, "ENDTAB")
def test_get_table_entry(table):
entry = table.get("ACAD")
assert "ACAD" == entry.dxf.name
def test_entry_names_are_case_insensitive(table):
entry = table.get("acad")
assert "ACAD" == entry.dxf.name
def test_duplicate_entry(table):
new_entry = table.duplicate_entry("ACAD", "ACAD2018")
assert new_entry.dxf.name == "ACAD2018"
entry2 = table.get("ACAD2018")
assert new_entry.dxf.handle == entry2.dxf.handle
new_entry2 = table.duplicate_entry("ACAD2018", "ACAD2019")
new_entry.dxf.flags = 71
new_entry2.dxf.flags = 17
# really different entities
assert new_entry.dxf.flags == 71
assert new_entry2.dxf.flags == 17
def test_create_vport_table():
doc = ezdxf.new()
assert len(doc.viewports) == 1
# standard viewport exists
assert "*Active" in doc.viewports
# create a multi-viewport configuration
# create two entries with same name
vp1 = doc.viewports.new("V1")
vp2 = doc.viewports.new("V1")
assert len(doc.viewports) == 3
# get multi-viewport configuration as list
conf = doc.viewports.get_config("V1")
assert len(conf) == 2
# check handles
vports = [vp1, vp2]
assert conf[0] in vports
assert conf[1] in vports
assert "Test" not in doc.viewports
with pytest.raises(ezdxf.DXFTableEntryError):
_ = doc.viewports.get_config("test")
# delete: ignore not existing configurations
with pytest.raises(ezdxf.DXFTableEntryError):
doc.viewports.delete_config("test")
# delete multi config
doc.viewports.delete_config("V1")
assert len(doc.viewports) == 1
AC1009TABLE = """0
SECTION
2
TABLES
0
TABLE
2
APPID
70
10
0
APPID
2
ACAD
70
0
0
APPID
2
ACADANNOPO
70
0
0
APPID
2
ACADANNOTATIVE
70
0
0
APPID
2
ACAD_DSTYLE_DIMJAG
70
0
0
APPID
2
ACAD_DSTYLE_DIMTALN
70
0
0
APPID
2
ACAD_MLEADERVER
70
0
0
APPID
2
ACAECLAYERSTANDARD
70
0
0
APPID
2
ACAD_EXEMPT_FROM_CAD_STANDARDS
70
0
0
APPID
2
ACAD_DSTYLE_DIMBREAK
70
0
0
APPID
2
ACAD_PSEXT
70
0
0
ENDTAB
0
ENDSEC
"""
AC1024TABLE = """ 0
SECTION
2
TABLES
0
TABLE
2
APPID
5
9
330
0
100
AcDbSymbolTable
70
10
0
APPID
5
12
330
9
100
AcDbSymbolTableRecord
100
AcDbRegAppTableRecord
2
ACAD
70
0
0
APPID
5
DD
330
9
100
AcDbSymbolTableRecord
100
AcDbRegAppTableRecord
2
AcadAnnoPO
70
0
0
APPID
5
DE
330
9
100
AcDbSymbolTableRecord
100
AcDbRegAppTableRecord
2
AcadAnnotative
70
0
0
APPID
5
DF
330
9
100
AcDbSymbolTableRecord
100
AcDbRegAppTableRecord
2
ACAD_DSTYLE_DIMJAG
70
0
0
APPID
5
E0
330
9
100
AcDbSymbolTableRecord
100
AcDbRegAppTableRecord
2
ACAD_DSTYLE_DIMTALN
70
0
0
APPID
5
107
330
9
100
AcDbSymbolTableRecord
100
AcDbRegAppTableRecord
2
ACAD_MLEADERVER
70
0
0
APPID
5
1B5
330
9
100
AcDbSymbolTableRecord
100
AcDbRegAppTableRecord
2
AcAecLayerStandard
70
0
0
APPID
5
1BA
330
9
100
AcDbSymbolTableRecord
100
AcDbRegAppTableRecord
2
ACAD_EXEMPT_FROM_CAD_STANDARDS
70
0
0
APPID
5
237
330
9
100
AcDbSymbolTableRecord
100
AcDbRegAppTableRecord
2
ACAD_DSTYLE_DIMBREAK
70
0
0
APPID
5
28E
330
9
100
AcDbSymbolTableRecord
100
AcDbRegAppTableRecord
2
ACAD_PSEXT
70
0
0
ENDTAB
0
ENDSEC
"""
INVALID_TABLE_ENTRY = """0
SECTION
2
TABLES
0
TABLE
2
LAYERS
70
10
0
APPID
2
ACAD
70
0
0
ENDTAB
0
ENDSEC
"""
|
applications/TrilinosApplication/tests/test_trilinos_matrix.py
|
lkusch/Kratos
| 778 |
49873
|
import KratosMultiphysics.KratosUnittest as KratosUnittest
import KratosMultiphysics
import KratosMultiphysics.TrilinosApplication as KratosTrilinos
class TestTrilinosMatrix(KratosUnittest.TestCase):
def test_resize(self):
comm = KratosTrilinos.CreateEpetraCommunicator(KratosMultiphysics.DataCommunicator.GetDefault())
space = KratosTrilinos.TrilinosSparseSpace()
pb = space.CreateEmptyVectorPointer(comm)
space.ResizeVector(pb,2)
n = space.Size(pb.GetReference())
self.assertEqual(n,2)
if __name__ == '__main__':
KratosUnittest.main()
|
cupy_alias/indexing/__init__.py
|
fixstars/clpy
| 142 |
49890
|
<filename>cupy_alias/indexing/__init__.py<gh_stars>100-1000
from clpy.indexing import * # NOQA
|
src/ostorlab/agent/message/proto/v3/asset/ip/v4/geolocation/geolocation_pb2.py
|
bbhunter/ostorlab
| 113 |
49896
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: v3/asset/ip/v4/geolocation/geolocation.proto
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _reflection
from google.protobuf import symbol_database as _symbol_database
# @@protoc_insertion_point(imports)
_sym_db = _symbol_database.Default()
DESCRIPTOR = _descriptor.FileDescriptor(
name='v3/asset/ip/v4/geolocation/geolocation.proto',
package='v3.asset.ip.v4.geolocation',
syntax='proto2',
serialized_options=None,
serialized_pb=_b('\n,v3/asset/ip/v4/geolocation/geolocation.proto\x12\x1av3.asset.ip.v4.geolocation\"\x94\x02\n\x07Message\x12\x0c\n\x04host\x18\x01 \x02(\t\x12\x0c\n\x04mask\x18\x02 \x01(\t\x12\x12\n\x07version\x18\x03 \x02(\x05:\x01\x34\x12\x11\n\tcontinent\x18\x05 \x01(\t\x12\x16\n\x0e\x63ontinent_code\x18\x06 \x01(\t\x12\x0f\n\x07\x63ountry\x18\x07 \x01(\t\x12\x14\n\x0c\x63ountry_code\x18\x08 \x01(\t\x12\x0e\n\x06region\x18\t \x01(\t\x12\x13\n\x0bregion_name\x18\n \x01(\t\x12\x0c\n\x04\x63ity\x18\x0b \x01(\t\x12\x0b\n\x03zip\x18\x0c \x01(\t\x12\x10\n\x08latitude\x18\r \x01(\x02\x12\x11\n\tlongitude\x18\x0e \x01(\x02\x12\x10\n\x08timezone\x18\x0f \x01(\t\x12\x10\n\x08\x64istrict\x18\x10 \x01(\t')
)
_MESSAGE = _descriptor.Descriptor(
name='Message',
full_name='v3.asset.ip.v4.geolocation.Message',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='host', full_name='v3.asset.ip.v4.geolocation.Message.host', index=0,
number=1, type=9, cpp_type=9, label=2,
has_default_value=False, default_value=_b("").decode('utf-8'),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='mask', full_name='v3.asset.ip.v4.geolocation.Message.mask', index=1,
number=2, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode('utf-8'),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='version', full_name='v3.asset.ip.v4.geolocation.Message.version', index=2,
number=3, type=5, cpp_type=1, label=2,
has_default_value=True, default_value=4,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='continent', full_name='v3.asset.ip.v4.geolocation.Message.continent', index=3,
number=5, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode('utf-8'),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='continent_code', full_name='v3.asset.ip.v4.geolocation.Message.continent_code', index=4,
number=6, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode('utf-8'),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='country', full_name='v3.asset.ip.v4.geolocation.Message.country', index=5,
number=7, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode('utf-8'),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='country_code', full_name='v3.asset.ip.v4.geolocation.Message.country_code', index=6,
number=8, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode('utf-8'),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='region', full_name='v3.asset.ip.v4.geolocation.Message.region', index=7,
number=9, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode('utf-8'),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='region_name', full_name='v3.asset.ip.v4.geolocation.Message.region_name', index=8,
number=10, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode('utf-8'),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='city', full_name='v3.asset.ip.v4.geolocation.Message.city', index=9,
number=11, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode('utf-8'),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='zip', full_name='v3.asset.ip.v4.geolocation.Message.zip', index=10,
number=12, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode('utf-8'),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='latitude', full_name='v3.asset.ip.v4.geolocation.Message.latitude', index=11,
number=13, type=2, cpp_type=6, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='longitude', full_name='v3.asset.ip.v4.geolocation.Message.longitude', index=12,
number=14, type=2, cpp_type=6, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='timezone', full_name='v3.asset.ip.v4.geolocation.Message.timezone', index=13,
number=15, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode('utf-8'),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='district', full_name='v3.asset.ip.v4.geolocation.Message.district', index=14,
number=16, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode('utf-8'),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
],
extensions=[
],
nested_types=[],
enum_types=[
],
serialized_options=None,
is_extendable=False,
syntax='proto2',
extension_ranges=[],
oneofs=[
],
serialized_start=77,
serialized_end=353,
)
DESCRIPTOR.message_types_by_name['Message'] = _MESSAGE
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
Message = _reflection.GeneratedProtocolMessageType('Message', (_message.Message,), dict(
DESCRIPTOR = _MESSAGE,
__module__ = 'v3.asset.ip.v4.geolocation.geolocation_pb2'
# @@protoc_insertion_point(class_scope:v3.asset.ip.v4.geolocation.Message)
))
_sym_db.RegisterMessage(Message)
# @@protoc_insertion_point(module_scope)
|
misc/main.py
|
vishalbelsare/interpolation.py
| 110 |
49925
|
if True:
import numpy as np
d = 3
K = 50
N = 10 ** 6
a = np.zeros(3)
b = np.ones(3)
orders = np.array([K for i in range(d)])
coeffs = np.random.random([k + 2 for k in orders])
points = np.random.random((N, d)) # each line is a vector
points_c = points.T.copy() # each column is a vector
vals = np.zeros(N)
print(points.max().max())
print(points.min().min())
import time
from alternative_implementations import *
from eval_cubic_splines_cython import vec_eval_cubic_spline_3 as rr
vec_eval_cubic_spline_3(a, b, orders, coeffs, points, vals) # warmup
vec_eval_cubic_spline_3_inlined(a, b, orders, coeffs, points, vals) # warmup
vec_eval_cubic_spline_3_inlined_columns(
a, b, orders, coeffs, points_c, vals
) # warmup
vec_eval_cubic_spline_3_kernel(a, b, orders, coeffs, points, vals) # warmup
vec_eval_cubic_spline_3_inlined_lesswork(orders, coeffs, points, vals, Ad, dAd)
# rr(a,b,orders,coeffs,points,vals,Ad,dAd)
rr(a, b, orders, coeffs, points, vals)
t1 = time.time()
vec_eval_cubic_spline_3(a, b, orders, coeffs, points, vals)
t2 = time.time()
vec_eval_cubic_spline_3_inlined(a, b, orders, coeffs, points, vals)
t3 = time.time()
vec_eval_cubic_spline_3_inlined_columns(a, b, orders, coeffs, points_c, vals)
t4 = time.time()
vec_eval_cubic_spline_3_kernel(a, b, orders, coeffs, points, vals)
t5 = time.time()
vec_eval_cubic_spline_3_inlined_lesswork(orders, coeffs, points, vals, Ad, dAd)
t6 = time.time()
# rr(a,b,orders,coeffs,points,vals,Ad,dAd)
rr(a, b, orders, coeffs, points, vals)
t7 = time.time()
print("one function call per point: {}".format(t2 - t1))
print("inlined (points in rows): {}".format(t3 - t2))
print("inlined (points in columns): {}".format(t4 - t3))
print("kernel: {}".format(t5 - t4))
print("less work: {}".format(t6 - t5))
print("cython: {}".format(t7 - t6))
print(vals[:10, 0])
|
authentication/admin.py
|
nicbou/markdown-notes
| 121 |
49931
|
<filename>authentication/admin.py
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
UserAdmin.list_display = ('username', 'email', 'first_name', 'last_name', 'is_active', 'date_joined')
admin.site.unregister(User)
admin.site.register(User, UserAdmin)
|
coilutils/__init__.py
|
rehohoho/coiltraine
| 204 |
49942
|
<reponame>rehohoho/coiltraine<gh_stars>100-1000
from .attribute_dict import AttributeDict
#from .experiment_schedule import mount_experiment_heap, get_free_gpus, pop_half_gpu, pop_one_gpu
|
CalibPPS/ESProducers/python/ctppsRPAlignmentCorrectionsDataESSourceXML_cfi.py
|
ckamtsikis/cmssw
| 852 |
49971
|
import FWCore.ParameterSet.Config as cms
ctppsRPAlignmentCorrectionsDataESSourceXML = cms.ESSource("CTPPSRPAlignmentCorrectionsDataESSourceXML",
verbosity = cms.untracked.uint32(0),
MeasuredFiles = cms.vstring(),
RealFiles = cms.vstring(),
MisalignedFiles = cms.vstring()
)
|
PG/5-TNPG/model.py
|
g6ling/Pytorch-Cartpole
| 116 |
49972
|
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
from config import gamma, lr
def flat_grad(grads):
grad_flatten = []
for grad in grads:
grad_flatten.append(grad.view(-1))
grad_flatten = torch.cat(grad_flatten)
return grad_flatten
def flat_hessian(hessians):
hessians_flatten = []
for hessian in hessians:
hessians_flatten.append(hessian.contiguous().view(-1))
hessians_flatten = torch.cat(hessians_flatten).data
return hessians_flatten
def flat_params(model):
params = []
for param in model.parameters():
params.append(param.data.view(-1))
params_flatten = torch.cat(params)
return params_flatten
def update_model(model, new_params):
index = 0
for params in model.parameters():
params_length = len(params.view(-1))
new_param = new_params[index: index + params_length]
new_param = new_param.view(params.size())
params.data.copy_(new_param)
index += params_length
def kl_divergence(net, old_net, states):
policy = net(states)
old_policy = old_net(states).detach()
kl = old_policy * torch.log(old_policy / policy)
kl = kl.sum(1, keepdim=True)
return kl
def fisher_vector_product(net, states, p, cg_damp=0.1):
kl = kl_divergence(net, net, states)
kl = kl.mean()
kl_grad = torch.autograd.grad(kl, net.parameters(), create_graph=True) # create_graph is True if we need higher order derivative products
kl_grad = flat_grad(kl_grad)
kl_grad_p = (kl_grad * p.detach()).sum()
kl_hessian_p = torch.autograd.grad(kl_grad_p, net.parameters())
kl_hessian_p = flat_hessian(kl_hessian_p)
return kl_hessian_p + cg_damp * p.detach()
def conjugate_gradient(net, states, loss_grad, n_step=10, residual_tol=1e-10):
x = torch.zeros(loss_grad.size())
r = loss_grad.clone()
p = loss_grad.clone()
r_dot_r = torch.dot(r, r)
for i in range(n_step):
A_dot_p = fisher_vector_product(net, states, p)
alpha = r_dot_r / torch.dot(p, A_dot_p)
x += alpha * p
r -= alpha * A_dot_p
new_r_dot_r = torch.dot(r,r)
betta = new_r_dot_r / r_dot_r
p = r + betta * p
r_dot_r = new_r_dot_r
if r_dot_r < residual_tol:
break
return x
class TNPG(nn.Module):
def __init__(self, num_inputs, num_outputs):
super(TNPG, self).__init__()
self.t = 0
self.num_inputs = num_inputs
self.num_outputs = num_outputs
self.fc_1 = nn.Linear(num_inputs, 128)
self.fc_2 = nn.Linear(128, num_outputs)
for m in self.modules():
if isinstance(m, nn.Linear):
nn.init.xavier_uniform(m.weight)
def forward(self, input):
x = torch.tanh(self.fc_1(input))
policy = F.softmax(self.fc_2(x))
return policy
@classmethod
def train_model(cls, net, transitions):
states, actions, rewards, masks = transitions.state, transitions.action, transitions.reward, transitions.mask
states = torch.stack(states)
actions = torch.stack(actions)
rewards = torch.Tensor(rewards)
masks = torch.Tensor(masks)
returns = torch.zeros_like(rewards)
running_return = 0
for t in reversed(range(len(rewards))):
running_return = rewards[t] + gamma * running_return * masks[t]
returns[t] = running_return
policies = net(states)
policies = policies.view(-1, net.num_outputs)
policy_actions = (policies * actions.detach()).sum(dim=1)
loss = (policy_actions * returns).mean()
loss_grad = torch.autograd.grad(loss, net.parameters())
loss_grad = flat_grad(loss_grad)
step_dir = conjugate_gradient(net, states, loss_grad.data)
params = flat_params(net)
new_params = params + lr * step_dir
update_model(net, new_params)
return -loss
def get_action(self, input):
policy = self.forward(input)
policy = policy[0].data.numpy()
action = np.random.choice(self.num_outputs, 1, p=policy)[0]
return action
|
Competitive_Programming/Stepping_stones_3.py
|
varshakancham/Data_Structure_n_Algorithms
| 125 |
49974
|
"""
Vasu is running up a stone staircase with N stones, and can hop(jump) either 1 step, 2 steps or 3 steps at a time.
You have to count, how many possible ways Vasu can run up to the stone stairs.
Input Format:
Input contains integer N that is number of steps
Constraints:
1<= N <=30
Output Format:
Output for each integer N the no of possible ways w.
"""
def hop(N) :
if (N == 1 or N == 0) :
return 1
elif (N == 2) :
return 2
else :
return hop(N - 3) + hop(N - 2) + hop(N - 1)
N = int(input())
print(hop(N))
|
cupy_alias/padding/__init__.py
|
fixstars/clpy
| 142 |
49979
|
<gh_stars>100-1000
from clpy.padding import * # NOQA
|
lightly/active_learning/scorers/__init__.py
|
CodeGuy-007/lightly
| 1,515 |
49990
|
""" Collection of Active Learning Scorers """
# Copyright (c) 2020. Lightly AG and its affiliates.
# All Rights Reserved
from lightly.active_learning.scorers.scorer import Scorer
from lightly.active_learning.scorers.classification import ScorerClassification
from lightly.active_learning.scorers.detection import ScorerObjectDetection
from lightly.active_learning.scorers.semantic_segmentation import ScorerSemanticSegmentation
|
graph_based_slam/launch/graphbasedslam.launch.py
|
edhml/lidarslam_ros2
| 130 |
50004
|
import os
import launch
import launch_ros.actions
from ament_index_python.packages import get_package_share_directory
def generate_launch_description():
graphbasedslam_param_dir = launch.substitutions.LaunchConfiguration(
'graphbasedslam_param_dir',
default=os.path.join(
get_package_share_directory('graph_based_slam'),
'param',
'graphbasedslam.yaml'))
graphbasedslam = launch_ros.actions.Node(
package='graph_based_slam',
executable='graph_based_slam_node',
parameters=[graphbasedslam_param_dir],
output='screen'
)
return launch.LaunchDescription([
launch.actions.DeclareLaunchArgument(
'graphbasedslam_param_dir',
default_value=graphbasedslam_param_dir,
description='Full path to graphbasedslam parameter file to load'),
graphbasedslam,
])
|
tests/nonrealtime/test_nonrealtime_Session_duration.py
|
butayama/supriya
| 191 |
50029
|
import supriya.nonrealtime
def test_01():
session = supriya.nonrealtime.Session()
assert session.offsets == [float("-inf"), 0.0]
assert session.duration == 0.0
def test_02():
session = supriya.nonrealtime.Session()
with session.at(0):
session.add_group()
assert session.offsets == [float("-inf"), 0.0, float("inf")]
assert session.duration == 0.0
def test_03():
session = supriya.nonrealtime.Session()
with session.at(23.5):
session.add_group()
assert session.offsets == [float("-inf"), 0.0, 23.5, float("inf")]
assert session.duration == 23.5
def test_04():
session = supriya.nonrealtime.Session()
with session.at(23.5):
session.add_group(duration=1.0)
assert session.offsets == [float("-inf"), 0.0, 23.5, 24.5]
assert session.duration == 24.5
def test_05():
session = supriya.nonrealtime.Session()
with session.at(0):
session.add_group()
with session.at(23.5):
session.add_group(duration=1.0)
assert session.offsets == [float("-inf"), 0.0, 23.5, 24.5, float("inf")]
assert session.duration == 24.5
def test_06():
session = supriya.nonrealtime.Session(padding=11.0)
assert session.offsets == [float("-inf"), 0.0]
assert session.duration == 0.0
def test_07():
session = supriya.nonrealtime.Session(padding=11.0)
with session.at(0):
session.add_group()
assert session.offsets == [float("-inf"), 0.0, float("inf")]
assert session.duration == 0.0
def test_08():
session = supriya.nonrealtime.Session(padding=11.0)
with session.at(23.5):
session.add_group()
assert session.offsets == [float("-inf"), 0.0, 23.5, float("inf")]
assert session.duration == 34.5
def test_09():
session = supriya.nonrealtime.Session(padding=11.0)
with session.at(23.5):
session.add_group(duration=1.0)
assert session.offsets == [float("-inf"), 0.0, 23.5, 24.5]
assert session.duration == 35.5
def test_10():
session = supriya.nonrealtime.Session(padding=11.0)
with session.at(0):
session.add_group()
with session.at(23.5):
session.add_group(duration=1.0)
assert session.offsets == [float("-inf"), 0.0, 23.5, 24.5, float("inf")]
assert session.duration == 35.5
|
tensorflow_toolkit/action_detection/tools/models/export.py
|
morkovka1337/openvino_training_extensions
| 256 |
50046
|
#!/usr/bin/env python2
#
# Copyright (C) 2019 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions
# and limitations under the License.
from os import makedirs
from os.path import exists, basename, join
from argparse import ArgumentParser
from action_detection.nn.monitors.factory import get_monitor
BASE_FILE_NAME = 'converted_model'
CKPT_FILE_NAME = '{}.ckpt'.format(BASE_FILE_NAME)
PB_FILE_NAME = '{}.pbtxt'.format(BASE_FILE_NAME)
FROZEN_FILE_NAME = 'frozen.pb'
def main():
"""Carry out model preparation for the export.
"""
parser = ArgumentParser()
parser.add_argument('--config', '-c', type=str, required=True, help='Path to config file')
parser.add_argument('--snapshot_path', '-s', type=str, required=True, default='', help='Path to model snapshot')
parser.add_argument('--output_dir', '-o', type=str, required=True, default='', help='Path to output directory')
args = parser.parse_args()
assert exists(args.config)
assert exists(args.snapshot_path + '.index')
if not exists(args.output_dir):
makedirs(args.output_dir)
task_monitor = get_monitor(args.config, snapshot_path=args.snapshot_path)
converted_snapshot_path = join(args.output_dir, CKPT_FILE_NAME)
task_monitor.eliminate_train_ops(converted_snapshot_path)
converted_model_path = '{}-{}'.format(converted_snapshot_path,
int(basename(args.snapshot_path).split('-')[-1]))
task_monitor.save_model_graph(converted_model_path, args.output_dir)
task_monitor.freeze_model_graph(converted_model_path,
join(args.output_dir, PB_FILE_NAME),
join(args.output_dir, FROZEN_FILE_NAME))
if __name__ == '__main__':
main()
|
ambari-common/src/main/python/ambari_commons/buffered_queue.py
|
likenamehaojie/Apache-Ambari-ZH
| 1,664 |
50084
|
<reponame>likenamehaojie/Apache-Ambari-ZH<gh_stars>1000+
"""
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
from collections import deque
from threading import Event
class BufferedQueue(object):
"""
Thread safe buffered queue
"""
def __init__(self):
self.__queue = deque()
self.__data_ready_event = Event()
self.__queue_end = False # sign that buffer is empty
self.__queue_feeder_end = False # EOF sign
def __notify_ready(self):
"""
Notify reader that data is ready to be consumed
"""
self.__queue_end = False
self.__data_ready_event.set()
def notify_end(self):
"""
Notify queue about end of producer stream, allow consumer to read buffer to the end
"""
self.__queue_feeder_end = True
self.__notify_ready()
def put(self, item):
"""
Add object to the buffer
"""
if self.__queue_feeder_end:
raise IndexError("'notify_end' was called, queue is locked for writing")
self.__queue.append(item)
self.__notify_ready()
def get(self, timeout=None):
"""
Read data from buffer at least in `timeout` seconds. If no data ready in `timeout`, would be returned None.
:param timeout: amount of time to wait for data availability
:return: data or None if no data were read in `timeout` or no more data available (buffer is empty)
"""
try:
if not self.__queue_feeder_end:
self.__data_ready_event.wait(timeout)
return self.__queue.popleft()
except IndexError:
if timeout:
return None
self.__queue_end = True
finally:
if self.count == 0:
self.__data_ready_event.clear()
if self.__queue_feeder_end:
self.__queue_end = True
def reset(self):
"""
Clear instance state and data
"""
self.__data_ready_event.clear()
self.__queue.clear()
self.__queue_feeder_end = False
self.__queue_end = False
@property
def empty(self):
if self.__queue_feeder_end and self.count == 0:
return True
return self.__queue_end
@property
def count(self):
return len(self.__queue)
|
html_parsing/https_www_stoloto_ru_4x20_archive__parse_all_loto.py
|
DazEB2/SimplePyScripts
| 117 |
50100
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
__author__ = 'ipetrash'
from urllib.parse import urljoin
import requests
from bs4 import BeautifulSoup
import csv
def get_number(text: str) -> int:
return int(''.join(c for c in text.strip() if c.isdigit()))
first = 1
last = 50
step = 50
result = []
while True:
url = f'https://www.stoloto.ru/4x20/archive?firstDraw={first}&lastDraw={last}&mode=draw'
print(f'first={first}, last={last}: {url}')
rs = requests.get(url)
root = BeautifulSoup(rs.content, 'html.parser')
rows = root.select('.drawings_data .elem > .main')
# Если пустое, значит достигли конца
if not rows:
break
# Чтобы был порядок от меньшего к большему
rows.reverse()
for row in rows:
date_time_str = row.select_one('.draw_date').text.strip()
a = row.select_one('.draw > a')
abs_url = urljoin(url, a['href'])
number = get_number(a.text)
numbers = ' '.join(x.text.strip() for x in row.select('.numbers .numbers_wrapper b'))
prize = get_number(row.select_one('.prize').text)
item = [number, date_time_str, numbers, prize, abs_url]
result.append(item)
print(item)
first += step
last += step
print()
print(len(result), result)
# Наибольшая сумма приза
print(max(result, key=lambda x: x[3]))
# Наименьшая сумма приза
print(min(result, key=lambda x: x[3]))
print()
with open('all_lotto.csv', 'w', encoding='utf-8', newline='') as f:
file = csv.writer(f)
file.writerows(result)
|
examples/garbage.py
|
cyberbeast/pympler
| 862 |
50103
|
<filename>examples/garbage.py
from pympler.garbagegraph import start_debug_garbage
from pympler import web
class Leaf(object):
pass
class Branch(object):
def __init__(self, root):
self.root = root
self.leaf = Leaf()
class Root(object):
def __init__(self, num_branches):
self.branches = [Branch(self) for _ in range(num_branches)]
start_debug_garbage()
tree = Root(2)
del tree
web.start_profiler(debug=True)
|
ner/ner_silver_to_gold.py
|
svlandeg/prodigy-recipes
| 312 |
50117
|
<gh_stars>100-1000
import prodigy
from prodigy.models.ner import EntityRecognizer
from prodigy.components.preprocess import add_tokens
from prodigy.components.db import connect
from prodigy.util import split_string
import spacy
from typing import List, Optional
# Recipe decorator with argument annotations: (description, argument type,
# shortcut, type / converter function called on value before it's passed to
# the function). Descriptions are also shown when typing --help.
@prodigy.recipe(
"ner.silver-to-gold",
silver_dataset=("Dataset with binary annotations", "positional", None, str),
gold_dataset=("Name of dataset to save new annotations", "positional", None, str),
spacy_model=("The base model", "positional", None, str),
label=("One or more comma-separated labels", "option", "l", split_string),
)
def ner_silver_to_gold(
silver_dataset: str,
gold_dataset: str,
spacy_model: str,
label: Optional[List[str]] = None,
):
"""
Take an existing "silver" dataset with binary accept/reject annotations,
merge the annotations to find the best possible analysis given the
constraints defined in the annotations, and manually edit it to create
a perfect and complete "gold" dataset.
"""
# Connect to the database using the settings from prodigy.json, check
# that the silver dataset exists and load it
DB = connect()
if silver_dataset not in DB:
raise ValueError("Can't find dataset '{}'.".format(silver_dataset))
silver_data = DB.get_dataset(silver_dataset)
# Load the spaCy model
nlp = spacy.load(spacy_model)
if label is None:
# Get the labels from the model by looking at the available moves, e.g.
# B-PERSON, I-PERSON, L-PERSON, U-PERSON
ner = nlp.get_pipe("ner")
label = sorted(ner.labels)
# Initialize Prodigy's entity recognizer model, which uses beam search to
# find all possible analyses and outputs (score, example) tuples
model = EntityRecognizer(nlp, label=label)
# Merge all annotations and find the best possible analyses
stream = model.make_best(silver_data)
# Tokenize the incoming examples and add a "tokens" property to each
# example. Also handles pre-defined selected spans. Tokenization allows
# faster highlighting, because the selection can "snap" to token boundaries.
stream = add_tokens(nlp, stream)
return {
"view_id": "ner_manual", # Annotation interface to use
"dataset": gold_dataset, # Name of dataset to save annotations
"stream": stream, # Incoming stream of examples
"config": { # Additional config settings, mostly for app UI
"lang": nlp.lang,
"labels": label, # Selectable label options
},
}
|
tests/test_ping.py
|
naujoh/TorMySQL
| 340 |
50121
|
<reponame>naujoh/TorMySQL<filename>tests/test_ping.py
#!/usr/bin/env python
# encoding: utf-8
import uuid
from tornado.testing import gen_test
from . import BaseTestCase
class TestPing(BaseTestCase):
@gen_test
def test1(self):
with (yield self.pool.Connection()) as connection:
yield connection.ping()
|
effdet/config/train_config.py
|
phager90/efficientdet-pytorch
| 1,386 |
50131
|
from omegaconf import OmegaConf
def default_detection_train_config():
# FIXME currently using args for train config, will revisit, perhaps move to Hydra
h = OmegaConf.create()
# dataset
h.skip_crowd_during_training = True
# augmentation
h.input_rand_hflip = True
h.train_scale_min = 0.1
h.train_scale_max = 2.0
h.autoaugment_policy = None
# optimization
h.momentum = 0.9
h.learning_rate = 0.08
h.lr_warmup_init = 0.008
h.lr_warmup_epoch = 1.0
h.first_lr_drop_epoch = 200.0
h.second_lr_drop_epoch = 250.0
h.clip_gradients_norm = 10.0
h.num_epochs = 300
# regularization l2 loss.
h.weight_decay = 4e-5
h.lr_decay_method = 'cosine'
h.moving_average_decay = 0.9998
h.ckpt_var_scope = None
return h
|
scripts/BuildTimes.py
|
grassofsky/llfio
| 356 |
50153
|
#!/usr/bin/python3
# Calculate boost.afio build times under various configs
# (C) 2015 <NAME>
# Created: 12th March 2015
#[ [`--link-test --fast-build debug`][][[footnote ASIO has a link error without `link=static`]][fails]]
#[ [`--link-test debug`][][][]]
#[ [`--link-test --lto debug`][[]][][]]
#[ [`--link-test pch=off debug`][][][]]
#[[`--link-test --fast-build release`][][[footnote ASIO has a link error without `link=static`]][fails]]
#[ [`--link-test release`][][][]]
#[ [`--link-test --lto release`][][][]]
import os, sys, subprocess, time, shutil, platform
if len(sys.argv)<2:
print("Usage: "+sys.argv[0]+" <toolset>", file=sys.stderr)
sys.exit(1)
if not os.path.exists("b2") and not os.path.exists("b2.exe"):
print("ERROR: Need to run me from boost root directory please", file=sys.stderr)
print(os.getcwd())
shutil.rmtree("bin.v2", True)
onWindows="Windows" in platform.system()
configs=[
["--c++14 --link-test --fast-build debug", None],
["--c++14 --link-test debug", None],
["--c++14 --link-test --lto debug", None],
["--c++14 --link-test pch=off debug", None],
["--c++14 --link-test --fast-build release", None],
["--c++14 --link-test release", None],
["--c++14 --link-test --lto release", None],
["standalone_singleabi", None],
["standalone_multiabi", None]
]
for config in configs:
print("\n\nConfig: "+config[0])
if config[0]=="standalone_singleabi" or config[0]=="standalone_multiabi":
if onWindows:
test_all="test_all.exe"
tocall="alltests_msvc.bat" if "msvc" in sys.argv[1] else "alltests_gcc.bat"
else:
test_all="test_all"
tocall="alltests_gcc.sh"
if config[0]=="standalone_singleabi":
tocall="standalone_"+tocall
else:
tocall="multiabi_"+tocall
basedir=os.getcwd()
env=dict(os.environ)
if not onWindows:
tocall="./"+tocall
env['CXX']=sys.argv[1]
env['CXX']=env['CXX'].replace('gcc', 'g++')
env['CXX']=env['CXX'].replace('clang', 'clang++')
try:
os.chdir("libs/afio")
shutil.rmtree(test_all, True)
if subprocess.call(tocall, env=env, shell=True):
config[1]="FAILED"
continue
shutil.rmtree(test_all, True)
print("\n\nStarting benchmark ...")
begin=time.perf_counter()
subprocess.call(tocall, env=env, shell=True)
end=time.perf_counter()
finally:
os.chdir(basedir)
else:
shutil.rmtree("bin.v2/libs/afio", True)
if subprocess.call([os.path.abspath("b2"), "toolset="+sys.argv[1], "libs/afio/test", "-j", "8"]+config[0].split(" ")):
config[1]="FAILED"
continue
shutil.rmtree("bin.v2/libs/afio", True)
print("\n\nStarting benchmark ...")
begin=time.perf_counter()
subprocess.call([os.path.abspath("b2"), "toolset="+sys.argv[1], "libs/afio/test"]+config[0].split(" "))
end=time.perf_counter()
mins=int((end-begin)/60)
secs=int((end-begin)%60);
config[1]="%dm%ss" % (mins, secs)
print("Config %s took %dm%ss" % (config[0], mins, secs))
print("\n\n")
for config in configs:
print(config)
|
psiPerGene.py
|
CDZBIOSTU/SUPPA
| 176 |
50183
|
<filename>psiPerGene.py
# -*- coding: utf-8 -*-
"""
Created on Fri May 23 10:17:33 2014
@author: <NAME>
@email: <EMAIL>
"""
import sys
import logging
from argparse import ArgumentParser, RawTextHelpFormatter
from lib.tools import *
from lib.gtf_store import *
description = \
"Description:\n\n" + \
"This tool calculates the PSI (Percentatge Splice In) for the different\n" + \
"transcripts of a gene.\n" + \
"It reads a gtf to get transcript-gene relationship and an expression file\n" + \
"of the different transcripts\n"
parser = ArgumentParser(description=description, formatter_class=RawTextHelpFormatter,
add_help=False)
parser.add_argument("-g", "--gtf-file", help="Input gtf file",
required=True)
parser.add_argument("-e", "--expression-file", required=True,
help="Input expression file")
parser.add_argument("-o", "--output-file", required=True,
help="Path and name of the ouput file")
parser.add_argument("-m", "--mode", default="INFO",
help="to choose from DEBUG, INFO, WARNING, ERROR and CRITICAL")
def expression_reader(exp_file):
"""
Reads in expression file and returns dict
of transcript expressions and first line.
"""
if not os.path.isfile(exp_file):
sys.stderr.write("Expression file does not exist. Quiting\n")
exit(1)
expressions = {}
with open(exp_file, 'r') as handle:
first_line = nextel(handle).strip()
for line in handle:
line = line.strip().split('\t')
expressions[line[0]] = [float(xp) for xp in line[1:]]
return expressions, first_line
def expression_writer(genomeinfo, expressions, firstline, output_file):
"""
Function to write perIsoform inclusion
"""
output_file += '_isoform.psi'
entriesnumber = len(expressions[nextel(expressions.__iter__())])
with open(output_file, 'w') as handle:
handle.write(firstline + '\n')
for gene, _, _ in genomeinfo:
expr_sum = [0 for _ in range(entriesnumber)]
# collect expression
for transcript in gene.sortedTranscripts:
if transcript not in expressions:
logger.info(('Expression for transcript "{}" not found. '
'Ignoring it in calculation.').format(transcript))
else:
expr_sum = list(map(lambda exp_pair: exp_pair[0] + exp_pair[1], zip(expr_sum, expressions[transcript])))
# calculate expression
if 0 in expr_sum:
logger.debug('Gene "{}" has at least one replicate with 0 expression.'.format(gene.name))
expr_sum = [y if y else float('NaN') for y in expr_sum]
for transcript in gene.sortedTranscripts:
if transcript not in expressions:
continue
t_exp = map(lambda exp_pair: exp_pair[1] / exp_pair[0], zip(expr_sum, expressions[transcript]))
handle.write('{};{}\t{}\n'.format(gene.name, transcript,
'\t'.join([str(exp_val) for exp_val in t_exp])))
def main():
args = parser.parse_args()
#Parsing arguments
mode = "logging." + args.mode
#Setting logging preferences
logger = logging.getLogger(__name__)
logger.setLevel(eval(mode))
#Setting the level of the loggers in lib
setToolsLoggerLevel(mode)
#PREPAIRING GTF
my_genome = Genome()
logger.info("Reading GTF data.")
fetched_exons = gtf_reader(args.gtf_file, logger)
# Check for empy sequences
if len(fetched_exons) == 0:
logger.info("No exons found. Check format and content of your GTF file.")
exit(1)
for exon_meta in fetched_exons:
my_genome.add_to_genes(exon_meta)
# split non overlapping genes
my_genome.sort_transcripts()
my_genome.split_genes()
logger.info("Reading Expression data.")
trans_expres, sample_names = expression_reader(args.expression_file)
if not trans_expres:
logger.info("No expressions found. Check format and content of your expression file.")
exit(1)
# Calculate and write output
logger.info("Calculating inclusion and generating output.")
expression_writer(my_genome, trans_expres, sample_names, args.output_file)
if __name__ == '__main__':
main()
|
tests/urls.py
|
nkantar/django-distill
| 138 |
50196
|
from django.conf import settings
from django.http import HttpResponse
from django.urls import include, path
from django.contrib.flatpages.views import flatpage as flatpage_view
from django.apps import apps as django_apps
from django_distill import distill_url, distill_path, distill_re_path
def test_no_param_view(request):
return HttpResponse(b'test', content_type='application/octet-stream')
def test_positional_param_view(request, param):
return HttpResponse(b'test' + param.encode(),
content_type='application/octet-stream')
def test_named_param_view(request, param=None):
return HttpResponse(b'test' + param.encode(),
content_type='application/octet-stream')
def test_session_view(request):
request.session['test'] = 'test'
return HttpResponse(b'test', content_type='application/octet-stream')
def test_broken_view(request):
# Trigger a normal Python exception when rendering
a = 1 / 0
def test_http404_view(request):
response = HttpResponse(b'404', content_type='application/octet-stream')
response.status_code = 404
return response
def test_no_param_func():
return None
def test_positional_param_func():
return ('12345',)
def test_named_param_func():
return [{'param': 'test'}]
def test_flatpages_func():
Site = django_apps.get_model('sites.Site')
current_site = Site.objects.get_current()
flatpages = current_site.flatpage_set.filter(registration_required=False)
for flatpage in flatpages:
yield {'url': flatpage.url}
urlpatterns = [
distill_url(r'^url/$',
test_no_param_view,
name='url-no-param',
distill_func=test_no_param_func,
distill_file='test'),
distill_url(r'^url-no-func/$',
test_no_param_view,
name='url-no-param-no-func',
distill_file='test'),
distill_url(r'^url/([\d]+)$',
test_positional_param_view,
name='url-positional-param',
distill_func=test_positional_param_func),
distill_url(r'^url/(?P<param>[\w]+)$',
test_named_param_view,
name='url-named-param',
distill_func=test_named_param_func),
path('path/namespace1/',
include('tests.namespaced_urls', namespace='test_namespace')),
path('path/no-namespace/',
include('tests.no_namespaced_urls')),
]
if settings.HAS_RE_PATH:
urlpatterns += [
distill_re_path(r'^re_path/$',
test_no_param_view,
name='re_path-no-param',
distill_func=test_no_param_func,
distill_file='test'),
distill_re_path(r'^re_path-no-func/$',
test_no_param_view,
name='re_path-no-param-no-func',
distill_file='test'),
distill_re_path(r'^re_path/([\d]+)$',
test_positional_param_view,
name='re_path-positional-param',
distill_func=test_positional_param_func),
distill_re_path(r'^re_path/(?P<param>[\w]+)$',
test_named_param_view,
name='re_path-named-param',
distill_func=test_named_param_func),
distill_re_path(r'^re_path/broken$',
test_broken_view,
name='re_path-broken',
distill_func=test_no_param_func),
distill_re_path(r'^re_path/ignore-sessions$',
test_session_view,
name='re_path-ignore-sessions',
distill_func=test_no_param_func),
distill_re_path(r'^re_path/404$',
test_http404_view,
name='re_path-404',
distill_status_codes=(404,),
distill_func=test_no_param_func),
distill_re_path(r'^re_path/flatpage(?P<url>.+)$',
flatpage_view,
name='re_path-flatpage',
distill_func=test_flatpages_func),
]
if settings.HAS_PATH:
urlpatterns += [
distill_path('path/',
test_no_param_view,
name='path-no-param',
distill_func=test_no_param_func,
distill_file='test'),
distill_path('path-no-func/',
test_no_param_view,
name='path-no-param-no-func',
distill_file='test'),
distill_path('path/<int>',
test_positional_param_view,
name='path-positional-param',
distill_func=test_positional_param_func),
distill_path('path/<str:param>',
test_named_param_view,
name='path-named-param',
distill_func=test_named_param_func),
distill_path('path/broken',
test_broken_view,
name='path-broken',
distill_func=test_no_param_func),
distill_path('path/ignore-sessions',
test_session_view,
name='path-ignore-sessions',
distill_func=test_no_param_func),
distill_path('path/404',
test_http404_view,
name='path-404',
distill_status_codes=(404,),
distill_func=test_no_param_func),
distill_path('path/flatpage<path:url>',
flatpage_view,
name='path-flatpage',
distill_func=test_flatpages_func),
]
|
step32_elastic_file_storage/efs-with-lambda/Python/lambda/msg.py
|
fullstackwebdev/full-stack-serverless-cdk
| 192 |
50231
|
<filename>step32_elastic_file_storage/efs-with-lambda/Python/lambda/msg.py
from __future__ import print_function
import logging
import os
import json
msg_file_path = '/mnt/msg/content'
def handler(event, context):
# request = event['requestContext']
# http = request['http']
method = event['requestContext']['http']['method']
if method == 'GET':
return getMessages()
elif method == 'POST':
message = json.loads(event['body'])
return createMessages(message)
elif method == 'DELETE':
return deleteMessages()
else:
return {'message': 'method not supported'}
def getMessages():
try:
file = open(msg_file_path, 'r')
file_text = file.read()
return {'File_Text': file_text}
except:
logging.error('unable to read')
return {'message': 'unable to load information'}
def deleteMessages():
try:
os.remove(msg_file_path)
return {'message': 'File Deleted'}
except:
logging.error('unable to delete')
return {'message': 'unable to load information'}
def createMessages(message):
try:
file = open(msg_file_path, 'a')
file.write(message)
return {'appended_text': message}
except:
logging.error('unable to write to the file')
return {'message': 'unable to load information'}
|
src/skiptracer/plugins/who_call_id/__init__.py
|
EdwardDantes/skiptracer
| 912 |
50278
|
"""Whocallid.com search module"""
from __future__ import print_function
from __future__ import absolute_import
from ..base import PageGrabber
from ...colors.default_colors import DefaultBodyColors as bc
import re
import logging
try:
import __builtin__ as bi
except BaseException:
import builtins as bi
class WhoCallIdGrabber(PageGrabber):
"""
WhoCallID sales scraper for reverse telephone lookups
"""
def get_name(self):
"""
Grab the users name
"""
name = "Unknown"
try:
name = self.soup.find('h2', attrs={'class': 'name'})
if name:
name = name.text.strip()
print(" [" + bc.CGRN + "+" + bc.CEND + "] " +
bc.CRED + "Name: " + bc.CEND + str(name))
except BaseException:
pass
finally:
return name
def get_location(self):
"""
Get the location
"""
location = "Unknown"
try:
location = self.soup.find('h3', attrs={'class': 'location'})
if location:
location = location.text.strip()
print(" [" + bc.CGRN + "+" + bc.CEND + "] " +
bc.CRED + "Location: " + bc.CEND + str(location))
except BaseException:
pass
finally:
return location
def get_phone_type(self):
"""
Get the phone type
"""
phone_type = "Unknown"
try:
phone_type = self.soup.find("img").attrs['alt']
if phone_type:
phone_type = phone_type.strip()
print(" [" + bc.CGRN + "+" + bc.CEND + "] " +
bc.CRED + "Phone Type: " + bc.CEND + str(phone_type))
except BaseException:
pass
finally:
return phone_type
def get_carrier(self, phone_number):
"""
Get the phone carrier info
"""
carrier = ""
try:
self.url = "https://whocalld.com/+1{}?carrier".format(phone_number)
self.source = self.get_source(self.url)
self.soup = self.get_dom(self.source)
carrier = soup.find('span', attrs={'class': 'carrier'})
except BaseException:
pass
finally:
return carrier
def process_carrier(self, carrier):
"""
Take the carrier info and process it
"""
try:
if carrier:
carrier = carrier.text
print(" [" + bc.CGRN + "+" + bc.CEND + "] " +
bc.CRED + "Carrier: " + bc.CEND + str(carrier))
else:
carrier = ""
except BaseException:
carrier = ""
finally:
return carrier
def get_city(self):
"""
Grab the city info
"""
city = ""
try:
city = self.soup.find('span', attrs={'class': 'city'})
if city:
city = city.text
print(" [" + bc.CGRN + "+" + bc.CEND + "] " +
bc.CRED + "City: " + bc.CEND + str(city))
except BaseException:
pass
finally:
return city
def get_state(self):
"""
Grab the state info
"""
state = ""
try:
state = self.soup.find('span', attrs={'class': 'state'})
if state:
state = state.text
print(" [" + bc.CGRN + "+" + bc.CEND + "] " +
bc.CRED + "State: " + bc.CEND + str(state))
except BaseException:
pass
finally:
return state
def get_time(self):
"""
Grab time info
"""
time = ""
try:
time = self.soup.find('span', attrs={'class': 'time'})
if time:
time = time.text
print(" [" + bc.CGRN + "+" + bc.CEND + "] " +
bc.CRED + "Time: " + bc.CEND + str(time))
except BaseException:
pass
finally:
return time
def get_info(self, phone_number, lookup):
"""
Request, scrape and return values found
"""
print("[" + bc.CPRP + "?" + bc.CEND + "] " +
bc.CCYN + "WhoCalld" + bc.CEND)
# Get phone info
self.url = 'https://whocalld.com/+1{}'.format(phone_number)
self.source = self.get_source(self.url)
self.soup = self.get_dom(self.source)
try:
if self.soup.body.find_all(string=re.compile(
'.*{0}.*'.format('country')), recursive=True):
print(" [" + bc.CRED + "X" + bc.CEND + "] " +
bc.CYLW + "No WhoCallID data returned\n" + bc.CEND)
return
except:
print(" [" + bc.CRED + "X" + bc.CEND + "] " +
bc.CYLW + "Unable to extract data. Is the site online?\n" + bc.CEND)
name = self.get_name()
location = self.get_location()
phone_type = self.get_phone_type()
carrier = self.get_carrier(phone_number)
carrier = self.process_carrier(carrier)
city = self.get_city()
state = self.get_state()
time = self.get_time()
self.info_dict.update({
"carrier": carrier,
"city": city,
"location": location,
"name": name,
"phone_type": phone_type,
"state": state,
"time": time
})
print()
return self.info_dict
|
superset/migrations/versions/bb38f40aa3ff_add_force_screenshot_to_alerts_reports.py
|
m-ajay/superset
| 18,621 |
50286
|
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
"""Add force_screenshot to alerts/reports
Revision ID: bb38f40aa3ff
Revises: <PASSWORD>
Create Date: 2021-12-10 19:25:29.802949
"""
# revision identifiers, used by Alembic.
revision = "bb38f40aa3ff"
down_revision = "3<PASSWORD>"
import sqlalchemy as sa
from alembic import op
from sqlalchemy.ext.declarative import declarative_base
from superset import db
Base = declarative_base()
class ReportSchedule(Base):
__tablename__ = "report_schedule"
id = sa.Column(sa.Integer, primary_key=True)
type = sa.Column(sa.String(50), nullable=False)
force_screenshot = sa.Column(sa.Boolean, default=False)
def upgrade():
with op.batch_alter_table("report_schedule") as batch_op:
batch_op.add_column(sa.Column("force_screenshot", sa.Boolean(), default=False))
bind = op.get_bind()
session = db.Session(bind=bind)
for report in session.query(ReportSchedule).all():
# Update existing alerts that send chart screenshots so that the cache is
# bypassed. We don't turn this one for dashboards because (1) it's currently
# not supported but also because (2) it can be very expensive.
report.force_screenshot = report.type == "Alert" and report.chart_id is not None
session.commit()
def downgrade():
with op.batch_alter_table("report_schedule") as batch_op:
batch_op.drop_column("force_screenshot")
|
core/ocr/spaceocr.py
|
huihui7987/MillionHeroAssistant
| 672 |
50292
|
<filename>core/ocr/spaceocr.py<gh_stars>100-1000
# -*- coding: utf-8 -*-
import json
import requests
"""
ocr.space
"""
def get_text_from_image(image_data, api_key='<KEY>', overlay=False, language='chs'):
"""
CR.space API request with local file.
:param image_data: image's base64 encoding.
:param overlay: Is OCR.space overlay required in your response.
Defaults to False.
:param api_key: OCR.space API key.
Defaults to 'helloworld'.
:param language: Language code to be used in OCR.
List of available language codes can be found on https://ocr.space/OCRAPI
Defaults to 'en'.
:return: Result in JSON format.
"""
payload = {
'isOverlayRequired': overlay,
'apikey': api_key,
'language': language,
}
r = requests.post('https://api.ocr.space/parse/image',
files={'image.png': image_data},
data=payload,
)
result = json.loads(r.content)
if (result['OCRExitCode'] == 1):
return result['ParsedResults'][0]['ParsedText']
print(result['ErrorMessage'])
return ""
|
testdata/stamp_info.bzl
|
mgred/rules_docker
| 912 |
50294
|
<gh_stars>100-1000
# Copyright 2017 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Provides the stamp info file containing the Bazel non-volatile keys
"""
def _impl(ctx):
output = ctx.outputs.out
ctx.actions.run_shell(
outputs = [output],
inputs = [ctx.info_file],
command = "cp {src} {dst}".format(
src = ctx.info_file.path,
dst = output.path,
),
)
stamp_info = rule(
implementation = _impl,
outputs = {
# The stamp file.
"out": "%{name}.txt",
},
)
|
genalog/text/lcs.py
|
jingjie181/genalog
| 185 |
50300
|
<filename>genalog/text/lcs.py
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# ---------------------------------------------------------
class LCS:
""" Compute the Longest Common Subsequence (LCS) of two given string."""
def __init__(self, str_m, str_n):
self.str_m_len = len(str_m)
self.str_n_len = len(str_n)
dp_table = self._construct_dp_table(str_m, str_n)
self._lcs_len = dp_table[self.str_m_len][self.str_n_len]
self._lcs = self._find_lcs_str(str_m, str_n, dp_table)
def _construct_dp_table(self, str_m, str_n):
m = self.str_m_len
n = self.str_n_len
# Initialize DP table
dp = [[0 for j in range(n + 1)] for i in range(m + 1)]
for i in range(1, m + 1):
for j in range(1, n + 1):
# Case 1: if char1 == char2
if str_m[i - 1] == str_n[j - 1]:
dp[i][j] = 1 + dp[i - 1][j - 1]
# Case 2: take the max of the values in the top and left cell
else:
dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])
return dp
def _find_lcs_str(self, str_m, str_n, dp_table):
m = self.str_m_len
n = self.str_n_len
lcs = ""
while m > 0 and n > 0:
# same char
if str_m[m - 1] == str_n[n - 1]:
# prepend the character
lcs = str_m[m - 1] + lcs
m -= 1
n -= 1
# top cell > left cell
elif dp_table[m - 1][n] > dp_table[m][n - 1]:
m -= 1
else:
n -= 1
return lcs
def get_len(self):
return self._lcs_len
def get_str(self):
return self._lcs
|
release/scripts/presets/camera/Samsung_Galaxy_S4.py
|
rbabari/blender
| 365 |
50315
|
<reponame>rbabari/blender
import bpy
bpy.context.camera.sensor_width = 4.8
bpy.context.camera.sensor_height = 3.6
bpy.context.camera.lens = 4.20
bpy.context.camera.sensor_fit = 'HORIZONTAL'
|
examples/datacenters.py
|
doziya/hpeOneView
| 107 |
50337
|
# -*- coding: utf-8 -*-
###
# (C) Copyright (2012-2017) Hewlett Packard Enterprise Development LP
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
###
from pprint import pprint
from config_loader import try_load_from_file
from hpOneView.oneview_client import OneViewClient
config = {
"ip": "<oneview_ip>",
"credentials": {
"userName": "<username>",
"password": "<password>"
}
}
# Try load config from a file (if there is a config file)
config = try_load_from_file(config)
oneview_client = OneViewClient(config)
datacenter_information = {
"name": "MyDatacenter",
"width": 5000, "depth": 5000
}
# Add a Datacenter
datacenter_added = oneview_client.datacenters.add(datacenter_information)
print("\nAdded Datacenter '{name}' successfully\n".format(**datacenter_added))
# Retrieve Datacenter by URI
datacenter = oneview_client.datacenters.get(datacenter_added['uri'])
print("\nGet Datacenter by URI: retrieved '{name}' successfully\n".format(**datacenter))
# Update the Datacenter
datacenter['name'] = "New Datacenter Name"
datacenter = oneview_client.datacenters.update(datacenter)
print("\nDatacenter '{name}' updated successfully\n".format(**datacenter))
# Get the Datacenter by name
datacenter_list = oneview_client.datacenters.get_by('name', "New Datacenter Name")
print("\nGet Datacenter device by name: '{name}'\n".format(**datacenter))
# Get the Datacenter visual content
print("Getting the Datacenter visual content...")
datacenter_visual_content = oneview_client.datacenters.get_visual_content(datacenter['uri'])
pprint(datacenter_visual_content)
# Remove added Datacenter
oneview_client.datacenters.remove(datacenter)
print("\nSuccessfully removed the datacenter")
# Add a datacenter again and call Remove All
datacenter_added = oneview_client.datacenters.add(datacenter_information)
oneview_client.datacenters.remove_all(filter="name matches '%'")
print("\nSuccessfully removed all datacenters")
|
medium/images/data_for_fitting.py
|
yull1860outlook/Data-Analysis
| 4,358 |
50362
|
<reponame>yull1860outlook/Data-Analysis
def data_for_fitting(*, building_id, date):
"""
Retrieves data for fitting from the previous business day
taking into account holidays
"""
lease_start = None
while lease_start is None:
# Previous business day according to Pandas (might be a holiday)
previous_bday = pd.to_datetime(date) - BDay(1)
# If a holiday, this will return None
lease_start = (
db()
.execute(
building_daily_stats.select()
.where(building_daily_stats.c.building_id == building_id)
.where(building_daily_stats.c.date == previous_bday)
)
.fetchone()
.lease_obligations_start_at
)
date = previous_bday
# Retrieve 8 hours of data from the lease start
return load_sensor_values(
building_id=building_id,
start_time=lease_start,
end_time=lease_start + timedelta(hours=8),
)
|
python/ql/test/query-tests/Security/CWE-079/jinja2_escaping.py
|
vadi2/codeql
| 4,036 |
50412
|
Environment(loader=templateLoader, autoescape=fake_func())
from flask import Flask, request, make_response, escape
from jinja2 import Environment, select_autoescape, FileSystemLoader, Template
app = Flask(__name__)
loader = FileSystemLoader( searchpath="templates/" )
unsafe_env = Environment(loader=loader)
safe1_env = Environment(loader=loader, autoescape=True)
safe2_env = Environment(loader=loader, autoescape=select_autoescape())
def render_response_from_env(env):
name = request.args.get('name', '')
template = env.get_template('template.html')
return make_response(template.render(name=name))
@app.route('/unsafe')
def unsafe():
return render_response_from_env(unsafe_env)
@app.route('/safe1')
def safe1():
return render_response_from_env(safe1_env)
@app.route('/safe2')
def safe2():
return render_response_from_env(safe2_env)
# Explicit autoescape
e = Environment(
loader=loader,
autoescape=select_autoescape(['html', 'htm', 'xml'])
) # GOOD
# Additional checks with flow.
auto = select_autoescape
e = Environment(autoescape=auto) # GOOD
z = 0
e = Environment(autoescape=z) # BAD
E = Environment
E() # BAD
E(autoescape=z) # BAD
E(autoescape=auto) # GOOD
E(autoescape=0+1) # GOOD
def checked(cond=False):
if cond:
e = Environment(autoescape=cond) # GOOD
unsafe_tmpl = Template('Hello {{ name }}!')
safe1_tmpl = Template('Hello {{ name }}!', autoescape=True)
safe2_tmpl = Template('Hello {{ name }}!', autoescape=select_autoescape())
|
moe/tests/bandit/__init__.py
|
dstoeckel/MOE
| 966 |
50446
|
# -*- coding: utf-8 -*-
r"""Testing code for the (Python) bandit library.
Testing is done via the Testify package:
https://github.com/Yelp/Testify
This package includes:
* Test cases/test setup files
* Tests for bandit/epsilon: :mod:`moe.tests.bandit.epsilon`
* Tests for bandit/ucb: :mod:`moe.tests.bandit.ucb`
* Tests for bandit/bla: :mod:`moe.tests.bandit.bla`
This package includes:
* Test cases/test setup files
* Tests for classes and utils in :mod:`moe.bandit`
**Files in this package**
* :mod:`moe.tests.bandit.bandit_interface_test`: tests for :mod:`moe.bandit.interfaces.bandit_interface.BanditInterface`
* :mod:`moe.tests.bandit.bandit_test_case`: base test case for bandit tests with a simple integration test case
* :mod:`moe.tests.bandit.linkers_test`: tests for :mod:`moe.bandit.linkers`
* :mod:`moe.tests.bandit.utils_test`: tests for :mod:`moe.bandit.utils`
"""
|
terrascript/resource/drarko/mssql.py
|
mjuenema/python-terrascript
| 507 |
50502
|
# terrascript/resource/drarko/mssql.py
# Automatically generated by tools/makecode.py (24-Sep-2021 15:21:59 UTC)
import terrascript
class mssql_login(terrascript.Resource):
pass
__all__ = [
"mssql_login",
]
|
ouroboros/cmath.py
|
mewbak/ouroboros
| 205 |
50515
|
<reponame>mewbak/ouroboros<filename>ouroboros/cmath.py
"""
A pure python implementation of the standard module library cmath.
"""
import math
" These are constants from float.h"
_FLT_RADIX = 2
_DBL_MIN = 2.2250738585072014e-308
_DBL_MAX = 1.7976931348623157e+308
_DBL_EPSILON = 2.2204460492503131e-16
_DBL_MANT_DIG = 53
_CM_SCALE_UP = 2*int(_DBL_MANT_DIG/2) + 1
_CM_SCALE_DOWN = int(-(_CM_SCALE_UP+1)/2)
_LOG_2 = 0.6931471805599453094
_LOG_10 = 2.302585092994045684
_LARGE_INT = 2305843009213693951
_LOG_LARGE_INT = 18.3628297355029
_LARGE_DOUBLE = 4.49423283715579e+307
_LOG_LARGE_DOUBLE = 307.652655568589
_SQRT_LARGE_DOUBLE = 6.70390396497130e+153
_SQRT_DBL_MIN = 1.49166814624004e-154
e = 2.7182818284590452354
pi = 3.14159265358979323846
tau = 2*pi
inf = float("inf")
infj = complex(0, inf)
nan = float("nan")
nanj = complex(0, nan)
def _make_complex(x):
if isinstance(x, complex):
return x
try:
z = x.__complex__()
except AttributeError:
try:
z = complex(x.__float__())
except AttributeError:
raise TypeError
if isinstance(z, complex):
return z
raise TypeError
def _special_type(x):
ST_NINF, ST_NEG, ST_NZERO, ST_PZERO, ST_POS, ST_PINF, ST_NAN = range(7)
if math.isnan(x):
return ST_NAN
if math.isfinite(x):
if x != 0:
if math.copysign(1, x) == 1:
return ST_POS
return ST_NEG
if math.copysign(1, x) == 1:
return ST_PZERO
return ST_NZERO
if math.copysign(1, x) == 1:
return ST_PINF
return ST_NINF
def rect(r, phi):
_rect_special = [
[inf+nanj, None, -inf, complex(-float("inf"), -0.0), None, inf+nanj, inf+nanj],
[nan+nanj, None, None, None, None, nan+nanj, nan+nanj],
[0, None, complex(-0.0, 0.0), complex(-0.0, -0.0), None, 0, 0],
[0, None, complex(0.0, -0.0), 0, None, 0, 0],
[nan+nanj, None, None, None, None, nan+nanj, nan+nanj],
[inf+nanj, None, complex(float("inf"), -0.0), inf, None, inf+nanj, inf+nanj],
[nan+nanj, nan+nanj, nan, nan, nan+nanj, nan+nanj, nan+nanj]
]
if not math.isfinite(r) or not math.isfinite(phi):
if math.isinf(phi) and not math.isnan(r) and r != 0:
raise ValueError
if math.isinf(r) and math.isfinite(phi) and phi != 0:
if r > 0:
return complex(math.copysign(inf, math.cos(phi)),
math.copysign(inf, math.sin(phi)))
return complex(-math.copysign(inf, math.cos(phi)),
-math.copysign(inf, math.sin(phi)))
return _rect_special[_special_type(r)][_special_type(phi)]
return complex(r*math.cos(phi), r*math.sin(phi))
def phase(x):
z = complex(x)
return math.atan2(z.imag, z.real)
def polar(x):
return abs(x), phase(x)
def exp(x):
z = _make_complex(x)
exp_special = [
[0+0j, None, complex(0, -0.0), 0+0j, None, 0+0j, 0+0j],
[nan+nanj, None, None, None, None, nan+nanj, nan+nanj],
[nan+nanj, None, 1-0j, 1+0j, None, nan+nanj, nan+nanj],
[nan+nanj, None, 1-0j, 1+0j, None, nan+nanj, nan+nanj],
[nan+nanj, None, None, None, None, nan+nanj, nan+nanj],
[inf+nanj, None, complex(float("inf"), -0.0), inf, None, inf+nanj, inf+nanj],
[nan+nanj, nan+nanj, complex(float("nan"), -0.0), nan, nan+nanj, nan+nanj, nan+nanj]
]
if not isfinite(z):
if math.isinf(z.real) and math.isfinite(z.imag) and z.imag != 0:
if z.real > 0:
ret = complex(math.copysign(inf, math.cos(z.imag)),
math.copysign(inf, math.sin(z.imag)))
else:
ret = complex(math.copysign(0, math.cos(z.imag)),
math.copysign(0, math.sin(z.imag)))
else:
ret = exp_special[_special_type(z.real)][_special_type(z.imag)]
if math.isinf(z.imag) and (math.isfinite(z.real) or
(math.isinf(z.real) and z.real > 0)):
raise ValueError
return ret
if z.real > _LOG_LARGE_DOUBLE:
ret = e * rect(math.exp(z.real - 1), z.imag)
else:
ret = rect(math.exp(z.real), z.imag)
if math.isinf(ret.real) or math.isinf(ret.imag):
raise OverflowError
return ret
def _log(z):
abs_x = abs(z.real)
abs_y = abs(z.imag)
if abs_x > _LARGE_INT or abs_y > _LARGE_INT:
return complex(math.log(math.hypot(abs_x/2, abs_y/2)) + _LOG_2,
math.atan2(z.imag, z.real))
if abs_x < _DBL_MIN and abs_y < _DBL_MIN:
if abs_x > 0 or abs_y > 0:
return complex(math.log(math.hypot(math.ldexp(abs_x, _DBL_MANT_DIG),
math.ldexp(abs_y, _DBL_MANT_DIG)))
- _DBL_MANT_DIG * _LOG_2,
math.atan2(z.imag, z.real))
raise ValueError
rad, phi = polar(z)
return complex(math.log(rad), phi)
def log(x, base=e):
if base != e:
return _log(_make_complex(x))/_log(_make_complex(base))
return _log(_make_complex(x))
def log10(x):
z = _log(_make_complex(x))
return complex(z.real/_LOG_10, z.imag/_LOG_10)
def sqrt(x):
sqrt_special = [
[inf-infj, 0-infj, 0-infj, infj, infj, inf+infj, nan+infj],
[inf-infj, None, None, None, None, inf+infj, nan+nanj],
[inf-infj, None, 0-0j, 0+0j, None, inf+infj, nan+nanj],
[inf-infj, None, 0-0j, 0+0j, None, inf+infj, nan+nanj],
[inf-infj, None, None, None, None, inf+infj, nan+nanj],
[inf-infj, complex(float("inf"), -0.0), complex(float("inf"), -0.0), inf, inf, inf+infj, inf+nanj],
[inf-infj, nan+nanj, nan+nanj, nan+nanj, nan+nanj, inf+infj, nan+nanj]
]
z = _make_complex(x)
if math.isinf(z.real) or math.isinf(z.imag):
return sqrt_special[_special_type(z.real)][_special_type(z.imag)]
abs_x, abs_y = abs(z.real), abs(z.imag)
if abs_x < _DBL_MIN and abs_y < _DBL_MIN:
if abs_x > 0 or abs_y > 0:
abs_x = math.ldexp(abs_x, _CM_SCALE_UP)
s = math.ldexp(math.sqrt(abs_x +
math.hypot(abs_x,
math.ldexp(abs_y,
_CM_SCALE_UP))),
_CM_SCALE_DOWN)
else:
return complex(0, z.imag)
else:
abs_x /= 8
s = 2 * math.sqrt(abs_x + math.hypot(abs_x, abs_y/8))
if z.real >= 0:
return complex(s, math.copysign(abs_y/(2*s), z.imag))
return complex(abs_y/(2*s), math.copysign(s, z.imag))
def acos(x):
_acos_special = [
[3*pi/4+infj, pi+infj, pi+infj, pi-infj, pi-infj, 3*pi/4-infj, nan+infj],
[pi/2+infj, None, None, None, None, pi/2-infj, nan+nanj],
[pi/2+infj, None, None, None, None, pi/2-infj, pi/2+nanj],
[pi/2+infj, None, None, None, None, pi/2-infj, pi/2+nanj],
[pi/2+infj, None, None, None, None, pi/2-infj, nan+nanj],
[pi/4+infj, infj, infj, 0.0-infj, 0.0-infj, pi/4-infj, nan+infj],
[nan+infj, nan+nanj, nan+nanj, nan+nanj, nan+nanj, nan-infj, nan+nanj]
]
z = _make_complex(x)
if not isfinite(z):
return _acos_special[_special_type(z.real)][_special_type(z.imag)]
if abs(z.real) > _LARGE_DOUBLE or abs(z.imag) > _LARGE_DOUBLE:
if z.real < 0:
imag = -math.copysign(math.log(math.hypot(z.real/2, z.imag/2)) +
2 * _LOG_2, z.imag)
else:
imag = math.copysign(math.log(math.hypot(z.real/2, z.imag/2)) +
2 * _LOG_2, -z.imag)
return complex(math.atan2(abs(z.imag), z.real), imag)
s1 = sqrt(complex(1.0 - z.real, -z.imag))
s2 = sqrt(complex(1.0 + z.real, z.imag))
return complex(2 * math.atan2(s1.real, s2.real),
math.asinh(s2.real*s1.imag - s2.imag*s1.real))
def asin(x):
z = _make_complex(x)
z = asinh(complex(-z.imag, z.real))
return complex(z.imag, -z.real)
def atan(x):
z = _make_complex(x)
z = atanh(complex(-z.imag, z.real))
return complex(z.imag, -z.real)
def cos(x):
z = _make_complex(x)
return cosh(complex(-z.imag, z.real))
def sin(x):
z = _make_complex(x)
z = sinh(complex(-z.imag, z.real))
return complex(z.imag, -z.real)
def tan(x):
z = _make_complex(x)
z = tanh(complex(-z.imag, z.real))
return complex(z.imag, -z.real)
def acosh(x):
z = _make_complex(x)
if abs(z.real) > _LARGE_DOUBLE or abs(z.imag) > _LARGE_DOUBLE:
return complex(math.log(math.hypot(z.real/2, z.imag/2)) + 2*_LOG_2,
math.atan2(z.imag, z.real))
s1 = sqrt(complex(z.real-1, z.imag))
s2 = sqrt(complex(z.real+1, z.imag))
return complex(math.asinh(s1.real*s2.real + s1.imag*s2.imag),
2*math.atan2(s1.imag, s2.real))
def asinh(x):
_asinh_special = [
[-inf-1j*pi/4, complex(-float("inf"), -0.0), complex(-float("inf"), -0.0),
complex(-float("inf"), 0.0), complex(-float("inf"), 0.0), -inf+1j*pi/4, -inf+nanj],
[-inf-1j*pi/2, None, None, None, None, -inf+1j*pi/2, nan+nanj],
[-inf-1j*pi/2, None, None, None, None, -inf+1j*pi/2, nan+nanj],
[inf-1j*pi/2, None, None, None, None, inf+1j*pi/2, nan+nanj],
[inf-1j*pi/2, None, None, None, None, inf+1j*pi/2, nan+nanj],
[inf-1j*pi/4, complex(float("inf"), -0.0), complex(float("inf"), -0.0),
inf, inf, inf+1j*pi/4, inf+nanj],
[inf+nanj, nan+nanj, complex(float("nan"), -0.0), nan, nan+nanj, inf+nanj, nan+nanj]
]
z = _make_complex(x)
if not isfinite(z):
return _asinh_special[_special_type(z.real)][_special_type(z.imag)]
if abs(z.real) > _LARGE_DOUBLE or abs(z.imag) > _LARGE_DOUBLE:
if z.imag >= 0:
real = math.copysign(math.log(math.hypot(z.imag/2, z.real/2)) +
2 * _LOG_2, z.real)
else:
real = -math.copysign(math.log(math.hypot(z.imag/2, z.real/2)) +
2 * _LOG_2, -z.real)
return complex(real, math.atan2(z.imag, abs(z.real)))
s1 = sqrt(complex(1+z.imag, -z.real))
s2 = sqrt(complex(1-z.imag, z.real))
return complex(math.asinh(s1.real*s2.imag-s2.real*s1.imag),
math.atan2(z.imag, s1.real*s2.real - s1.imag*s2.imag))
def atanh(x):
_atanh_special = [
[complex(-0.0, -pi/2), complex(-0.0, -pi/2), complex(-0.0, -pi/2),
complex(-0.0, pi/2), complex(-0.0, pi/2), complex(-0.0, pi/2),
complex(-0.0, float("nan"))],
[complex(-0.0, -pi/2), None, None, None, None, complex(-0.0, pi/2),
nan+nanj],
[complex(-0.0, -pi/2), None, None, None, None, complex(-0.0, pi/2),
complex(-0.0, float("nan"))],
[-1j*pi/2, None, None, None, None, 1j*pi/2, nanj],
[-1j*pi/2, None, None, None, None, 1j*pi/2, nan+nanj],
[-1j*pi/2, -1j*pi/2, -1j*pi/2, 1j*pi/2, 1j*pi/2, 1j*pi/2, nanj],
[-1j*pi/2, nan+nanj, nan+nanj, nan+nanj, nan+nanj, 1j*pi/2, nan+nanj]
]
z = _make_complex(x)
if not isfinite(z):
return _atanh_special[_special_type(z.real)][_special_type(z.imag)]
if z.real < 0:
return -atanh(-z)
ay = abs(z.imag)
if z.real > _SQRT_LARGE_DOUBLE or ay > _SQRT_LARGE_DOUBLE:
hypot = math.hypot(z.real/2, z.imag/2)
return complex(z.real/4/hypot/hypot, -math.copysign(pi/2, -z.imag))
if z.real == 1 and ay < _SQRT_DBL_MIN:
if ay == 0:
raise ValueError
return complex(-math.log(math.sqrt(ay)/math.sqrt(math.hypot(ay, 2))),
math.copysign(math.atan2(2, -ay)/2, z.imag))
return complex(math.log1p(4*z.real/((1-z.real)*(1-z.real) + ay*ay))/4,
-math.atan2(-2*z.imag, (1-z.real)*(1+z.real) - ay*ay)/2)
def cosh(x):
_cosh_special = [
[inf+nanj, None, inf, complex(float("inf"), -0.0), None, inf+nanj, inf+nanj],
[nan+nanj, None, None, None, None, nan+nanj, nan+nanj],
[nan, None, 1, complex(1, -0.0), None, nan, nan],
[nan, None, complex(1, -0.0), 1, None, nan, nan],
[nan+nanj, None, None, None, None, nan+nanj, nan+nanj],
[inf+nanj, None, complex(float("inf"), -0.0), inf, None, inf+nanj, inf+nanj],
[nan+nanj, nan+nanj, nan, nan, nan+nanj, nan+nanj, nan+nanj]
]
z = _make_complex(x)
if not isfinite(z):
if math.isinf(z.imag) and not math.isnan(z.real):
raise ValueError
if math.isinf(z.real) and math.isfinite(z.imag) and z.imag != 0:
if z.real > 0:
return complex(math.copysign(inf, math.cos(z.imag)),
math.copysign(inf, math.sin(z.imag)))
return complex(math.copysign(inf, math.cos(z.imag)),
-math.copysign(inf, math.sin(z.imag)))
return _cosh_special[_special_type(z.real)][_special_type(z.imag)]
if abs(z.real) > _LOG_LARGE_DOUBLE:
x_minus_one = z.real - math.copysign(1, z.real)
ret = complex(e * math.cos(z.imag) * math.cosh(x_minus_one),
e * math.sin(z.imag) * math.sinh(x_minus_one))
else:
ret = complex(math.cos(z.imag) * math.cosh(z.real),
math.sin(z.imag) * math.sinh(z.real))
if math.isinf(ret.real) or math.isinf(ret.imag):
raise OverflowError
return ret
def sinh(x):
_sinh_special = [
[inf+nanj, None, complex(-float("inf"), -0.0), -inf, None, inf+nanj, inf+nanj],
[nan+nanj, None, None, None, None, nan+nanj, nan+nanj],
[nanj, None, complex(-0.0, -0.0), complex(-0.0, 0.0), None, nanj, nanj],
[nanj, None, complex(0.0, -0.0), complex(0.0, 0.0), None, nanj, nanj],
[nan+nanj, None, None, None, None, nan+nanj, nan+nanj],
[inf+nanj, None, complex(float("inf"), -0.0), inf, None, inf+nanj, inf+nanj],
[nan+nanj, nan+nanj, complex(float("nan"), -0.0), nan, nan+nanj, nan+nanj, nan+nanj]
]
z = _make_complex(x)
if not isfinite(z):
if math.isinf(z.imag) and not math.isnan(z.real):
raise ValueError
if math.isinf(z.real) and math.isfinite(z.imag) and z.imag != 0:
if z.real > 0:
return complex(math.copysign(inf, math.cos(z.imag)),
math.copysign(inf, math.sin(z.imag)))
return complex(-math.copysign(inf, math.cos(z.imag)),
math.copysign(inf, math.sin(z.imag)))
return _sinh_special[_special_type(z.real)][_special_type(z.imag)]
if abs(z.real) > _LOG_LARGE_DOUBLE:
x_minus_one = z.real - math.copysign(1, z.real)
return complex(math.cos(z.imag) * math.sinh(x_minus_one) * e,
math.sin(z.imag) * math.cosh(x_minus_one) * e)
return complex(math.cos(z.imag) * math.sinh(z.real),
math.sin(z.imag) * math.cosh(z.real))
def tanh(x):
_tanh_special = [
[-1, None, complex(-1, -0.0), -1, None, -1, -1],
[nan+nanj, None, None, None, None, nan+nanj, nan+nanj],
[nan+nanj, None, complex(-0.0, -0.0), complex(-0.0, 0.0), None, nan+nanj, nan+nanj],
[nan+nanj, None, complex(0.0, -0.0), 0.0, None, nan+nanj, nan+nanj],
[nan+nanj, None, None, None, None, nan+nanj, nan+nanj],
[1, None, complex(1, -0.0), 1, None, 1, 1],
[nan+nanj, nan+nanj, complex(float("nan"), -0.0), nan, nan+nanj, nan+nanj, nan+nanj]
]
z = _make_complex(x)
if not isfinite(z):
if math.isinf(z.imag) and math.isfinite(z.real):
raise ValueError
if math.isinf(z.real) and math.isfinite(z.imag) and z.imag != 0:
if z.real > 0:
return complex(1, math.copysign(0.0, math.sin(z.imag)
* math.cos(z.imag)))
return complex(-1, math.copysign(0.0, math.sin(z.imag)
* math.cos(z.imag)))
return _tanh_special[_special_type(z.real)][_special_type(z.imag)]
if abs(z.real) > _LOG_LARGE_DOUBLE:
return complex(
math.copysign(1, z.real),
4*math.sin(z.imag)*math.cos(z.imag)*math.exp(-2*abs(z.real))
)
tanh_x = math.tanh(z.real)
tan_y = math.tan(z.imag)
cx = 1/math.cosh(z.real)
denom = 1 + tanh_x * tanh_x * tan_y * tan_y
return complex(tanh_x * (1 + tan_y*tan_y)/denom,
((tan_y / denom) * cx) * cx)
def isfinite(x):
return math.isfinite(x.real) and math.isfinite(x.imag)
def isinf(x):
return math.isinf(x.real) or math.isinf(x.imag)
def isnan(x):
return math.isnan(x.real) or math.isnan(x.imag)
def isclose(a, b, *, rel_tol=1e-09, abs_tol=0.0):
a = _make_complex(a)
b = _make_complex(b)
rel_tol = float(rel_tol)
abs_tol = float(abs_tol)
if rel_tol < 0 or abs_tol < 0:
raise ValueError("tolerances must be non-negative")
if a.real == b.real and a.imag == b.imag:
return True
if math.isinf(a.real) or math.isinf(a.imag) or math.isinf(b.real) \
or math.isinf(b.imag):
return False
# if isnan(a) or isnan(b):
# return False
diff = abs(a-b)
return diff <= rel_tol * abs(a) or diff <= rel_tol * abs(b) or diff <= abs_tol
|
anchore/cli/common.py
|
berez23/anchore
| 401 |
50541
|
<reponame>berez23/anchore<gh_stars>100-1000
import os
import click
import json
import yaml
import logging
import sys
from anchore import anchore_utils
from anchore.cli import logs
from anchore.util import contexts
plain_output = False
def extended_help_option(extended_help=None, *param_decls, **attrs):
"""
Based on the click.help_option code.
Adds a ``--extended-help`` option which immediately ends the program
printing out the extended extended-help page. Defaults to using the
callback's doc string, but can be given an explicit value as well.
This is intended for use as a decorator on a command to provide a 3rd level
of help verbosity suitable for use as a manpage (though not formatted as such explicitly).
Like :func:`version_option`, this is implemented as eager option that
prints in the callback and exits.
All arguments are forwarded to :func:`option`.
"""
def decorator(f):
def callback(ctx, param, value):
if value and not ctx.resilient_parsing:
if not extended_help:
ctx.command.help = ctx.command.callback.__doc__
click.echo(ctx.get_help(), color=ctx.color)
else:
ctx.command.help = extended_help
click.echo(ctx.get_help(), color=ctx.color)
ctx.exit()
attrs.setdefault('is_flag', True)
attrs.setdefault('expose_value', False)
attrs.setdefault('help', 'Show extended help content, similar to manpage, and exit.')
attrs.setdefault('is_eager', True)
attrs['callback'] = callback
return click.option(*(param_decls or ('--extended-help',)), **attrs)(f)
return decorator
def std_formatter(msg):
"""
Default simple string format. Dumps block-style indented yaml for dicts if found. Otherwise no formatting
:param msg:
:return:
"""
if isinstance(msg, dict):
return yaml.safe_dump(msg, indent=True, default_flow_style=False)
return str(msg)
def json_formatter(obj):
"""
Format the output in JSON
:param obj:
:return:
"""
if isinstance(obj, str):
# Make a list of size 1
return json.dumps([obj], indent=True)
else:
return json.dumps(obj, indent=True, sort_keys=True)
# Which formatting function to use
formatter = std_formatter
def init_output_format(use_json=False, use_plain=False, use_debug=False, use_verbose=False, use_quiet=False, log_filepath=None, debug_log_filepath = None):
global formatter
if use_json:
formatter = json_formatter
if use_debug:
level = 'debug'
elif use_verbose:
level = 'verbose'
elif use_quiet:
level = 'quiet'
else:
level = 'normal'
logs.init_output_formatters(output_verbosity=level, logfile=log_filepath, debug_logfile=debug_log_filepath)
def anchore_print_err(msg):
exc = sys.exc_info()
if exc is not None and exc != (None, None, None):
logging.getLogger(__name__).exception(msg)
else:
logging.getLogger(__name__).error(msg)
def anchore_print(msg, do_formatting=False):
"""
Print to stdout using the proper formatting for the command.
:param msg: output to be printed, either an object or a string. Objects will be serialized according to config
:return:
"""
if do_formatting:
click.echo(formatter(msg))
else:
click.echo(msg)
def build_image_list(config, image, imagefile, all_local, include_allanchore, dockerfile=None, exclude_file=None):
"""Given option inputs from the cli, construct a list of image ids. Includes all found with no exclusion logic"""
if not image and not (imagefile or all_local):
raise click.BadOptionUsage('No input found for image source. One of <image>, <imagefile>, or <all> must be specified')
if image and imagefile:
raise click.BadOptionUsage('Only one of <image> and <imagefile> can be specified')
filter_images = []
if exclude_file:
with open(exclude_file) as f:
for line in f.readlines():
filter_images.append(line.strip())
imagelist = {}
if image:
imagelist[image] = {'dockerfile':dockerfile}
if imagefile:
filelist = anchore_utils.read_kvfile_tolist(imagefile)
for i in range(len(filelist)):
l = filelist[i]
imageId = l[0]
try:
dfile = l[1]
except:
dfile = None
imagelist[imageId] = {'dockerfile':dfile}
if all_local:
docker_cli = contexts['docker_cli']
if docker_cli:
for f in docker_cli.images(all=True, quiet=True, filters={'dangling': False}):
if f not in imagelist and f not in filter_images:
imagelist[f] = {'dockerfile':None}
else:
raise Exception("Could not load any images from local docker host - is docker running?")
if include_allanchore:
ret = contexts['anchore_db'].load_all_images().keys()
if ret and len(ret) > 0:
for l in list(set(imagelist.keys()) | set(ret)):
imagelist[l] = {'dockerfile':None}
# Remove excluded items
for excluded in filter_images:
docker_cli = contexts['docker_cli']
if not docker_cli:
raise Exception("Could not query docker - is docker running?")
for img in docker_cli.images(name=excluded, quiet=True):
imagelist.pop(img, None)
return imagelist
|
recipes/Python/577826_Yet_Another_Ordered_Dictionary/recipe-577826.py
|
tdiprima/code
| 2,023 |
50551
|
# ordereddict.py
# A dictionary that remembers insertion order
# Tested under Python 2.7 and 2.6.6 only
#
# Copyright (C) 2011 by <NAME> <lukius at gmail dot com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
from _abcoll import *
try:
from thread import get_ident as _get_ident
except ImportError:
from dummy_thread import get_ident as _get_ident
from operator import eq as _eq
from itertools import imap as _imap
__author__ = '<NAME> <lukius at gmail dot com>'
__version__ = '1.1'
__all__ = ['OrderedDict']
########################### Constants ###########################
FORWARD = 0
BACKWARDS = 1
KEY = 0
VALUE = 1
NEXT = 3
PREVIOUS = 2
#################################################################
class OrderedDict(dict, MutableMapping):
'A dictionary that remembers insertion order.'
# This implementation uses a doubly-linked list of nodes, each
# node being a 4-tuple <key, value, previous node, next node>.
# Despite this, the interesting thing about it is that the list
# is actually embedded in the dictionary. As a consequence,
# there is little space penalty, and also every operation
# exhibits an efficient implementation (i.e., no need to perform
# lookups or deletions multiple times, as it happens with other
# versions of this data structure.).
#
# It is worth noticing that passing an OrderedDict as an argument
# to the dict constructor won't behave as expected. This is due
# to the fact that the internal dictionary keeps additional information
# apart from a key's value. If needed, the instance method dict()
# provides a dict copy of an OrderedDict.
update = MutableMapping.update
setdefault = MutableMapping.setdefault
__ne__ = MutableMapping.__ne__
######################## Class methods #########################
@classmethod
def fromkeys(cls, iterable, value = None):
'''od.fromkeys(S[, v]) -> New ordered dictionary with keys from S
and values equal to v (which defaults to None).
'''
d = cls()
for key in iterable:
d[key] = value
return d
################################################################
######################## Initialization ########################
def __init__(self, *args, **kwds):
"""Initialize an ordered dictionary. Signature is the same as for
regular dictionaries, but keyword arguments are not recommended
because their insertion order is arbitrary.
"""
if len(args) > 1:
raise TypeError('expected at most 1 arguments, got %d' % len(args))
try:
self.first_node
except AttributeError:
self.first_node = None
self.last_node = None
self.update(*args, **kwds)
################################################################
################## Data access & manipulation ##################
__marker = object()
def __getitem__(self, key):
'od.__getitem__(y) <==> od[y]'
node = dict.__getitem__(self, key)
return node[VALUE]
def get(self, key, default = None):
'od.get(k[,d]) -> od[k] if k in od, else d. d defaults to None.'
try:
value = self.__getitem__(key)
except KeyError:
value = default
return value
def __setitem__(self, key, value):
'od.__setitem__(i, y) <==> od[i]=y'
try:
node = dict.__getitem__(self, key)
node[VALUE] = value
except KeyError:
new_node = [key, value, self.last_node, None]
if( self.first_node is None ):
self.first_node = new_node
if( self.last_node is not None ):
self.last_node[NEXT] = new_node
self.last_node = new_node
dict.__setitem__(self, key, new_node)
def __delitem__(self, key):
'od.__delitem__(y) <==> del od[y]'
removed_node = dict.pop(self,key)
self.__adjust_after_removing(removed_node)
def pop(self, key, default = __marker):
'''od.pop(k[,d]) -> v, remove specified key and return the corresponding
value. If key is not found, d is returned if given, otherwise KeyError
is raised.'''
removed_node = dict.pop(self, key, default)
if( removed_node is self.__marker ):
raise KeyError, key
if( removed_node is default ):
return default
self.__adjust_after_removing(removed_node)
return removed_node[VALUE]
def popitem(self, last = True):
'''od.popitem() -> (k, v), remove and return some (key, value) pair as a
2-tuple; but raise KeyError if od is empty.'''
if not self:
raise KeyError('dictionary is empty')
key = next(reversed(self) if last else iter(self))
value = self.pop(key)
return key, value
def clear(self):
'od.clear() -> None. Remove all items from od.'
dict.clear(self)
self.first_node = None
self.last_node = None
def __adjust_after_removing(self, a_node):
'Adjust a_node previous and next pointers after its removal.'
previous = a_node[PREVIOUS]
next = a_node[NEXT]
if( next ):
next[PREVIOUS] = previous
else:
self.last_node = previous
if( previous ):
previous[NEXT] = next
else:
self.first_node = next
################################################################
#################### Iteration & keys/values ###################
def __walk(self, direction = FORWARD, action = lambda x: x, *arguments):
'Iterate over action applied to each node, in the appropriate order.'
if( direction == FORWARD ):
next = NEXT
first = self.first_node
elif( direction == BACKWARDS ):
next = PREVIOUS
first = self.last_node
current_node = first
while( current_node ):
yield action(current_node, *arguments)
current_node = current_node[next]
def __walk_to_list(self, direction = FORWARD, action = lambda x: x, *arguments):
'''Obtain a list of objects resulting from applying action to
each node, in the appropriate order.'''
return_list = list()
item_generator = self.__walk(direction = direction, action = action, *arguments)
for item in item_generator: return_list.append(item)
return return_list
def __iter__(self):
'od.__iter__() <==> iter(od)'
return self.__walk( action = lambda node: node[KEY] )
def __reversed__(self):
'od.__reversed__() <==> reversed(od)'
return self.__walk( direction = BACKWARDS, action = lambda node: node[KEY] )
def keys(self):
"od.keys() -> list of od's keys"
return self.__walk_to_list( action = lambda node: node[KEY] )
def values(self):
"od.values() -> list of od's values"
return self.__walk_to_list( action = lambda node: node[VALUE] )
def items(self):
"od.items() -> list of od's (key, value) pairs, as 2-tuples"
return self.__walk_to_list( action = lambda node: (node[KEY], node[VALUE]) )
def iterkeys(self):
'od.iterkeys() -> an iterator over the keys of od'
return iter(self)
def itervalues(self):
'od.itervalues() -> an iterator over the values of od'
return self.__walk( action = lambda node: node[VALUE] )
def iteritems(self):
'od.iteritems() -> an iterator over the (key, value) items of od'
return self.__walk( action = lambda node: (node[KEY], node[VALUE]) )
################################################################
############################# Copies ###########################
def copy(self):
'od.copy() -> a shallow copy of od'
return self.__class__(self)
def dict(self):
'od.dict() -> a dict copy of od'
d = {}
for item in self.iteritems(): d[item[KEY]] = item[VALUE]
return d
################################################################
########################## Miscellaneous #######################
def __repr__(self, _repr_running = {}):
'od.__repr__() <==> repr(od)'
call_key = id(self), _get_ident()
if call_key in _repr_running:
return '...'
_repr_running[call_key] = 1
try:
if not self:
return '%s()' % (self.__class__.__name__,)
return '%s(%r)' % (self.__class__.__name__, self.items())
finally:
del _repr_running[call_key]
def __reduce__(self):
'Return state information for pickling'
items = self.items()
tmp = self.first_node, self.last_node
del self.first_node, self.last_node
inst_dict = vars(self).copy()
self.first_node, self.last_node = tmp
if inst_dict:
return (self.__class__, (items,), inst_dict)
return self.__class__, (items,)
def __eq__(self, other):
'''od.__eq__(y) <==> od==y. Comparison to another OD is order-sensitive
while comparison to a regular mapping is order-insensitive.
'''
if isinstance(other, OrderedDict):
return len(self) == len(other) and \
all(_imap(_eq, self.iteritems(), other.iteritems()))
return dict.__eq__(self.dict(), other)
def viewkeys(self):
"od.viewkeys() -> a set-like object providing a view on od's keys"
return KeysView(self)
def viewvalues(self):
"od.viewvalues() -> an object providing a view on od's values"
return ValuesView(self)
def viewitems(self):
"od.viewitems() -> a set-like object providing a view on od's items"
return ItemsView(self)
################################################################
|
web/sales_app/apps/home/models.py
|
iabok/sales-tracker
| 163 |
50562
|
"""Base models"""
|
metrics/webnlg_challenge_2017/evaluator.py
|
HKUNLP/UnifiedSKG
| 191 |
50593
|
<gh_stars>100-1000
# encoding=utf8
import os
from third_party.dart import extract_score_webnlg
def evaluate_webnlg_challenge_2017(references_s, preds):
"""
The evaluation of the webnlg_challenge_2017,
we use the evaluate shell that DART dataset provided.
:param references_s: ACTUALLY, references in webnlg are of no use.
:param preds:
:return:
"""
tmp_file_name = 'webnlg_challenge_2017_tmp4eval.txt'
with open(tmp_file_name, 'w') as tmp_file:
for pred in preds:
print(pred, file=tmp_file)
os.system("bash utils/process/general/dart_lib/run_eval_on_webnlg.sh "
"{}".format(tmp_file_name))
summary = extract_score_webnlg()
return summary
class EvaluateTool(object):
def __init__(self, args):
self.args = args
def evaluate(self, preds, golds, section):
references_s = [item["references"] for item in golds]
assert len(preds) == len(references_s)
summary = evaluate_webnlg_challenge_2017(references_s, preds)
return summary
|
indra/sources/isi/__init__.py
|
zebulon2/indra
| 136 |
50608
|
<reponame>zebulon2/indra<filename>indra/sources/isi/__init__.py
"""
This module provides an input interface and processor to the ISI reading
system.
The reader is set up to run within a Docker container.
For the ISI reader to run, set the Docker memory and swap space to the maximum.
"""
from .api import process_text, process_nxml, process_preprocessed, \
process_output_folder, process_json_file
|
openbook_auth/apps.py
|
TamaraAbells/okuna-api
| 164 |
50626
|
from django.apps import AppConfig
class OpenbookAuthConfig(AppConfig):
name = 'openbook_auth'
|
lightbus/api.py
|
gcollard/lightbus
| 178 |
50627
|
from typing import Dict
from lightbus.exceptions import (
UnknownApi,
InvalidApiRegistryEntry,
EventNotFound,
MisconfiguredApiOptions,
InvalidApiEventConfiguration,
)
__all__ = ["Api", "Event"]
class ApiRegistry:
def __init__(self):
self._apis: Dict[str, Api] = dict()
def add(self, api: "Api"):
if isinstance(api, type):
raise InvalidApiRegistryEntry(
"An attempt was made to add a type to the API registry. This "
"is probably because you are trying to add the API class, rather "
"than an instance of the API class.\n"
"\n"
"Use bus.client.register_api(MyApi()), rather than bus.client.register_api(MyApi)"
)
self._apis[api.meta.name] = api
def get(self, name) -> "Api":
try:
return self._apis[name]
except KeyError:
raise UnknownApi(
"An API named '{}' was requested from the registry but the "
"registry does not recognise it. Maybe the incorrect API name "
"was specified, or maybe the API has not been registered.".format(name)
)
def remove(self, name) -> None:
try:
del self._apis[name]
except KeyError:
raise UnknownApi(
"An attempt was made to remove an API named '{}' from the registry, but the API "
"could not be found. Maybe the incorrect API name "
"was specified, or maybe the API has not been registered.".format(name)
)
def public(self):
return [api for api in self._apis.values() if not api.meta.internal]
def internal(self):
return [api for api in self._apis.values() if api.meta.internal]
def all(self):
return list(self._apis.values())
def names(self):
return list(self._apis.keys())
class ApiOptions:
name: str
internal: bool = False
version: int = 1
def __init__(self, options):
for k, v in options.items():
if not k.startswith("_"):
setattr(self, k, v)
class ApiMetaclass(type):
""" API Metaclass
Validates options in the API's Meta class and populates the
API class' `meta` attribute.
"""
def __init__(cls, name, bases=None, dict_=None):
is_api_base_class = name == "Api" and not bases
if is_api_base_class:
super(ApiMetaclass, cls).__init__(name, bases, dict_)
else:
options = dict_.get("Meta", None)
if options is None:
raise MisconfiguredApiOptions(
f"API class {name} does not contain a class named 'Meta'. Each API definition "
f"must contain a child class named 'Meta' which can contain configurations options. "
f"For example, the 'name' option is required and specifies "
f"the name used to access the API on the bus."
)
cls.sanity_check_options(name, options)
cls.meta = ApiOptions(cls.Meta.__dict__.copy())
super(ApiMetaclass, cls).__init__(name, bases, dict_)
if cls.meta.name == "default" or cls.meta.name.startswith("default."):
raise MisconfiguredApiOptions(
f"API class {name} is named 'default', or starts with 'default.'. "
f"This is a reserved name and is not allowed, please change it to something else."
)
def sanity_check_options(cls, name, options):
if not getattr(options, "name", None):
raise MisconfiguredApiOptions(
"API class {} does not specify a name option with its "
"'Meta' options."
"".format(name)
)
class Api(metaclass=ApiMetaclass):
class Meta:
name = None
def get_event(self, name) -> "Event":
event = getattr(self, name, None)
if isinstance(event, Event):
return event
else:
raise EventNotFound("Event named {}.{} could not be found".format(self, name))
def __str__(self):
return self.meta.name
class Event:
def __init__(self, parameters=tuple()):
# Ensure you update the __copy__() method if adding other instance variables below
if isinstance(parameters, str):
raise InvalidApiEventConfiguration(
f"You appear to have passed a string value of {repr(parameters)} "
f"for your API's event's parameters. This should be a list or a tuple, "
f"not a string. You probably missed a comma when defining your "
f"tuple of parameter names."
)
self.parameters = parameters
|
cryptol-remote-api/python/tests/cryptol/test_basics.py
|
GaloisInc/cryptol
| 773 |
50657
|
import unittest
from argo_client.interaction import ArgoException
from pathlib import Path
import unittest
import io
import os
import time
import cryptol
import cryptol.cryptoltypes
from cryptol.single_connection import *
from cryptol.bitvector import BV
from BitVector import * #type: ignore
# Tests of the core server functionality and less
# focused on intricate Cryptol specifics per se.
class BasicServerTests(unittest.TestCase):
@classmethod
def setUpClass(self):
self.c = cryptol.connect(verify=False)
def test_extend_search_path(self):
# Test that extending the search path acts as expected w.r.t. loads
c = self.c
c.extend_search_path(str(Path('tests','cryptol','test-files', 'test-subdir')))
c.load_module('Bar').result()
ans1 = c.eval("theAnswer").result()
ans2 = c.eval("id theAnswer").result()
self.assertEqual(ans1, ans2)
def test_logging(self):
c = self.c
c.extend_search_path(str(Path('tests','cryptol','test-files', 'test-subdir')))
c.load_module('Bar').result()
log_buffer = io.StringIO()
c.logging(on=True, dest=log_buffer)
_ = c.eval("theAnswer").result()
contents = log_buffer.getvalue()
self.assertEqual(len(contents.strip().splitlines()), 2,
msg=f'log contents: {str(contents.strip().splitlines())}')
_ = c.eval("theAnswer").result()
def test_check_timeout(self):
c = self.c
c.load_file(str(Path('tests','cryptol','test-files', 'examples','AES.cry'))).result()
t1 = time.time()
with self.assertRaises(ArgoException):
c.check("\\(bv : [256]) -> ~ (~ (~ (~bv))) == bv", num_tests="all", timeout=1.0).result()
t2 = time.time()
self.assertLess(t2 - t1, 2.0)
t1 = time.time()
with self.assertRaises(ArgoException):
c.check("\\(bv : [256]) -> ~ (~ (~ (~bv))) == bv", num_tests="all", timeout=5.0).result()
t2 = time.time()
self.assertLess(t2 - t1, 7)
t1 = time.time()
c.check("\\(bv : [256]) -> ~ (~ (~ (~bv))) == bv", num_tests=10, timeout=5.0).result()
t2 = time.time()
self.assertLess(t2 - t1, 5)
def test_interrupt(self):
# Check if this test is using a local server, if not we assume it's a remote HTTP server
if os.getenv('CRYPTOL_SERVER') is not None:
c = self.c
c.load_file(str(Path('tests','cryptol','test-files', 'examples','AES.cry')))
t1 = time.time()
c.check("\\(bv : [256]) -> ~ (~ (~ (~bv))) == bv", num_tests="all", timeout=30.0)
# ^ .result() intentionally omitted so we don't wait on it's result and we can interrupt
# it on the next line. We add a timeout just in case to the test fails
time.sleep(.5)
c.interrupt()
self.assertTrue(c.safe("aesEncrypt").result())
t2 = time.time()
self.assertLess(t2 - t1, 15.0) # ensure th interrupt ended things and not the timeout
elif os.getenv('CRYPTOL_SERVER_URL') is not None:
c = self.c
other_c = cryptol.connect(verify=False)
# Since this is the HTTP server, due to client implementation details
# the requests don't return until they get a response, so we fork
# to interrupt the server
newpid = os.fork()
if newpid == 0:
time.sleep(5)
other_c.interrupt()
os._exit(0)
c.load_file(str(Path('tests','cryptol','test-files', 'examples','AES.cry')))
t1 = time.time()
c.check("\\(bv : [256]) -> ~ (~ (~ (~bv))) == bv", num_tests="all", timeout=60.0)
self.assertTrue(c.safe("aesEncrypt").result())
t2 = time.time()
self.assertLess(t2 - t1, 20.0) # ensure th interrupt ended things and not the timeout
else:
# Otherwise fail... since this shouldn't be possible
self.assertFalse("Impossible")
def test_prove_timeout(self):
c = self.c
c.load_file(str(Path('tests','cryptol','test-files', 'examples','AES.cry')))
pt = BV(size=128, value=0x3243f6a8885a308d313198a2e0370734)
key = BV(size=128, value=<KEY>)
ct = c.call("aesEncrypt", (pt, key)).result()
expected_ct = BV(size=128, value=0x3925841d02dc09fbdc118597196a0b32)
self.assertEqual(ct, expected_ct)
decrypted_ct = c.call("aesDecrypt", (ct, key)).result()
self.assertEqual(pt, decrypted_ct)
pt = BV(size=128, value=0x00112233445566778899aabbccddeeff)
key = BV(size=128, value=0x000102030405060708090a0b0c0d0e0f)
ct = c.call("aesEncrypt", (pt, key)).result()
expected_ct = BV(size=128, value=0x69c4e0d86a7b0430d8cdb78070b4c55a)
self.assertEqual(ct, expected_ct)
decrypted_ct = c.call("aesDecrypt", (ct, key)).result()
self.assertEqual(pt, decrypted_ct)
self.assertTrue(c.safe("aesEncrypt").result())
self.assertTrue(c.safe("aesDecrypt").result())
self.assertTrue(c.check("AESCorrect").result().success)
t1 = time.time()
with self.assertRaises(ArgoException):
c.prove("AESCorrect", timeout=1.0).result()
t2 = time.time()
# check the timeout worked
self.assertGreaterEqual(t2 - t1, 1.0)
self.assertLess(t2 - t1, 5.0)
# make sure things are still working
self.assertTrue(c.safe("aesEncrypt").result())
# set the timeout at the connection level
c.timeout = 1.0
t1 = time.time()
with self.assertRaises(ArgoException):
c.prove("AESCorrect").result()
t2 = time.time()
# check the timeout worked
self.assertGreaterEqual(t2 - t1, 1.0)
self.assertLess(t2 - t1, 5.0)
# make sure things are still working
c.timeout = None
self.assertTrue(c.safe("aesEncrypt").result())
c.timeout = 1.0
t1 = time.time()
with self.assertRaises(ArgoException):
# override timeout with longer time
c.prove("AESCorrect", timeout=5.0).result()
t2 = time.time()
self.assertGreaterEqual(t2 - t1, 5.0)
self.assertLess(t2 - t1, 10.0)
# make sure things are still working
c.timeout = None
self.assertTrue(c.safe("aesEncrypt").result())
class BasicLoggingServerTests(unittest.TestCase):
# Connection to cryptol
log_buffer = None
@classmethod
def setUpClass(self):
self.log_buffer = io.StringIO()
connect(verify=False, log_dest = self.log_buffer)
def test_logging(self):
extend_search_path(str(Path('tests','cryptol','test-files', 'test-subdir')))
load_module('Bar')
_ = cry_eval("theAnswer")
content_lines = self.log_buffer.getvalue().strip().splitlines()
self.assertEqual(len(content_lines), 6,
msg=f'log contents: {str(content_lines)}')
if __name__ == "__main__":
unittest.main()
|
opps/articles/search_indexes.py
|
jeanmask/opps
| 159 |
50661
|
# -*- coding: utf-8 -*-
from datetime import datetime
from django.conf import settings
from haystack.indexes import Indexable
from opps.containers.search_indexes import ContainerIndex
from .models import Post, Album, Link
migration_date = getattr(settings, 'MIGRATION_DATE', None)
if migration_date:
m_date = datetime.strptime(migration_date, "%Y-%m-%d").date()
Post.is_legacy = lambda self: m_date >= self.date_insert.date()
else:
Post.is_legacy = lambda self: False
class PostIndex(ContainerIndex, Indexable):
def get_model(self):
return Post
class AlbumIndex(ContainerIndex, Indexable):
def get_model(self):
return Album
class LinkIndex(ContainerIndex, Indexable):
def get_model(self):
return Link
|
tests/test_cases/test_array_simple/test_array_simple.py
|
lavanyajagan/cocotb
| 350 |
50675
|
<filename>tests/test_cases/test_array_simple/test_array_simple.py
# Copyright cocotb contributors
# Licensed under the Revised BSD License, see LICENSE for details.
# SPDX-License-Identifier: BSD-3-Clause
"""Test getting and setting values of arrays"""
import contextlib
import logging
import cocotb
from cocotb.clock import Clock
from cocotb.triggers import Timer
tlog = logging.getLogger("cocotb.test")
def _check_value(tlog, hdl, expected):
assert hdl.value == expected
tlog.info(f" Found {hdl!r} ({hdl._type}) with value={hdl.value}")
# GHDL unable to put values on nested array types (gh-2588)
@cocotb.test(
expect_error=Exception if cocotb.SIM_NAME.lower().startswith("ghdl") else ()
)
async def test_1dim_array_handles(dut):
"""Test getting and setting array values using the handle of the full array."""
cocotb.start_soon(Clock(dut.clk, 1000, "ns").start())
dut.array_7_downto_4.value = [0xF0, 0xE0, 0xD0, 0xC0]
dut.array_4_to_7.value = [0xB0, 0xA0, 0x90, 0x80]
dut.array_3_downto_0.value = [0x70, 0x60, 0x50, 0x40]
dut.array_0_to_3.value = [0x30, 0x20, 0x10, 0x00]
await Timer(1000, "ns")
_check_value(tlog, dut.array_7_downto_4, [0xF0, 0xE0, 0xD0, 0xC0])
_check_value(tlog, dut.array_4_to_7, [0xB0, 0xA0, 0x90, 0x80])
_check_value(tlog, dut.array_3_downto_0, [0x70, 0x60, 0x50, 0x40])
_check_value(tlog, dut.array_0_to_3, [0x30, 0x20, 0x10, 0x00])
# GHDL unable to put values on nested array types (gh-2588)
# iverilog flattens multi-dimensional unpacked arrays (gh-2595)
@cocotb.test(
expect_error=Exception
if cocotb.SIM_NAME.lower().startswith(("icarus", "ghdl"))
else ()
)
async def test_ndim_array_handles(dut):
"""Test getting and setting multi-dimensional array values using the handle of the full array."""
cocotb.start_soon(Clock(dut.clk, 1000, "ns").start())
dut.array_2d.value = [[0xF0, 0xE0, 0xD0, 0xC0], [0xB0, 0xA0, 0x90, 0x80]]
await Timer(1000, "ns")
_check_value(
tlog, dut.array_2d, [[0xF0, 0xE0, 0xD0, 0xC0], [0xB0, 0xA0, 0x90, 0x80]]
)
# GHDL unable to put values on nested array types (gh-2588)
@cocotb.test(
expect_error=Exception if cocotb.SIM_NAME.lower().startswith("ghdl") else ()
)
async def test_1dim_array_indexes(dut):
"""Test getting and setting values of array indexes."""
cocotb.start_soon(Clock(dut.clk, 1000, "ns").start())
dut.array_7_downto_4.value = [0xF0, 0xE0, 0xD0, 0xC0]
dut.array_4_to_7.value = [0xB0, 0xA0, 0x90, 0x80]
dut.array_3_downto_0.value = [0x70, 0x60, 0x50, 0x40]
dut.array_0_to_3.value = [0x30, 0x20, 0x10, 0x00]
await Timer(1000, "ns")
# Check indices
_check_value(tlog, dut.array_7_downto_4[7], 0xF0)
_check_value(tlog, dut.array_7_downto_4[4], 0xC0)
_check_value(tlog, dut.array_4_to_7[4], 0xB0)
_check_value(tlog, dut.array_4_to_7[7], 0x80)
_check_value(tlog, dut.array_3_downto_0[3], 0x70)
_check_value(tlog, dut.array_3_downto_0[0], 0x40)
_check_value(tlog, dut.array_0_to_3[0], 0x30)
_check_value(tlog, dut.array_0_to_3[3], 0x00)
_check_value(tlog, dut.array_0_to_3[1], 0x20)
# Get sub-handles through NonHierarchyIndexableObject.__getitem__
dut.array_7_downto_4[7].value = 0xDE
dut.array_4_to_7[4].value = 0xFC
dut.array_3_downto_0[0].value = 0xAB
dut.array_0_to_3[1].value = 0x7A
dut.array_0_to_3[3].value = 0x42
await Timer(1000, "ns")
_check_value(tlog, dut.array_7_downto_4[7], 0xDE)
_check_value(tlog, dut.array_4_to_7[4], 0xFC)
_check_value(tlog, dut.array_3_downto_0[0], 0xAB)
_check_value(tlog, dut.array_0_to_3[1], 0x7A)
_check_value(tlog, dut.array_0_to_3[3], 0x42)
# GHDL unable to put values on nested array types (gh-2588)
# iverilog flattens multi-dimensional unpacked arrays (gh-2595)
@cocotb.test(
expect_error=Exception
if cocotb.SIM_NAME.lower().startswith(("icarus", "ghdl"))
else ()
)
async def test_ndim_array_indexes(dut):
"""Test getting and setting values of multi-dimensional array indexes."""
cocotb.start_soon(Clock(dut.clk, 1000, "ns").start())
dut.array_2d.value = [[0xF0, 0xE0, 0xD0, 0xC0], [0xB0, 0xA0, 0x90, 0x80]]
await Timer(1000, "ns")
# Check indices
_check_value(tlog, dut.array_2d[1], [0xB0, 0xA0, 0x90, 0x80])
_check_value(tlog, dut.array_2d[0][31], 0xF0)
_check_value(tlog, dut.array_2d[1][29], 0x90)
_check_value(tlog, dut.array_2d[1][28], 0x80)
# Get sub-handles through NonHierarchyIndexableObject.__getitem__
dut.array_2d[1].value = [0xDE, 0xAD, 0xBE, 0xEF]
dut.array_2d[0][31].value = 0x0F
await Timer(1000, "ns")
_check_value(tlog, dut.array_2d[0][31], 0x0F)
_check_value(tlog, dut.array_2d[0][29], 0xD0)
_check_value(tlog, dut.array_2d[1][30], 0xAD)
_check_value(tlog, dut.array_2d[1][28], 0xEF)
# GHDL unable to access record signals (gh-2591)
# Icarus doesn't support structs (gh-2592)
@cocotb.test(
expect_error=AttributeError
if cocotb.SIM_NAME.lower().startswith(("icarus", "ghdl"))
else ()
)
async def test_struct(dut):
"""Test setting and getting values of structs."""
cocotb.start_soon(Clock(dut.clk, 1000, "ns").start())
dut.inout_if.a_in.value = 1
await Timer(1000, "ns")
_check_value(tlog, dut.inout_if.a_in, 1)
dut.inout_if.a_in.value = 0
await Timer(1000, "ns")
_check_value(tlog, dut.inout_if.a_in, 0)
@contextlib.contextmanager
def assert_raises(exc_type):
try:
yield
except exc_type as exc:
tlog.info(f" {exc_type.__name__} raised as expected: {exc}")
else:
raise AssertionError(f"{exc_type.__name__} was not raised")
@cocotb.test()
async def test_exceptions(dut):
"""Test that correct Exceptions are raised."""
with assert_raises(TypeError):
dut.array_7_downto_4.value = (0xF0, 0xE0, 0xD0, 0xC0)
with assert_raises(TypeError):
dut.array_4_to_7.value = Exception("Exception Object")
with assert_raises(ValueError):
dut.array_3_downto_0.value = [0x70, 0x60, 0x50]
with assert_raises(ValueError):
dut.array_0_to_3.value = [0x40, 0x30, 0x20, 0x10, 0x00]
|
recipes/Python/577810_Named_Values/recipe-577810.py
|
tdiprima/code
| 2,023 |
50689
|
class NamedValue:
# defining __slots__ in a mixin doesn't play nicely with builtin types
# so a low overhead approach would have to use collections.namedtuple
# style templated code generation
def __new__(cls, *args, **kwds):
name, *args = args
self = super().__new__(cls, *args, **kwds)
self._name = name
return self
def __init__(self, *args, **kwds):
name, *args = args
super().__init__(*args, **kwds)
@property
def __name__(self):
return self._name
def __repr__(self):
# repr() is updated to include the name and type info
return "{}({!r}, {})".format(type(self).__name__,
self.__name__,
super().__repr__())
def __str__(self):
# str() is unchanged, even if it relies on the repr() fallback
base = super()
base_str = base.__str__
if base_str.__objclass__ is object:
return base.__repr__()
return base_str()
# Example usage
>>> class NamedFloat(NamedValue, float):
... pass
...
>>> import math
>>> tau = NamedFloat('tau', 2*math.pi)
>>> tau
NamedFloat(tau, 6.283185307179586)
>>> print(tau)
6.283185307179586
>>> class NamedList(NamedValue, list):
... pass
...
>>> data = NamedList('data', [])
>>> data
NamedList('data', [])
>>> print(data)
[]
|
etc/pending_ugens/PulseDivider.py
|
butayama/supriya
| 191 |
50716
|
import collections
from supriya.enums import CalculationRate
from supriya.synthdefs import UGen
class PulseDivider(UGen):
"""
::
>>> pulse_divider = supriya.ugens.PulseDivider.ar(
... div=2,
... start=0,
... trigger=0,
... )
>>> pulse_divider
PulseDivider.ar()
"""
### CLASS VARIABLES ###
_ordered_input_names = collections.OrderedDict(
'trigger',
'div',
'start',
)
_valid_calculation_rates = None
### INITIALIZER ###
def __init__(
self,
calculation_rate=None,
div=2,
start=0,
trigger=0,
):
UGen.__init__(
self,
calculation_rate=calculation_rate,
div=div,
start=start,
trigger=trigger,
)
### PUBLIC METHODS ###
@classmethod
def ar(
cls,
div=2,
start=0,
trigger=0,
):
"""
Constructs an audio-rate PulseDivider.
::
>>> pulse_divider = supriya.ugens.PulseDivider.ar(
... div=2,
... start=0,
... trigger=0,
... )
>>> pulse_divider
PulseDivider.ar()
Returns ugen graph.
"""
import supriya.synthdefs
calculation_rate = supriya.CalculationRate.AUDIO
ugen = cls._new_expanded(
calculation_rate=calculation_rate,
div=div,
start=start,
trigger=trigger,
)
return ugen
@classmethod
def kr(
cls,
div=2,
start=0,
trigger=0,
):
"""
Constructs a control-rate PulseDivider.
::
>>> pulse_divider = supriya.ugens.PulseDivider.kr(
... div=2,
... start=0,
... trigger=0,
... )
>>> pulse_divider
PulseDivider.kr()
Returns ugen graph.
"""
import supriya.synthdefs
calculation_rate = supriya.CalculationRate.CONTROL
ugen = cls._new_expanded(
calculation_rate=calculation_rate,
div=div,
start=start,
trigger=trigger,
)
return ugen
### PUBLIC PROPERTIES ###
@property
def div(self):
"""
Gets `div` input of PulseDivider.
::
>>> pulse_divider = supriya.ugens.PulseDivider.ar(
... div=2,
... start=0,
... trigger=0,
... )
>>> pulse_divider.div
2.0
Returns ugen input.
"""
index = self._ordered_input_names.index('div')
return self._inputs[index]
@property
def start(self):
"""
Gets `start` input of PulseDivider.
::
>>> pulse_divider = supriya.ugens.PulseDivider.ar(
... div=2,
... start=0,
... trigger=0,
... )
>>> pulse_divider.start
0.0
Returns ugen input.
"""
index = self._ordered_input_names.index('start')
return self._inputs[index]
@property
def trigger(self):
"""
Gets `trigger` input of PulseDivider.
::
>>> pulse_divider = supriya.ugens.PulseDivider.ar(
... div=2,
... start=0,
... trigger=0,
... )
>>> pulse_divider.trigger
0.0
Returns ugen input.
"""
index = self._ordered_input_names.index('trigger')
return self._inputs[index]
|
concepts/listChunking.py
|
sixtysecondrevit/dynamoPython
| 114 |
50736
|
"""
LIST: CHUNKING
"""
__author__ = '<NAME> - <EMAIL>'
__twitter__ = '@solamour'
__version__ = '1.0.0'
# Example of Chunking (Grouping an item with its next)
def chunks(list, number): # Requires a list and a number
for index in range(0, len(list), number): # For every
# index inside of a number range starting at '0'
# and running to the length of the list, with steps
# of a chosen 'number'
yield list[index : index + number] # Yield returns
# a 'generator' object, so we cast the result to a
# 'list' and will return 'list slices' ranging from
# the chosen 'index' to the chosen 'index' + chosen
# 'number'
# Exemplar list
itemList = [0, 1, 2, 3, 4, 5] # A simple list of numbers to
# parse with our 'chunks' definition
count = 2 # A number which we want to chunk to. We choose '2'
# which will result in sublists of: [[0, 1], [2, 3], [4,5]]
chunksList = chunks(itemList, count) # Here we call our new
# 'chunks' definition on our 'itemList' and with our 'count'
# then push those results to our variable called 'chunksList'
OUT = chunksList # Returning our chunked data
|
src/badgr/datasets/dataset.py
|
KaiW-53/badgr
| 110 |
50749
|
<filename>src/badgr/datasets/dataset.py
class Dataset(object):
def __init__(self, env_spec):
self._env_spec = env_spec
def get_batch(self, batch_size, horizon):
raise NotImplementedError
def get_batch_iterator(self, batch_size, horizon, randomize_order=False, is_tf=True):
raise NotImplementedError
|
gulp_version.py
|
FelixBoers/sublime-gulp
| 138 |
50757
|
<gh_stars>100-1000
import re
# Workaround for Windows ST2 not having disutils
try:
from distutils.version import LooseVersion
except:
# From distutils/version.py
class LooseVersion():
component_re = re.compile(r'(\d+ | [a-z]+ | \.)', re.VERBOSE)
def __init__ (self, vstring=None):
if vstring:
self.parse(vstring)
def __ge__(self, other):
c = self._cmp(other)
if c is NotImplemented:
return c
return c >= 0
def parse (self, vstring):
self.vstring = vstring
components = [x for x in self.component_re.split(vstring) if x and x != '.']
for i, obj in enumerate(components):
try:
components[i] = int(obj)
except ValueError:
pass
self.version = components
def _cmp (self, other):
if isinstance(other, str):
other = LooseVersion(other)
if self.version == other.version:
return 0
if self.version < other.version:
return -1
if self.version > other.version:
return 1
#
# Actual class
#
class GulpVersion():
def __init__(self, version_string):
self.version_string = version_string or ""
def supports_tasks_simple(self):
# This is a mess. The new gulp-cli started from version 0 and does support tasks-simple,
# but there's no reliable way to check which one is installed
# So here we are, having to check if the CLI version is _not_ between 3.6.0 and 3.7.0 which works..for now
cli_version = LooseVersion(self.cli_version())
return cli_version >= LooseVersion("3.7.0") or cli_version <= LooseVersion("3.6.0")
def cli_version(self):
return self.get("CLI")
def local_version(self):
return self.get("Local")
def get(self, version_name):
re_match = re.search(version_name + " version (\d+\.\d+\.\d+)", self.version_string)
return re_match.group(1) if re_match else "3.6.0"
|
pennylane/debugging.py
|
therooler/pennylane
| 539 |
50766
|
<filename>pennylane/debugging.py
# Copyright 2018-2022 Xanadu Quantum Technologies Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
This module contains functionality for debugging quantum programs on simulator devices.
"""
from pennylane import DeviceError
class _Debugger:
"""A debugging context manager.
Without an active debugging context, devices will not save their internal state when
encoutering Snapshot operations. The debugger also serves as storage for the device states.
Args:
dev (Device): device to attach the debugger to
"""
def __init__(self, dev):
if "Snapshot" not in dev.operations:
raise DeviceError("Device does not support snapshots.")
self.snapshots = {}
self.active = False
self.device = dev
dev._debugger = self
def __enter__(self):
self.active = True
return self
def __exit__(self, exc_type, exc_value, exc_traceback):
self.active = False
self.device._debugger = None
def snapshots(qnode):
r"""Create a function that retrieves snapshot results from a QNode.
Args:
qnode (.QNode): the input QNode to be simulated
Returns:
A function that has the same argument signature as ``qnode`` and returns a dictionary.
When called, the function will execute the QNode on the registered device and retrieve
the saved snapshots obtained via the ``qml.Snapshot`` operation. Additionally, the snapshot
dictionary always contains the execution results of the QNode, so the use of the tag
"execution_results" should be avoided to prevent conflicting key names.
**Example**
.. code-block:: python3
dev = qml.device("default.qubit", wires=2)
@qml.qnode(dev, interface=None)
def circuit():
qml.Snapshot()
qml.Hadamard(wires=0)
qml.Snapshot("very_important_state")
qml.CNOT(wires=[0, 1])
qml.Snapshot()
return qml.expval(qml.PauliX(0))
>>> qml.snapshots(circuit)()
{0: array([1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j]),
'very_important_state': array([0.70710678+0.j, 0.+0.j, 0.70710678+0.j, 0.+0.j]),
2: array([0.70710678+0.j, 0.+0.j, 0.+0.j, 0.70710678+0.j]),
'execution_results': array(0.)}
"""
def get_snapshots(*args, **kwargs):
with _Debugger(qnode.device) as dbg:
results = qnode(*args, **kwargs)
dbg.snapshots["execution_results"] = results
return dbg.snapshots
return get_snapshots
|
Covid India Stats App/app.py
|
avinashkranjan/PraticalPythonProjects
| 930 |
50807
|
import json
from flask import Flask, request
import requests
# Token that has to be generated from webhook page portal
ACCESS_TOKEN = "random <PASSWORD>"
# Token that has to be added for verification with developer portal
VERIFICATION_TOKEN = "abc"
# Identifier payloads for initial button
C19INDIA = "C19INDIA"
app = Flask(__name__)
# This get endpoint is for verification with messenger app
@app.route('/webhook', methods=['GET'])
def webhook():
verify_token = request.args.get("hub.verify_token")
if verify_token == VERIFICATION_TOKEN:
return request.args.get("hub.challenge")
return 'Unable to authorise.'
@app.route("/webhook", methods=['POST'])
def webhook_handle():
data = request.get_json()
if data["object"] == "page": # To verify that the request is being originated from a page
for entry in data["entry"]:
for event in entry["messaging"]:
if event.get("message"): # somebody typed a message
process_message(event)
# user clicked/tapped "postback" button in earlier message
elif event.get("postback"):
process_postback(event)
return 'ok'
def process_message(event):
# the facebook ID of the person sending you the message
sender_id = event["sender"]["id"]
# could receive text or attachment but not both
if "text" in event["message"]:
send_initial_menu(sender_id)
def send_initial_menu(sender_id):
message_data = json.dumps({
"recipient": {
"id": sender_id
},
"message": {
"attachment": {
"type": "template",
"payload": {
"template_type": "generic",
"elements": [{
"title": "Covid India Stats",
"subtitle": "Get the covid19 stats of Indian states",
"buttons": [{
"type": "web_url",
"url": "https://www.worldometers.info/coronavirus/country/india/",
"title": "Open Worldometer India"
}, {
"type": "postback",
"title": "Get Stats By Indian States",
"payload": C19INDIA,
}],
}]
}
}
}
})
call_send_api(message_data)
def send_state_list(sender_id):
message_data = json.dumps({
"recipient": {
"id": sender_id
},
"message": {
"attachment": {
"type": "template",
"payload": {
"template_type": "generic",
"elements": [{
"title": "Select State",
"buttons": create_state_list(1)
}, {
"title": "Select State",
"buttons": create_state_list(2)
}, {
"title": "Select State",
"buttons": create_state_list(3)
}, {
"title": "Select State",
"buttons": create_state_list(4)
}, {
"title": "Select State",
"buttons": create_state_list(5)
}, {
"title": "Select State",
"buttons": create_state_list(6)
}, {
"title": "Select State",
"buttons": create_state_list(7)
}, {
"title": "Select State",
"buttons": create_state_list(8)
}, {
"title": "Select State",
"buttons": create_state_list(9)
}, {
"title": "Select State",
"buttons": create_state_list(10)
}]
}
}
}
})
call_send_api(message_data)
def create_state_list(index):
state_list = ["Maharashtra", "Kerala", "Karnataka", "Andhra Pradesh", "Tamil Nadu", "Delhi", "Uttar Pradesh",
"West Bengal", "Odisha", "Rajasthan", "Chhattisgarh", "Telangana", "Haryana", "Gujarat", "Bihar",
"Madhya Pradesh", "Assam", "Punjab", "Jharkhand", "Uttarakhand", "Himachal Pradesh", "Goa", "Tripura",
"Manipur", "<NAME>", "Meghalaya", "Nagaland", "Sikkim", "Mizoram"]
payload_list = []
start_index = 0 + 3 * (index - 1)
end_index = 29 if (start_index + 3) > 29 else (start_index + 3)
for i in range(start_index, end_index):
postback = {}
postback["type"] = "postback"
postback["title"] = state_list[i]
postback["payload"] = state_list[i]
payload_list.append(postback)
return payload_list
def get_stats_send(sender_id, state):
response = json.loads(requests.get(
"https://api.covid19india.org/data.json").text)
list_state = response['statewise']
for i in list_state:
if i['state'] == state:
x = i
break
message_data = json.dumps({
"recipient": {
"id": sender_id
},
"message": {
"text": "ACTIVE CASES: {}\nCONFIRMED CASES: {}\nDEATHS: {}\nRECOVERED: {}".format(x['active'],
x['confirmed'],
x['deaths'],
x['recovered'])
}
})
call_send_api(message_data)
def process_postback(event):
sender_id = event["sender"]["id"]
payload = event["postback"]["payload"]
if payload == C19INDIA:
send_state_list(sender_id)
else:
get_stats_send(sender_id, payload)
def call_send_api(message_data):
params = {
"access_token": ACCESS_TOKEN
}
headers = {
"Content-Type": "application/json"
}
r = requests.post("https://graph.facebook.com/v5.0/me/messages",
params=params, headers=headers, data=message_data)
if __name__ == "__main__":
app.run()
|
core_scripts/startup_config.py
|
Nijta/project-NN-Pytorch-scripts
| 150 |
50813
|
<gh_stars>100-1000
#!/usr/bin/env python
"""
startup_config
Startup configuration utilities
"""
from __future__ import absolute_import
import os
import sys
import torch
import importlib
import random
import numpy as np
__author__ = "<NAME>"
__email__ = "<EMAIL>"
__copyright__ = "Copyright 2020, Xin Wang"
def set_random_seed(random_seed, args=None):
""" set_random_seed(random_seed, args=None)
Set the random_seed for numpy, python, and cudnn
input
-----
random_seed: integer random seed
args: argue parser
"""
# initialization
torch.manual_seed(random_seed)
random.seed(random_seed)
np.random.seed(random_seed)
os.environ['PYTHONHASHSEED'] = str(random_seed)
#For torch.backends.cudnn.deterministic
#Note: this default configuration may result in RuntimeError
#see https://pytorch.org/docs/stable/notes/randomness.html
if args is None:
cudnn_deterministic = True
cudnn_benchmark = False
else:
cudnn_deterministic = args.cudnn_deterministic_toggle
cudnn_benchmark = args.cudnn_benchmark_toggle
if not cudnn_deterministic:
print("cudnn_deterministic set to False")
if cudnn_benchmark:
print("cudnn_benchmark set to True")
if torch.cuda.is_available():
torch.cuda.manual_seed_all(random_seed)
torch.backends.cudnn.deterministic = cudnn_deterministic
torch.backends.cudnn.benchmark = cudnn_benchmark
return
|
tests/test_auth.py
|
matrixorz/firefly
| 247 |
50818
|
<filename>tests/test_auth.py
# coding=utf-8
from __future__ import absolute_import
from flask import url_for
from flask_login import current_user
import pytest
from firefly.models.user import User
@pytest.mark.usefixtures('client_class')
class TestAuth:
def setup(self):
self.username = 'foo'
self.password = '<PASSWORD>'
self.email = '<EMAIL>'
User.create_user(
username=self.username, password=self.password,
email=self.email
)
def test_register(self):
username = 'foo2'
email = '<EMAIL>'
password = '<PASSWORD>'
form = {
'username': username,
'email': email,
'password': password
}
self.client.post(url_for('home.register'), data=form)
assert current_user.is_authenticated()
user = User.objects.get(email=email)
assert user.check_password(password)
def login(self):
form = {
'email': self.email,
'password': <PASSWORD>
}
rv = self.client.post(
url_for('home.login'), data=form,
follow_redirects=True
)
assert current_user.is_authenticated()
assert url_for('security.logout') in rv.data
def test_logout(self):
self.login()
self.client.get(url_for('security.logout'))
assert not current_user.is_authenticated()
|
genomepy/plugins/__init__.py
|
tilschaef/genomepy
| 146 |
50846
|
<reponame>tilschaef/genomepy
"""Plugin class, modules & related functions"""
import os
import re
from genomepy.config import config
__all__ = ["Plugin", "manage_plugins", "get_active_plugins"]
class Plugin:
"""Plugin base class."""
def __init__(self):
self.name = convert(type(self).__name__).replace("_plugin", "")
self.active = False
def activate(self):
self.active = True
def deactivate(self):
self.active = False
def after_genome_download(self, genome, threads, force):
raise NotImplementedError("plugin should implement this method")
def get_properties(self, genome):
raise NotImplementedError("plugin should implement this method")
def convert(name: str) -> str:
"""
Convert CamelCase to underscore. e.g. StarPlugin -> star_plugin
Parameters
----------
name : str
Camelcase string
Returns
-------
name : str
Converted name
"""
s1 = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", name)
return re.sub("([a-z0-9])([A-Z])", r"\1_\2", s1).lower()
def list_plugins() -> list:
plugin_dir = os.path.dirname(os.path.realpath(__file__))
plugin_files = [f for f in os.listdir(plugin_dir) if f.endswith(".py")]
plugin_names = [f[:-3] for f in plugin_files if not f.startswith("_")]
return plugin_names
def init_plugins():
"""
create a dictionary of plugin instances
Returns
-------
plugins : dictionary
key is plugin name, value Plugin object
"""
# import plugins
for plugin in list_plugins():
__import__(f"genomepy.plugins.{plugin}")
# for each Plugin subclass, save an instance to a dict
d = {}
active_plugins = config.get("plugin", [])
for c in Plugin.__subclasses__():
ins = c()
if ins.name in active_plugins:
ins.activate()
d[ins.name] = ins
return d
PLUGINS = init_plugins()
def get_active_plugins() -> list:
"""Returns all active plugin instances."""
return [inst for name, inst in PLUGINS.items() if inst.active]
def activate(name):
"""Activate plugin.
Parameters
----------
name : str
Plugin name.
"""
if name in PLUGINS:
PLUGINS[name].activate()
else:
raise ValueError(f"plugin {name} not found")
def deactivate(name):
"""Deactivate plugin.
Parameters
----------
name : str
Plugin name.
"""
if name in PLUGINS:
PLUGINS[name].deactivate()
else:
raise ValueError(f"plugin {name} not found")
def show_plugins():
active_plugins = config.get("plugin", [])
print("{:20}{}".format("plugin", "enabled"))
for plugin in sorted(PLUGINS):
print(
"{:20}{}".format(plugin, {False: "", True: "*"}[plugin in active_plugins])
)
def manage_plugins(command: str, plugin_names: list = None):
"""
Manage genomepy plugins
Parameters
----------
command : str
command to perform. Options:
list
show plugins and status
enable
enable plugins
disable
disable plugins
plugin_names : list
plugin names for the enable/disable command
"""
if command in ["show", "list"]:
return show_plugins()
active_plugins = config.get("plugin", [])
for name in plugin_names if plugin_names else []:
if name not in PLUGINS:
raise ValueError(f"Unknown plugin: '{name}'.")
if command in ["enable", "activate"]:
[active_plugins.append(name) for name in plugin_names]
elif command in ["disable", "deactivate"]:
[active_plugins.remove(name) for name in plugin_names]
else:
raise ValueError(
f"Invalid plugin command: '{command}'. Options: 'list', 'enable' or 'disable'."
)
active_plugins = sorted(list(set(active_plugins)))
config["plugin"] = active_plugins
config.save()
print(f"Enabled plugins: {', '.join(active_plugins)}")
|
scripts/loss.py
|
headupinclouds/LightNet
| 737 |
50865
|
from torch.autograd import Variable
import torch.nn.functional as F
import scripts.utils as utils
import torch.nn as nn
import numpy as np
import torch
class CrossEntropy2d(nn.Module):
def __init__(self, size_average=True, ignore_label=255):
super(CrossEntropy2d, self).__init__()
self.size_average = size_average
self.ignore_label = ignore_label
def forward(self, predict, target, weight=None):
"""
Args:
predict:(n, c, h, w)
target:(n, h, w)
weight (Tensor, optional): a manual rescaling weight given to each class.
If given, has to be a Tensor of size "nclasses"
"""
assert not target.requires_grad
assert predict.dim() == 4
assert target.dim() == 3
assert predict.size(0) == target.size(0), "{0} vs {1} ".format(predict.size(0), target.size(0))
assert predict.size(2) == target.size(1), "{0} vs {1} ".format(predict.size(2), target.size(1))
assert predict.size(3) == target.size(2), "{0} vs {1} ".format(predict.size(3), target.size(3))
n, c, h, w = predict.size()
target_mask = (target >= 0) * (target != self.ignore_label)
target = target[target_mask]
predict = predict.transpose(1, 2).transpose(2, 3).contiguous()
predict = predict[target_mask.view(n, h, w, 1).repeat(1, 1, 1, c)].view(-1, c)
loss = F.cross_entropy(predict, target, weight=weight, size_average=self.size_average)
return loss
def cross_entropy2d(input, target, weight=None, size_average=True):
# 1. input: (n, c, h, w), target: (n, h, w)
n, c, h, w = input.size()
# 2. log_p: (n, c, h, w)
log_p = F.log_softmax(input, dim=1)
# 3. log_p: (n*h*w, c) - contiguous() required if transpose() is used before view().
log_p = log_p.transpose(1, 2).transpose(2, 3).contiguous().view(-1, c)
log_p = log_p[target.view(n * h * w, 1).repeat(1, c) >= 0]
log_p = log_p.view(-1, c)
# 4. target: (n*h*w,)
mask = target >= 0
target = target[mask]
loss = F.nll_loss(log_p, target, ignore_index=250, weight=weight, size_average=False)
if size_average:
loss /= mask.data.sum()
# loss /= mask.sum().data[0]
return loss
def bootstrapped_cross_entropy2d(input, target, K, weight=None, size_average=False):
"""A categorical cross entropy loss for 4D tensors.
We assume the following layout: (batch, classes, height, width)
Args:
input: The outputs.
target: The predictions.
K: The number of pixels to select in the bootstrapping process.
The total number of pixels is determined as 512 * multiplier.
Returns:
The pixel-bootstrapped cross entropy loss.
"""
batch_size = input.size()[0]
def _bootstrap_xentropy_single(input, target, K, weight=None, size_average=False):
n, c, h, w = input.size()
# 1. The log softmax. log_p: (n, c, h, w)
log_p = F.log_softmax(input, dim=1)
# 2. log_p: (n*h*w, c) - contiguous() required if transpose() is used before view().
log_p = log_p.transpose(1, 2).transpose(2, 3).contiguous().view(-1, c)
log_p = log_p[target.view(n * h * w, 1).repeat(1, c) >= 0]
log_p = log_p.view(-1, c)
# 3. target: (n*h*w,)
mask = target >= 0
target = target[mask]
loss = F.nll_loss(log_p, target, weight=weight, ignore_index=250,
reduce=False, size_average=size_average)
# For each element in the batch, collect the top K worst predictions
topk_loss, _ = loss.topk(K)
reduced_topk_loss = topk_loss.sum() / K
return reduced_topk_loss
loss = 0.0
# Bootstrap from each image not entire batch
for i in range(batch_size):
loss += _bootstrap_xentropy_single(input=torch.unsqueeze(input[i], 0),
target=torch.unsqueeze(target[i], 0),
K=K,
weight=weight,
size_average=size_average)
return loss / float(batch_size)
class FocalLoss2D(nn.Module):
"""
Focal Loss, which is proposed in:
"Focal Loss for Dense Object Detection (https://arxiv.org/abs/1708.02002v2)"
"""
def __init__(self, num_classes=19, ignore_label=250, alpha=0.25, gamma=2, size_average=True):
"""
Loss(x, class) = - \alpha (1-softmax(x)[class])^gamma \log(softmax(x)[class])
:param num_classes: (int) num of the classes
:param ignore_label: (int) ignore label
:param alpha: (1D Tensor or Variable) the scalar factor
:param gamma: (float) gamma > 0;
reduces the relative loss for well-classified examples (probabilities > .5),
putting more focus on hard, mis-classified examples
:param size_average: (bool): By default, the losses are averaged over observations for each mini-batch.
If the size_average is set to False, the losses are
instead summed for each mini-batch.
"""
super(FocalLoss2D, self).__init__()
self.alpha = alpha
self.gamma = gamma
self.num_classes = num_classes
self.ignore_label = ignore_label
self.size_average = size_average
self.one_hot = Variable(torch.eye(self.num_classes))
def forward(self, cls_preds, cls_targets):
"""
:param cls_preds: (n, c, h, w)
:param cls_targets: (n, h, w)
:return:
"""
assert not cls_targets.requires_grad
assert cls_targets.dim() == 3
assert cls_preds.size(0) == cls_targets.size(0), "{0} vs {1} ".format(cls_preds.size(0), cls_targets.size(0))
assert cls_preds.size(2) == cls_targets.size(1), "{0} vs {1} ".format(cls_preds.size(2), cls_targets.size(1))
assert cls_preds.size(3) == cls_targets.size(2), "{0} vs {1} ".format(cls_preds.size(3), cls_targets.size(3))
if cls_preds.is_cuda:
self.one_hot = self.one_hot.cuda()
n, c, h, w = cls_preds.size()
# +++++++++++++++++++++++++++++++++++++++++++++++++++ #
# 1. target reshape and one-hot encode
# +++++++++++++++++++++++++++++++++++++++++++++++++++ #
# 1.1. target: (n*h*w,)
cls_targets = cls_targets.view(n * h * w, 1)
target_mask = (cls_targets >= 0) * (cls_targets != self.ignore_label)
cls_targets = cls_targets[target_mask]
cls_targets = self.one_hot.index_select(dim=0, index=cls_targets)
# +++++++++++++++++++++++++++++++++++++++++++++++++++ #
# 2. compute focal loss for multi-classification
# +++++++++++++++++++++++++++++++++++++++++++++++++++ #
# 2.1. The softmax. prob: (n, c, h, w)
prob = F.softmax(cls_preds, dim=1)
# 2.2. prob: (n*h*w, c) - contiguous() required if transpose() is used before view().
prob = prob.transpose(1, 2).transpose(2, 3).contiguous().view(-1, c)
prob = prob[target_mask.repeat(1, c)]
prob = prob.view(-1, c) # (n*h*w, c)
probs = torch.clamp((prob * cls_targets).sum(1).view(-1, 1), min=1e-8, max=1.0)
batch_loss = -self.alpha * (torch.pow((1 - probs), self.gamma)) * probs.log()
if self.size_average:
loss = batch_loss.mean()
else:
loss = batch_loss.sum()
return loss
class SemanticEncodingLoss(nn.Module):
def __init__(self, num_classes=19, ignore_label=250, alpha=0.25):
super(SemanticEncodingLoss, self).__init__()
self.alpha = alpha
self.num_classes = num_classes
self.ignore_label = ignore_label
def unique_encode(self, cls_targets):
batch_size, _, _ = cls_targets.size()
target_mask = (cls_targets >= 0) * (cls_targets != self.ignore_label)
cls_targets = [cls_targets[idx].masked_select(target_mask[idx]) for idx in np.arange(batch_size)]
# unique_cls = [np.unique(label.numpy(), return_counts=True) for label in cls_targets]
unique_cls = [np.unique(label.numpy()) for label in cls_targets]
encode = np.zeros((batch_size, self.num_classes), dtype=np.uint8)
for idx in np.arange(batch_size):
np.put(encode[idx], unique_cls[idx], 1)
return torch.from_numpy(encode).float()
def forward(self, predicts, enc_cls_target, size_average=True):
se_loss = F.binary_cross_entropy_with_logits(predicts, enc_cls_target, weight=None,
size_average=size_average)
return self.alpha * se_loss
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
# Lovasz-Softmax
# <NAME> 2018 ESAT-PSI KU Leuven
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #
def lovasz_grad(gt_sorted):
"""
Computes gradient of the Lovasz extension w.r.t sorted errors
See Alg. 1 in paper
"""
p = len(gt_sorted)
gts = gt_sorted.sum()
intersection = gts - gt_sorted.float().cumsum(0)
union = gts + (1 - gt_sorted).float().cumsum(0)
jaccard = 1. - intersection / union
if p > 1: # cover 1-pixel case
jaccard[1:p] = jaccard[1:p] - jaccard[0:-1]
return jaccard
def iou_binary(preds, labels, EMPTY=1., ignore=None, per_image=True):
"""
IoU for foreground class
binary: 1 foreground, 0 background
"""
if not per_image:
preds, labels = (preds,), (labels,)
ious = []
for pred, label in zip(preds, labels):
intersection = ((label == 1) & (pred == 1)).sum()
union = ((label == 1) | ((pred == 1) & (label != ignore))).sum()
if not union:
iou = EMPTY
else:
iou = float(intersection) / union
ious.append(iou)
iou = utils.mean(ious) # mean accross images if per_image
return 100 * iou
def iou(preds, labels, C, EMPTY=1., ignore=None, per_image=False):
"""
Array of IoU for each (non ignored) class
"""
if not per_image:
preds, labels = (preds,), (labels,)
ious = []
for pred, label in zip(preds, labels):
iou = []
for i in range(C):
if i != ignore: # The ignored label is sometimes among predicted classes (ENet - CityScapes)
intersection = ((label == i) & (pred == i)).sum()
union = ((label == i) | ((pred == i) & (label != ignore))).sum()
if not union:
iou.append(EMPTY)
else:
iou.append(float(intersection) / union)
ious.append(iou)
ious = map(utils.mean, zip(*ious)) # mean accross images if per_image
return 100 * np.array(ious)
def lovasz_softmax(probas, labels, only_present=False, per_image=False, ignore=None):
"""
Multi-class Lovasz-Softmax loss
probas: [B, C, H, W] Variable, class probabilities at each prediction (between 0 and 1)
labels: [B, H, W] Tensor, ground truth labels (between 0 and C - 1)
only_present: average only on classes present in ground truth
per_image: compute the loss per image instead of per batch
ignore: void class labels
"""
if per_image:
loss = utils.mean(lovasz_softmax_flat(*flatten_probas(prob, lab, ignore), only_present=only_present)
for prob, lab in zip(probas, labels))
else:
loss = lovasz_softmax_flat(*flatten_probas(probas, labels, ignore), only_present=only_present)
return loss
def lovasz_softmax_flat(probas, labels, only_present=False):
"""
Multi-class Lovasz-Softmax loss
probas: [P, C] Variable, class probabilities at each prediction (between 0 and 1)
labels: [P] Tensor, ground truth labels (between 0 and C - 1)
only_present: average only on classes present in ground truth
"""
C = probas.size(1)
losses = []
for c in range(C):
fg = (labels == c).float() # foreground for class c
if only_present and fg.sum() == 0:
continue
errors = (fg - probas[:, c]).abs()
errors_sorted, perm = torch.sort(errors, 0, descending=True)
perm = perm.data
fg_sorted = fg[perm]
losses.append(torch.dot(errors_sorted, lovasz_grad(fg_sorted)))
return utils.mean(losses)
def flatten_probas(scores, labels, ignore=None):
"""
Flattens predictions in the batch
"""
B, C, H, W = scores.size()
scores = scores.permute(0, 2, 3, 1).contiguous().view(-1, C) # B * H * W, C = P, C
labels = labels.view(-1)
if ignore is None:
return scores, labels
valid = (labels != ignore)
vscores = scores[valid.nonzero().squeeze()]
vlabels = labels[valid]
return vscores, vlabels
if __name__ == "__main__":
from torch.autograd import Variable
while True:
dummy_in = Variable(torch.randn(2, 3, 32, 32), requires_grad=True)
dummy_gt = Variable(torch.LongTensor(2, 32, 32).random_(0, 3))
dummy_in = F.softmax(dummy_in, dim=1)
loss = lovasz_softmax(dummy_in, dummy_gt, ignore=255)
print(loss.data[0])
|
examples/demo_DDPG_TD3_SAC.py
|
Yonv1943/DL_RL_Zoo
| 129 |
50869
|
<gh_stars>100-1000
<<<<<<< HEAD
import sys
import gym
from elegantrl.train.run import train_and_evaluate, train_and_evaluate_mp
from elegantrl.train.config import Arguments
from elegantrl.agents.AgentDDPG import AgentDDPG
from elegantrl.agents.AgentTD3 import AgentTD3
from elegantrl.agents.AgentSAC import AgentSAC, AgentReliableSAC
def demo_ddpg_td3_sac(gpu_id, drl_id, env_id): # 2022.02.02
env_name = ['Pendulum-v0',
'Pendulum-v1',
'LunarLanderContinuous-v2',
'BipedalWalker-v3',
'Hopper-v2',
'Humanoid-v3', ][env_id]
agent = [AgentDDPG, AgentTD3, AgentSAC, AgentReliableSAC][drl_id]
if env_name in {'Pendulum-v0', 'Pendulum-v1'}:
from elegantrl.envs.CustomGymEnv import PendulumEnv
env = PendulumEnv(env_name, target_return=-500)
"""
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
2 1.60e+03-1147.49 |-1147.49 179.2 200 0 | -2.61 0.90 0.55 1.00
2 5.84e+04 -121.61 | -121.61 59.0 200 0 | -0.81 0.33 -40.64 0.79
| UsedTime: 132 |
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
1 1.60e+03-1267.96 |-1267.96 329.7 200 0 | -2.67 0.88 0.56 1.00
1 8.48e+04 -171.79 | -182.24 63.3 200 0 | -0.30 0.32 -30.75 0.64
1 1.19e+05 -171.79 | -178.25 116.8 200 0 | -0.31 0.16 -22.52 0.43
1 1.34e+05 -164.56 | -164.56 99.1 200 0 | -0.31 0.15 -18.09 0.35
1 1.47e+05 -135.20 | -135.20 92.1 200 0 | -0.31 0.14 -15.65 0.29
| UsedTime: 783 |
"""
args = Arguments(agent, env)
args.reward_scale = 2 ** -1 # RewardRange: -1800 < -200 < -50 < 0
args.gamma = 0.97
args.target_step = args.max_step * 2
args.eval_times = 2 ** 3
elif env_name == 'LunarLanderContinuous-v2':
"""
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
2 4.25e+03 -143.93 | -143.93 29.6 69 12 | -2.47 1.06 0.13 0.15
2 1.05e+05 170.35 | 170.35 57.9 645 177 | 0.06 1.59 15.93 0.20
2 1.59e+05 170.35 | 80.46 125.0 775 285 | 0.07 1.14 29.92 0.29
2 1.95e+05 221.39 | 221.39 19.7 449 127 | 0.12 1.09 32.16 0.40
| UsedTime: 421 |
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
1 4.26e+03 -139.77 | -139.77 36.7 67 12 | -2.16 11.20 0.12 0.15
1 1.11e+05 -105.09 | -105.09 84.3 821 244 | -0.14 27.60 1.04 0.21
1 2.03e+05 -15.21 | -15.21 22.7 1000 0 | -0.01 17.96 36.95 0.45
1 3.87e+05 59.39 | 54.09 160.7 756 223 | 0.00 16.57 88.99 0.73
1 4.03e+05 59.39 | 56.16 103.5 908 120 | 0.06 16.47 84.27 0.71
1 5.10e+05 186.59 | 186.59 103.6 547 257 | -0.02 12.72 67.97 0.57
1 5.89e+05 226.93 | 226.93 20.0 486 154 | 0.13 9.27 68.29 0.51
| UsedTime: 3407 |
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
1 4.15e+03 -169.01 | -169.01 87.9 110 59 | -2.18 11.86 0.10 0.15
1 1.09e+05 -84.47 | -84.47 80.1 465 293 | -0.30 30.64 -6.29 0.20
1 4.25e+05 -8.33 | -8.33 48.4 994 26 | 0.07 13.51 76.99 0.62
1 4.39e+05 87.29 | 87.29 86.9 892 141 | 0.04 12.76 70.37 0.61
1 5.57e+05 159.17 | 159.17 65.7 721 159 | 0.10 10.31 59.90 0.51
1 5.87e+05 190.09 | 190.09 71.7 577 175 | 0.09 9.45 61.74 0.48
1 6.20e+05 206.74 | 206.74 29.1 497 108 | 0.09 9.21 62.06 0.47
| UsedTime: 4433 |
"""
# env = gym.make('LunarLanderContinuous-v2')
# get_gym_env_args(env=env, if_print=True)
env_func = gym.make
env_args = {'env_num': 1,
'env_name': 'LunarLanderContinuous-v2',
'max_step': 1000,
'state_dim': 8,
'action_dim': 2,
'if_discrete': False,
'target_return': 200,
'id': 'LunarLanderContinuous-v2'}
args = Arguments(agent, env_func=env_func, env_args=env_args)
args.target_step = args.max_step
args.gamma = 0.99
args.eval_times = 2 ** 5
elif env_name == 'BipedalWalker-v3':
"""
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
3 7.51e+03 -111.59 | -111.59 0.2 97 7 | -0.18 4.23 -0.03 0.02
3 1.48e+05 -110.19 | -110.19 1.6 84 30 | -0.59 2.46 3.18 0.03
3 5.02e+05 -31.84 | -102.27 54.0 1359 335 | -0.06 0.85 2.84 0.04
3 1.00e+06 -7.94 | -7.94 73.2 411 276 | -0.17 0.72 1.96 0.03
3 1.04e+06 131.50 | 131.50 168.3 990 627 | 0.06 0.46 1.69 0.04
3 1.11e+06 214.12 | 214.12 146.6 1029 405 | 0.09 0.50 1.63 0.04
3 1.20e+06 308.34 | 308.34 0.7 1106 20 | 0.29 0.72 4.56 0.05
| UsedTime: 8611 |
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
3 6.75e+03 -92.44 | -92.44 0.2 120 3 | -0.18 1.94 -0.00 0.02
3 3.95e+05 -37.16 | -37.16 9.2 1600 0 | -0.06 1.90 4.20 0.07
3 6.79e+05 -23.32 | -42.54 90.0 1197 599 | -0.02 0.91 1.57 0.04
3 6.93e+05 46.92 | 46.92 96.9 808 395 | -0.04 0.57 1.34 0.04
3 8.38e+05 118.86 | 118.86 154.5 999 538 | 0.14 1.44 0.75 0.05
3 1.00e+06 225.56 | 225.56 124.1 1207 382 | 0.13 0.72 4.75 0.06
3 1.02e+06 283.37 | 283.37 86.3 1259 245 | 0.14 0.80 3.96 0.06
3 1.19e+06 313.36 | 313.36 0.9 1097 20 | 0.21 0.78 6.80 0.06
| UsedTime: 9354 | SavedDir: ./BipedalWalker-v3_ModSAC_3
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
3 6.55e+03 -109.86 | -109.86 4.5 156 30 | -0.06 0.71 -0.01 0.02
3 1.24e+05 -88.28 | -88.28 26.2 475 650 | -0.15 0.15 0.04 0.02
3 3.01e+05 -47.89 | -56.76 21.7 1341 540 | -0.03 0.19 -2.76 0.05
3 3.82e+05 80.89 | 53.79 140.1 983 596 | -0.01 0.18 0.46 0.05
3 4.35e+05 137.70 | 28.54 104.7 936 581 | -0.01 0.21 0.63 0.06
3 4.80e+05 158.71 | 25.54 114.7 524 338 | 0.18 0.17 6.17 0.06
3 5.31e+05 205.81 | 203.27 143.9 1048 388 | 0.14 0.15 4.00 0.06
3 6.93e+05 254.40 | 252.74 121.1 992 280 | 0.21 0.12 7.34 0.06
3 7.11e+05 304.79 | 304.79 73.4 1015 151 | 0.21 0.12 5.69 0.06
| UsedTime: 3215 |
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
1 7.08e+03 -106.48 | -106.48 6.0 170 17 | -0.14 0.70 0.03 0.02
1 2.38e+05 -89.62 | -89.62 29.8 775 728 | -0.30 0.31 -13.44 0.04
1 4.12e+05 -33.40 | -34.50 27.6 1342 516 | -0.01 0.20 1.34 0.06
1 5.05e+05 2.54 | -47.29 20.9 1342 516 | 0.02 0.17 0.24 0.05
1 5.43e+05 52.93 | 52.93 107.6 1084 540 | -0.21 0.15 0.32 0.05
1 5.80e+05 138.30 | 136.60 77.6 1460 176 | 0.10 0.16 2.14 0.05
1 6.16e+05 188.98 | 171.72 99.2 1386 305 | 0.12 0.16 -0.40 0.05
1 7.06e+05 250.72 | 231.97 142.9 1247 448 | 0.12 0.13 2.81 0.05
1 8.06e+05 287.28 | -68.06 5.9 211 19 | -0.08 0.12 7.83 0.06
1 8.56e+05 291.10 | 286.19 56.0 1181 63 | 0.17 0.13 6.37 0.06
1 8.83e+05 314.54 | 314.54 1.0 1252 19 | 0.11 0.12 7.23 0.06
| UsedTime: 5008 |
"""
env_func = gym.make
env_args = {'env_num': 1,
'env_name': 'BipedalWalker-v3',
'max_step': 1600,
'state_dim': 24,
'action_dim': 4,
'if_discrete': False,
'target_return': 300,
'id': 'BipedalWalker-v3', }
args = Arguments(agent, env_func=env_func, env_args=env_args)
args.target_step = args.max_step
args.gamma = 0.98
args.eval_times = 2 ** 4
elif env_name == 'Hopper-v2':
"""
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
5 1.61e+04 131.99 | 131.99 3.6 81 2 | 0.03 0.09 0.03 -0.54
5 2.20e+05 391.44 | 391.44 0.3 158 0 | 0.08 0.01 -0.06 -0.75
5 4.25e+05 860.96 | 860.96 11.9 280 5 | 0.09 0.11 0.12 -0.84
5 6.27e+05 3001.43 | 3001.43 7.9 1000 0 | 0.10 0.78 -0.01 -0.85
5 1.64e+06 3203.09 | 3103.14 0.0 1000 0 | 0.10 1.82 -0.06 -0.76
5 2.86e+06 3256.43 | 3152.72 0.0 1000 0 | 0.10 0.75 0.01 -0.67
5 3.88e+06 3256.43 | 1549.69 0.0 512 0 | 0.10 0.86 0.00 -0.71
| UsedTime: 2565 |
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
2 1.60e+04 328.68 | 328.68 6.2 262 6 | 0.02 0.01 -0.02 -0.54
2 2.16e+05 2460.57 | 2460.57 14.3 1000 0 | 0.09 0.86 0.20 -0.74
2 6.22e+05 2789.97 | 2788.28 30.9 1000 0 | 0.10 0.40 -0.11 -1.04
2 1.23e+06 3263.16 | 3216.96 0.0 1000 0 | 0.10 1.06 0.12 -1.05
2 2.46e+06 3378.50 | 3364.02 0.0 1000 0 | 0.11 0.87 0.02 -0.92
2 3.90e+06 3397.88 | 3302.80 0.0 1000 0 | 0.11 0.46 0.01 -0.93
| UsedTime: 2557 |
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
4 2.41e+04 222.39 | 222.39 1.5 120 1 | 0.94 8.45 0.05 -0.55
4 5.34e+05 344.58 | 344.58 0.4 142 0 | 2.41 1.91 0.02 -0.94
4 8.74e+05 540.69 | 540.69 20.1 180 4 | 2.96 5.82 0.00 -1.10
4 1.39e+06 989.51 | 989.51 2.2 308 2 | 3.20 16.75 0.07 -1.08
4 1.73e+06 3161.60 | 3149.35 0.0 1000 0 | 3.26 43.84 -0.02 -1.08
4 2.06e+06 3367.27 | 3105.77 0.0 1000 0 | 3.32 44.14 0.00 -1.13
4 3.92e+06 3604.42 | 3565.39 0.0 1000 0 | 3.44 30.54 0.04 -1.04
4 5.76e+06 3717.06 | 3607.94 0.0 1000 0 | 3.40 51.92 0.07 -0.95
4 6.26e+06 3840.95 | 3409.25 0.0 1000 0 | 3.32 66.48 -0.02 -0.94
| UsedTime: 6251 |
"""
env_func = gym.make
env_args = {
'env_num': 1,
'env_name': 'Hopper-v2',
'max_step': 1000,
'state_dim': 11,
'action_dim': 3,
'if_discrete': False,
'target_return': 3800.,
}
args = Arguments(agent, env_func=env_func, env_args=env_args)
args.eval_times = 2 ** 2
args.reward_scale = 2 ** -4
args.target_step = args.max_step * 2
args.worker_num = 2
args.net_dim = 2 ** 8
args.layer_num = 3
args.batch_size = int(args.net_dim * 2)
args.repeat_times = 2 ** 4
args.gamma = 0.99
args.if_allow_break = False
args.break_step = int(8e6)
elif env_name == 'Humanoid-v3':
from elegantrl.envs.CustomGymEnv import HumanoidEnv
env_func = HumanoidEnv
env_args = {
'env_num': 1,
'env_name': 'Humanoid-v3',
'max_step': 1000,
'state_dim': 376,
'action_dim': 17,
'if_discrete': False,
'target_return': 3000.,
}
args = Arguments(agent, env_func=env_func, env_args=env_args)
args.eval_times = 2 ** 2
args.reward_scale = 2 ** -4
args.max_memo = 2 ** 21
args.learning_rate = 2 ** -14
args.coeff_a_log_std = 2 ** -6
args.target_step = args.max_step
args.worker_num = 4
args.net_dim = 2 ** 8
args.layer_num = 4
args.batch_size = args.net_dim
args.repeat_times = 2 ** 1
args.gamma = 0.99
args.if_act_target = False # todo
import numpy as np
args.target_entropy = np.log(env_args['action_dim']) # todo
args.if_allow_break = False
args.break_step = int(2e6)
elif env_name == 'Humanoid-v3.backup':
from elegantrl.envs.CustomGymEnv import HumanoidEnv
env_func = HumanoidEnv
env_args = {
'env_num': 1,
'env_name': 'Humanoid-v3',
'max_step': 1000,
'state_dim': 376,
'action_dim': 17,
'if_discrete': False,
'target_return': 3000.,
}
args = Arguments(agent, env_func=env_func, env_args=env_args)
args.eval_times = 2 ** 2
args.reward_scale = 2 ** -4
args.max_memo = 2 ** 21
args.learning_rate = 2 ** -14
args.coeff_a_log_std = 2 ** -6
args.target_step = args.max_step
args.worker_num = 4
args.net_dim = 2 ** 8
args.layer_num = 4
args.batch_size = args.net_dim
args.repeat_times = 2 ** 1
args.gamma = 0.99
args.if_allow_break = False
args.break_step = int(2e6)
"""
| Arguments Remove cwd: ./Humanoid-v3_ReliableSAC_2
################################################################################
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
2 8.07e+03 76.16 |
2 8.07e+03 76.16 | 76.16 0.1 16 0 | 0.30 0.55 -0.11 0.00
2 8.47e+04 226.51 |
2 8.47e+04 226.51 | 226.51 12.0 45 2 | 0.29 0.03 4.31 0.00
2 1.26e+05 330.59 |
2 1.26e+05 330.59 | 330.59 12.2 70 2 | 0.29 0.07 8.89 0.00
2 1.59e+05 502.37 |
2 1.59e+05 502.37 | 502.37 74.8 102 13 | 0.33 0.08 10.22 0.00
2 1.89e+05 502.37 | 271.74 0.0 51 0 | 0.32 0.13 13.05 0.00
2 2.13e+05 502.37 | 263.78 0.0 58 0 | 0.32 0.16 12.73 0.01
2 2.34e+05 502.37 | 333.15 0.0 65 0 | 0.28 0.15 13.12 0.01
2 2.55e+05 502.37 | 480.34 70.0 105 13 | 0.32 0.13 11.47 0.02
2 2.76e+05 538.58 |
2 2.76e+05 538.58 | 538.58 108.7 108 19 | 0.31 0.11 12.34 0.02
2 2.92e+05 538.58 | 357.07 0.0 68 0 | 0.30 0.12 12.55 0.02
2 3.09e+05 538.58 | 401.06 0.0 79 0 | 0.30 0.12 12.48 0.02
2 3.26e+05 538.58 | 359.38 0.0 78 0 | 0.31 0.13 14.05 0.02
2 3.43e+05 538.58 | 415.86 0.0 98 0 | 0.30 0.14 14.95 0.02
2 3.59e+05 538.58 | 427.16 0.0 80 0 | 0.31 0.15 14.31 0.02
2 3.77e+05 538.58 | 486.99 0.0 93 0 | 0.30 0.16 14.94 0.02
2 3.89e+05 538.58 | 462.94 0.0 101 0 | 0.30 0.17 15.75 0.02
2 4.01e+05 538.58 | 419.89 0.0 99 0 | 0.30 0.18 15.39 0.02
2 4.14e+05 538.58 | 479.96 0.0 90 0 | 0.31 0.19 15.36 0.02
2 4.27e+05 538.58 | 537.61 0.0 119 0 | 0.30 0.20 15.81 0.02
2 4.39e+05 538.58 | 363.96 0.0 75 0 | 0.30 0.21 15.95 0.02
2 4.52e+05 538.58 | 535.53 158.0 110 35 | 0.30 0.21 17.68 0.02
2 4.65e+05 538.58 | 434.56 0.0 90 0 | 0.31 0.22 17.65 0.02
2 4.78e+05 538.58 | 421.31 0.0 88 0 | 0.31 0.22 16.96 0.02
2 4.91e+05 538.58 | 372.28 0.0 74 0 | 0.30 0.23 17.25 0.02
2 5.03e+05 538.58 | 455.47 128.7 96 29 | 0.30 0.23 18.11 0.02
2 5.16e+05 538.58 | 428.26 0.0 86 0 | 0.31 0.24 18.75 0.02
2 5.29e+05 538.58 | 316.51 0.0 62 0 | 0.31 0.24 19.18 0.02
2 5.42e+05 615.80 |
2 5.42e+05 615.80 | 615.80 96.7 123 21 | 0.31 0.25 21.45 0.02
2 5.54e+05 826.89 |
2 5.54e+05 826.89 | 826.89 104.2 168 26 | 0.30 0.27 20.43 0.02
2 5.67e+05 826.89 | 450.51 0.0 92 0 | 0.31 0.27 19.76 0.02
2 5.80e+05 826.89 | 498.25 0.0 92 0 | 0.31 0.27 21.87 0.02
2 5.93e+05 826.89 | 815.60 147.8 166 33 | 0.31 0.27 22.05 0.02
2 6.02e+05 826.89 | 699.31 0.0 147 0 | 0.30 0.28 22.44 0.02
2 6.10e+05 826.89 | 643.56 0.0 126 0 | 0.31 0.28 23.44 0.02
2 6.19e+05 826.89 | 167.29 0.0 33 0 | 0.31 0.28 23.14 0.02
2 6.28e+05 826.89 | 367.48 0.0 74 0 | 0.31 0.29 23.11 0.02
2 6.36e+05 826.89 | 658.05 0.0 127 0 | 0.31 0.29 22.56 0.02
2 6.45e+05 826.89 | 746.85 0.0 147 0 | 0.31 0.29 23.29 0.02
2 6.54e+05 826.89 | 767.08 0.0 168 0 | 0.30 0.29 21.61 0.02
2 6.62e+05 826.89 | 736.44 0.0 139 0 | 0.30 0.30 23.38 0.02
2 6.71e+05 826.89 | 436.42 0.0 94 0 | 0.30 0.30 22.17 0.02
2 6.80e+05 826.89 | 634.87 0.0 120 0 | 0.30 0.29 24.19 0.02
2 6.89e+05 826.89 | 595.90 189.0 123 44 | 0.31 0.29 26.35 0.02
2 6.97e+05 826.89 | 567.10 0.0 107 0 | 0.31 0.31 24.67 0.02
2 7.06e+05 826.89 | 595.54 0.0 114 0 | 0.31 0.31 24.35 0.02
2 7.15e+05 826.89 | 399.45 0.0 77 0 | 0.31 0.30 23.58 0.02
2 7.23e+05 826.89 | 434.58 0.0 85 0 | 0.31 0.31 25.30 0.02
2 7.32e+05 826.89 | 446.36 0.0 83 0 | 0.31 0.31 26.40 0.02
2 7.40e+05 826.89 | 537.46 0.0 97 0 | 0.31 0.31 24.95 0.02
2 7.49e+05 826.89 | 671.12 0.0 137 0 | 0.32 0.30 24.95 0.02
2 7.58e+05 826.89 | 453.14 0.0 87 0 | 0.31 0.31 25.86 0.02
2 7.67e+05 826.89 | 691.16 0.0 130 0 | 0.31 0.30 25.07 0.02
2 7.75e+05 1530.83 |
2 7.75e+05 1530.83 | 1530.83 396.3 297 80 | 0.30 0.31 23.88 0.02
2 7.84e+05 1530.83 | 891.09 0.0 180 0 | 0.31 0.30 25.45 0.02
2 7.93e+05 1530.83 | 360.46 0.0 70 0 | 0.31 0.31 26.00 0.02
2 8.01e+05 1530.83 | 452.85 0.0 90 0 | 0.30 0.30 24.52 0.02
2 8.10e+05 1530.83 | 663.09 0.0 131 0 | 0.32 0.30 26.27 0.02
2 8.19e+05 1530.83 | 1212.53 511.4 247 106 | 0.31 0.30 26.67 0.02
2 8.28e+05 1530.83 | 799.14 0.0 151 0 | 0.31 0.30 23.82 0.02
2 8.37e+05 1530.83 | 779.43 0.0 156 0 | 0.31 0.30 25.61 0.02
2 8.45e+05 1530.83 | 631.44 0.0 118 0 | 0.31 0.30 25.03 0.02
2 8.54e+05 1530.83 | 1248.43 0.0 248 0 | 0.31 0.30 25.75 0.02
2 8.63e+05 1530.83 | 928.86 0.0 182 0 | 0.31 0.30 26.13 0.02
2 8.73e+05 1530.83 | 1125.56 0.0 219 0 | 0.31 0.30 26.08 0.02
2 8.82e+05 1530.83 | 698.18 0.0 145 0 | 0.31 0.30 26.49 0.02
2 8.91e+05 1530.83 | 961.80 0.0 212 0 | 0.30 0.30 26.33 0.02
2 9.00e+05 1530.83 | 1174.05 0.0 230 0 | 0.31 0.30 26.08 0.02
2 9.09e+05 1530.83 | 1100.58 0.0 239 0 | 0.31 0.30 27.55 0.02
2 9.18e+05 1868.20 |
2 9.18e+05 1868.20 | 1868.20 164.8 371 30 | 0.30 0.30 26.45 0.02
2 9.28e+05 1868.20 | 1073.36 0.0 201 0 | 0.31 0.30 26.89 0.02
2 9.37e+05 1868.20 | 1205.66 0.0 230 0 | 0.31 0.30 26.77 0.02
2 9.46e+05 1868.20 | 1372.51 0.0 267 0 | 0.31 0.29 28.57 0.02
2 9.56e+05 1868.20 | 798.34 0.0 154 0 | 0.31 0.30 28.85 0.02
2 9.66e+05 1868.20 | 1428.51 788.3 277 150 | 0.32 0.29 27.15 0.02
2 9.75e+05 1868.20 | 608.42 0.0 116 0 | 0.31 0.28 29.42 0.02
2 9.85e+05 1868.20 | 325.33 0.0 64 0 | 0.31 0.29 28.10 0.02
2 9.95e+05 1928.41 |
2 9.95e+05 1928.41 | 1928.41 822.3 379 159 | 0.32 0.29 29.61 0.02
2 1.00e+06 1928.41 | 1149.56 0.0 226 0 | 0.31 0.29 28.76 0.02
2 1.01e+06 1928.41 | 1721.60 0.0 345 0 | 0.31 0.28 28.38 0.02
2 1.02e+06 1928.41 | 1185.92 0.0 223 0 | 0.32 0.29 27.91 0.02
2 1.03e+06 1928.41 | 1233.72 0.0 244 0 | 0.31 0.28 28.91 0.02
2 1.04e+06 1928.41 | 1551.67 0.0 303 0 | 0.31 0.28 29.68 0.02
2 1.05e+06 1928.41 | 978.83 0.0 192 0 | 0.31 0.28 28.76 0.02
2 1.06e+06 2257.10 |
2 1.06e+06 2257.10 | 2257.10 674.7 421 120 | 0.31 0.28 29.41 0.02
2 1.07e+06 2257.10 | 2150.05 0.0 401 0 | 0.32 0.28 29.53 0.02
2 1.08e+06 2257.10 | 775.42 0.0 149 0 | 0.31 0.28 29.71 0.02
2 1.09e+06 2257.10 | 681.05 0.0 134 0 | 0.31 0.28 29.51 0.02
2 1.10e+06 2257.10 | 1053.45 0.0 209 0 | 0.31 0.28 28.97 0.02
2 1.11e+06 2257.10 | 850.63 0.0 170 0 | 0.31 0.27 29.28 0.02
2 1.12e+06 2257.10 | 1736.51 0.0 344 0 | 0.31 0.28 30.47 0.02
2 1.13e+06 2257.10 | 1936.67 0.0 370 0 | 0.32 0.27 29.64 0.02
2 1.14e+06 2257.10 | 2247.72 1388.4 426 262 | 0.31 0.26 30.76 0.02
2 1.15e+06 2825.53 |
2 1.15e+06 2825.53 | 2825.53 1191.8 556 232 | 0.32 0.26 30.33 0.02
2 1.16e+06 2825.53 | 2546.58 1666.1 498 332 | 0.32 0.27 30.56 0.02
2 1.17e+06 2825.53 | 850.81 0.0 166 0 | 0.32 0.26 29.23 0.01
2 1.18e+06 2825.53 | 1411.25 0.0 280 0 | 0.32 0.26 28.02 0.01
2 1.19e+06 2825.53 | 538.52 0.0 109 0 | 0.32 0.26 31.44 0.01
2 1.19e+06 2825.53 | 2693.81 0.0 508 0 | 0.31 0.26 30.05 0.01
2 1.20e+06 2978.43 |
2 1.20e+06 2978.43 | 2978.43 1663.4 573 317 | 0.32 0.25 30.95 0.01
2 1.20e+06 3575.62 |
2 1.20e+06 3575.62 | 3575.62 1612.5 694 314 | 0.31 0.26 31.57 0.01
2 1.21e+06 3575.62 | 993.93 0.0 186 0 | 0.32 0.25 29.87 0.01
2 1.21e+06 3575.62 | 1999.92 0.0 392 0 | 0.31 0.26 30.52 0.01
2 1.22e+06 3575.62 | 889.42 0.0 171 0 | 0.33 0.25 30.81 0.01
2 1.22e+06 3575.62 | 3405.88 1731.5 668 338 | 0.32 0.25 31.85 0.01
2 1.23e+06 3575.62 | 892.11 0.0 168 0 | 0.32 0.25 31.85 0.01
2 1.23e+06 3575.62 | 778.46 0.0 147 0 | 0.32 0.25 31.28 0.01
2 1.24e+06 3575.62 | 1535.40 0.0 310 0 | 0.32 0.25 31.43 0.01
2 1.24e+06 3575.62 | 2843.25 1210.4 554 243 | 0.32 0.25 29.70 0.01
2 1.25e+06 3575.62 | 3353.49 0.0 631 0 | 0.31 0.25 30.64 0.01
2 1.25e+06 3575.62 | 883.32 0.0 170 0 | 0.32 0.25 31.49 0.01
2 1.26e+06 3575.62 | 3092.77 1210.6 606 226 | 0.32 0.25 31.16 0.01
2 1.26e+06 3575.62 | 569.80 0.0 112 0 | 0.32 0.24 31.06 0.01
2 1.27e+06 3575.62 | 1041.53 0.0 197 0 | 0.31 0.24 31.33 0.01
2 1.28e+06 3575.62 | 3255.92 0.0 638 0 | 0.33 0.24 30.84 0.01
2 1.28e+06 3575.62 | 2279.13 0.0 434 0 | 0.33 0.24 33.50 0.01
2 1.29e+06 3575.62 | 559.01 0.0 107 0 | 0.32 0.24 32.44 0.01
2 1.29e+06 3575.62 | 3277.19 0.0 649 0 | 0.32 0.25 32.05 0.01
2 1.29e+06 3575.62 | 1050.02 0.0 204 0 | 0.33 0.24 31.84 0.01
2 1.30e+06 3575.62 | 715.11 0.0 138 0 | 0.32 0.24 32.69 0.01
2 1.31e+06 3575.62 | 569.46 0.0 111 0 | 0.32 0.24 31.83 0.01
2 1.31e+06 3575.62 | 948.73 0.0 180 0 | 0.33 0.25 32.41 0.01
2 1.31e+06 3575.62 | 1140.72 0.0 224 0 | 0.33 0.24 30.14 0.01
2 1.32e+06 3575.62 | 1303.37 0.0 249 0 | 0.32 0.24 30.97 0.01
2 1.32e+06 3575.62 | 2585.92 0.0 511 0 | 0.33 0.24 30.48 0.01
2 1.33e+06 4376.07 |
2 1.33e+06 4376.07 | 4376.07 1031.6 854 199 | 0.33 0.24 31.88 0.01
2 1.34e+06 4376.07 | 2329.53 0.0 447 0 | 0.32 0.24 31.45 0.01
2 1.34e+06 4376.07 | 2766.31 1240.2 565 254 | 0.32 0.24 32.76 0.01
2 1.35e+06 4376.07 | 3559.24 0.0 672 0 | 0.32 0.24 32.08 0.01
2 1.35e+06 4376.07 | 2982.04 1761.5 557 330 | 0.31 0.24 31.67 0.01
2 1.36e+06 4376.07 | 1431.25 0.0 282 0 | 0.32 0.23 31.13 0.01
2 1.36e+06 4376.07 | 1818.30 0.0 373 0 | 0.32 0.24 30.68 0.01
2 1.37e+06 4376.07 | 911.64 0.0 167 0 | 0.33 0.24 31.94 0.01
2 1.37e+06 4376.07 | 2429.27 0.0 442 0 | 0.32 0.24 31.20 0.01
2 1.38e+06 4376.07 | 1491.57 0.0 294 0 | 0.33 0.23 31.37 0.01
2 1.38e+06 4376.07 | 1535.84 0.0 294 0 | 0.33 0.22 32.09 0.01
2 1.39e+06 4376.07 | 1724.81 0.0 331 0 | 0.33 0.24 31.07 0.01
2 1.39e+06 4376.07 | 1426.36 0.0 273 0 | 0.33 0.23 32.00 0.01
2 1.40e+06 4376.07 | 2066.45 1369.6 401 264 | 0.33 0.23 33.17 0.01
2 1.40e+06 4376.07 | 1078.23 0.0 210 0 | 0.33 0.23 31.05 0.01
2 1.41e+06 4376.07 | 1217.95 0.0 256 0 | 0.33 0.23 32.79 0.01
2 1.41e+06 4376.07 | 1394.94 0.0 270 0 | 0.33 0.23 33.30 0.01
2 1.42e+06 4376.07 | 3662.75 0.0 688 0 | 0.33 0.23 34.01 0.01
2 1.42e+06 4376.07 | 3106.36 0.0 595 0 | 0.32 0.23 32.38 0.01
2 1.43e+06 4376.07 | 3703.49 0.0 705 0 | 0.33 0.23 33.98 0.01
2 1.43e+06 4376.07 | 1284.99 0.0 240 0 | 0.33 0.22 33.41 0.01
2 1.44e+06 4376.07 | 2499.82 0.0 479 0 | 0.33 0.23 31.52 0.01
2 1.44e+06 4376.07 | 4095.95 1608.4 780 308 | 0.33 0.22 31.57 0.01
2 1.45e+06 4376.07 | 1376.74 0.0 268 0 | 0.33 0.22 34.45 0.01
2 1.45e+06 4376.07 | 1529.86 0.0 293 0 | 0.33 0.23 33.78 0.01
2 1.46e+06 4376.07 | 2346.18 0.0 472 0 | 0.33 0.23 33.08 0.01
2 1.46e+06 4376.07 | 1454.02 0.0 278 0 | 0.33 0.22 31.71 0.01
2 1.47e+06 4376.07 | 4071.25 0.0 775 0 | 0.32 0.22 32.64 0.01
2 1.47e+06 4376.07 | 4041.26 1121.8 774 226 | 0.33 0.23 32.98 0.01
2 1.48e+06 4376.07 | 2339.81 0.0 470 0 | 0.33 0.23 34.03 0.01
2 1.48e+06 4376.07 | 3188.20 1323.7 610 249 | 0.33 0.22 31.73 0.01
2 1.49e+06 4376.07 | 1301.07 0.0 270 0 | 0.33 0.22 33.16 0.01
2 1.49e+06 4376.07 | 2600.90 1531.0 535 298 | 0.33 0.22 32.24 0.01
2 1.50e+06 4376.07 | 2169.64 0.0 433 0 | 0.32 0.22 32.96 0.01
2 1.51e+06 4376.07 | 1137.47 0.0 221 0 | 0.33 0.22 34.14 0.01
2 1.51e+06 4376.07 | 3703.59 1616.3 704 305 | 0.33 0.22 32.40 0.01
2 1.52e+06 4376.07 | 2139.60 0.0 406 0 | 0.33 0.21 32.47 0.01
2 1.52e+06 4376.07 | 4352.19 1187.4 811 229 | 0.34 0.22 33.02 0.01
2 1.53e+06 4376.07 | 2650.12 1653.3 486 297 | 0.33 0.22 33.92 0.01
2 1.53e+06 4376.07 | 1533.19 0.0 303 0 | 0.34 0.21 31.45 0.01
2 1.54e+06 4376.07 | 780.99 0.0 146 0 | 0.33 0.21 32.48 0.01
2 1.54e+06 4376.07 | 2626.05 0.0 509 0 | 0.33 0.21 33.91 0.01
2 1.55e+06 4376.07 | 4370.40 0.0 823 0 | 0.33 0.21 31.92 0.01
2 1.55e+06 4376.07 | 1506.31 0.0 297 0 | 0.33 0.22 33.49 0.01
2 1.56e+06 4376.07 | 2899.16 1496.5 554 282 | 0.33 0.21 32.71 0.01
2 1.56e+06 4376.07 | 1198.79 0.0 236 0 | 0.34 0.20 34.19 0.01
2 1.57e+06 4376.07 | 4314.28 1905.6 795 350 | 0.33 0.21 32.53 0.01
2 1.57e+06 4376.07 | 932.14 0.0 185 0 | 0.33 0.20 32.61 0.01
2 1.58e+06 4376.07 | 3710.02 0.0 680 0 | 0.33 0.21 33.56 0.01
2 1.58e+06 4376.07 | 1788.02 0.0 334 0 | 0.33 0.20 32.80 0.01
2 1.59e+06 4376.07 | 2178.98 0.0 405 0 | 0.33 0.20 35.01 0.01
2 1.59e+06 4661.43 |
2 1.59e+06 4661.43 | 4661.43 1205.4 870 225 | 0.33 0.21 34.16 0.01
2 1.60e+06 4661.43 | 4636.75 1363.6 856 249 | 0.34 0.20 32.75 0.01
2 1.60e+06 4661.43 | 3285.64 0.0 641 0 | 0.34 0.20 34.36 0.01
2 1.61e+06 4661.43 | 3996.92 0.0 746 0 | 0.33 0.20 32.96 0.01
2 1.61e+06 4808.85 |
2 1.61e+06 4808.85 | 4808.85 858.2 905 165 | 0.32 0.20 32.36 0.01
2 1.62e+06 4808.85 | 3711.65 1420.6 712 269 | 0.33 0.20 33.59 0.01
2 1.62e+06 4808.85 | 2343.89 0.0 433 0 | 0.32 0.20 33.83 0.01
2 1.63e+06 4808.85 | 3650.32 1767.0 675 326 | 0.33 0.19 33.05 0.01
2 1.64e+06 4808.85 | 1539.43 0.0 279 0 | 0.33 0.19 34.10 0.01
2 1.64e+06 4808.85 | 3677.19 1948.3 664 352 | 0.34 0.19 34.59 0.01
2 1.65e+06 4808.85 | 2687.31 0.0 496 0 | 0.33 0.20 33.47 0.01
2 1.65e+06 4808.85 | 1542.33 0.0 290 0 | 0.33 0.19 33.24 0.01
2 1.66e+06 4808.85 | 867.88 0.0 173 0 | 0.34 0.19 34.27 0.01
2 1.66e+06 4808.85 | 3085.34 1711.3 579 322 | 0.34 0.20 33.70 0.01
2 1.67e+06 4808.85 | 1687.58 0.0 323 0 | 0.33 0.20 34.93 0.01
2 1.67e+06 4808.85 | 4066.38 1268.1 742 228 | 0.34 0.19 32.41 0.01
2 1.68e+06 4808.85 | 452.65 0.0 91 0 | 0.33 0.20 33.70 0.01
2 1.68e+06 4808.85 | 3018.52 0.0 558 0 | 0.34 0.21 34.58 0.01
2 1.69e+06 4808.85 | 430.01 0.0 102 0 | 0.33 0.35 38.89 0.02
2 1.69e+06 4808.85 | 472.74 0.0 109 0 | 0.33 0.40 44.93 0.03
2 1.70e+06 4808.85 | 628.25 0.0 136 0 | 0.31 0.32 44.62 0.02
2 1.70e+06 4808.85 | 812.73 0.0 167 0 | 0.28 0.27 42.12 0.01
2 1.70e+06 4808.85 | 1707.97 0.0 327 0 | 0.31 0.24 39.53 0.01
2 1.71e+06 4808.85 | 1819.14 0.0 339 0 | 0.32 0.23 36.88 0.01
2 1.72e+06 4808.85 | 2053.70 0.0 388 0 | 0.33 0.21 35.72 0.01
2 1.72e+06 4808.85 | 2262.07 0.0 419 0 | 0.33 0.21 33.69 0.01
2 1.72e+06 4808.85 | 787.00 0.0 153 0 | 0.33 0.20 35.14 0.01
2 1.73e+06 4808.85 | 1620.02 0.0 309 0 | 0.34 0.20 33.92 0.01
2 1.74e+06 4808.85 | 2368.23 0.0 447 0 | 0.33 0.20 34.85 0.01
2 1.74e+06 4846.42 |
2 1.74e+06 4846.42 | 4846.42 581.3 906 110 | 0.33 0.19 34.40 0.01
2 1.75e+06 4846.42 | 752.17 0.0 150 0 | 0.34 0.19 33.20 0.01
2 1.75e+06 4846.42 | 3085.69 2158.1 576 395 | 0.34 0.19 34.28 0.01
2 1.76e+06 4846.42 | 381.14 0.0 71 0 | 0.34 0.20 33.92 0.01
2 1.76e+06 4846.42 | 3684.18 0.0 693 0 | 0.34 0.19 34.47 0.01
2 1.77e+06 5436.18 |
2 1.77e+06 5436.18 | 5436.18 35.3 1000 0 | 0.33 0.19 34.15 0.01
2 1.77e+06 5436.18 | 5327.19 0.0 1000 0 | 0.34 0.19 33.98 0.01
2 1.78e+06 5436.18 | 4729.78 0.0 857 0 | 0.34 0.20 34.32 0.01
2 1.78e+06 5578.46 |
2 1.78e+06 5578.46 | 5578.46 86.6 1000 0 | 0.34 0.19 34.41 0.01
2 1.79e+06 5578.46 | 2561.99 0.0 473 0 | 0.34 0.19 34.08 0.01
2 1.79e+06 5578.46 | 5432.93 0.0 1000 0 | 0.35 0.19 34.19 0.01
2 1.80e+06 5578.46 | 1247.43 0.0 232 0 | 0.34 0.19 34.27 0.01
2 1.80e+06 5578.46 | 3227.15 0.0 598 0 | 0.35 0.18 35.06 0.01
2 1.81e+06 5578.46 | 3294.27 0.0 610 0 | 0.35 0.18 34.52 0.01
2 1.81e+06 5578.46 | 5424.16 0.0 1000 0 | 0.33 0.18 34.81 0.01
2 1.82e+06 5578.46 | 5410.13 0.0 1000 0 | 0.34 0.18 34.04 0.01
2 1.82e+06 5578.46 | 2406.91 0.0 454 0 | 0.34 0.18 35.67 0.01
2 1.83e+06 5578.46 | 5494.68 0.0 1000 0 | 0.34 0.18 35.15 0.01
2 1.83e+06 5578.46 | 2468.08 0.0 535 0 | 0.34 0.19 34.65 0.01
2 1.84e+06 5578.46 | 3286.31 0.0 633 0 | 0.34 0.19 34.83 0.01
2 1.84e+06 5578.46 | 5295.30 0.0 1000 0 | 0.33 0.19 33.75 0.01
2 1.85e+06 5578.46 | 1098.72 0.0 216 0 | 0.34 0.18 35.00 0.01
2 1.85e+06 5578.46 | 2036.09 0.0 381 0 | 0.34 0.18 34.08 0.01
2 1.86e+06 5578.46 | 704.63 0.0 135 0 | 0.34 0.18 32.72 0.01
2 1.86e+06 5578.46 | 5437.36 0.0 1000 0 | 0.33 0.18 35.17 0.01
2 1.87e+06 5578.46 | 1882.41 0.0 352 0 | 0.34 0.18 33.29 0.01
2 1.87e+06 5578.46 | 2585.14 0.0 453 0 | 0.34 0.18 34.44 0.01
2 1.88e+06 5578.46 | 3676.13 0.0 674 0 | 0.34 0.18 33.99 0.01
2 1.88e+06 5578.46 | 2395.74 0.0 438 0 | 0.34 0.18 34.04 0.01
2 1.89e+06 5578.46 | 1226.04 0.0 241 0 | 0.34 0.17 34.84 0.01
2 1.89e+06 5578.46 | 5255.36 0.0 1000 0 | 0.34 0.18 33.56 0.01
2 1.90e+06 5578.46 | 5571.49 0.0 1000 0 | 0.35 0.17 34.05 0.01
2 1.90e+06 5578.46 | 3593.36 0.0 716 0 | 0.34 0.18 33.59 0.01
2 1.91e+06 5578.46 | 5293.41 0.0 1000 0 | 0.35 0.18 34.38 0.01
2 1.91e+06 5578.46 | 4169.86 0.0 795 0 | 0.33 0.18 34.22 0.01
2 1.92e+06 5578.46 | 3631.33 0.0 647 0 | 0.34 0.17 34.96 0.01
2 1.92e+06 5578.46 | 5460.01 0.0 1000 0 | 0.35 0.17 34.32 0.01
2 1.93e+06 5578.46 | 5410.56 0.0 1000 0 | 0.35 0.17 33.34 0.01
2 1.93e+06 5578.46 | 5460.13 0.0 1000 0 | 0.34 0.17 33.90 0.01
2 1.94e+06 5578.46 | 2817.41 0.0 537 0 | 0.34 0.18 34.36 0.01
2 1.94e+06 5578.46 | 1858.92 0.0 339 0 | 0.35 0.17 34.96 0.01
2 1.95e+06 5578.46 | 2207.20 0.0 418 0 | 0.34 0.17 35.02 0.01
2 1.95e+06 5578.46 | 2759.04 0.0 523 0 | 0.35 0.17 35.04 0.01
2 1.96e+06 5578.46 | 5266.78 0.0 940 0 | 0.35 0.17 33.96 0.01
2 1.96e+06 5578.46 | 1092.09 0.0 203 0 | 0.34 0.18 33.64 0.01
2 1.97e+06 5578.46 | 2487.55 0.0 446 0 | 0.34 0.26 37.81 0.02
2 1.97e+06 5578.46 | 2313.96 0.0 420 0 | 0.34 0.23 40.44 0.01
2 1.98e+06 5606.16 |
2 1.98e+06 5606.16 | 5606.16 51.8 1000 0 | 0.32 0.21 38.85 0.01
2 1.98e+06 5606.16 | 3925.41 0.0 696 0 | 0.34 0.19 37.93 0.01
2 1.99e+06 5606.16 | 5475.95 0.0 1000 0 | 0.35 0.18 35.79 0.01
2 1.99e+06 5606.16 | 2794.34 0.0 516 0 | 0.36 0.19 34.80 0.01
2 2.00e+06 5606.16 | 5602.57 0.0 1000 0 | 0.35 0.17 34.41 0.01
2 2.00e+06 5606.16 | 5382.77 326.0 968 56 | 0.35 0.18 35.26 0.01
| UsedTime: 45183 | SavedDir: ./Humanoid-v3_ReliableSAC_2
| Learner: Save in ./Humanoid-v3_ReliableSAC_2
"""
else:
raise ValueError('env_name:', env_name)
args.learner_gpus = gpu_id
args.random_seed += gpu_id
if_check = 0
if if_check:
train_and_evaluate(args)
else:
train_and_evaluate_mp(args)
if __name__ == '__main__':
GPU_ID = int(sys.argv[1]) if len(sys.argv) > 1 else 0 # >=0 means GPU ID, -1 means CPU
DRL_ID = int(sys.argv[2]) if len(sys.argv) > 2 else 3
ENV_ID = int(sys.argv[3]) if len(sys.argv) > 3 else 1
demo_ddpg_td3_sac(GPU_ID, DRL_ID, ENV_ID)
=======
import sys
import gym
from elegantrl.train.run import train_and_evaluate, train_and_evaluate_mp
from elegantrl.train.config import Arguments
from elegantrl.agents.AgentDDPG import AgentDDPG, AgentDDPGHterm
from elegantrl.agents.AgentTD3 import AgentTD3
from elegantrl.agents.AgentSAC import AgentSAC, AgentReSAC, AgentReSACHterm, AgentReSACHtermK
def demo_ddpg_td3_sac(gpu_id, drl_id, env_id): # 2022.02.02
env_name = ['Pendulum-v0',
'Pendulum-v1',
'LunarLanderContinuous-v2',
'BipedalWalker-v3',
'Hopper-v2',
'HalfCheetah-v2'
'Humanoid-v3', ][env_id]
agent = [AgentDDPG, AgentTD3, AgentSAC, AgentReSAC][drl_id]
if env_name in {'Pendulum-v0', 'Pendulum-v1'}:
from elegantrl.envs.CustomGymEnv import PendulumEnv
env = PendulumEnv(env_name, target_return=-500)
"""
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
2 1.60e+03-1147.49 |-1147.49 179.2 200 0 | -2.61 0.90 0.55 1.00
2 5.84e+04 -121.61 | -121.61 59.0 200 0 | -0.81 0.33 -40.64 0.79
| UsedTime: 132 |
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
1 1.60e+03-1267.96 |-1267.96 329.7 200 0 | -2.67 0.88 0.56 1.00
1 8.48e+04 -171.79 | -182.24 63.3 200 0 | -0.30 0.32 -30.75 0.64
1 1.19e+05 -171.79 | -178.25 116.8 200 0 | -0.31 0.16 -22.52 0.43
1 1.34e+05 -164.56 | -164.56 99.1 200 0 | -0.31 0.15 -18.09 0.35
1 1.47e+05 -135.20 | -135.20 92.1 200 0 | -0.31 0.14 -15.65 0.29
| UsedTime: 783 |
"""
args = Arguments(agent, env)
args.reward_scale = 2 ** -1 # RewardRange: -1800 < -200 < -50 < 0
args.gamma = 0.97
args.target_step = args.max_step * 2
args.eval_times = 2 ** 3
elif env_name == 'LunarLanderContinuous-v2':
"""
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
2 4.25e+03 -143.93 | -143.93 29.6 69 12 | -2.47 1.06 0.13 0.15
2 1.05e+05 170.35 | 170.35 57.9 645 177 | 0.06 1.59 15.93 0.20
2 1.59e+05 170.35 | 80.46 125.0 775 285 | 0.07 1.14 29.92 0.29
2 1.95e+05 221.39 | 221.39 19.7 449 127 | 0.12 1.09 32.16 0.40
| UsedTime: 421 |
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
1 4.26e+03 -139.77 | -139.77 36.7 67 12 | -2.16 11.20 0.12 0.15
1 1.11e+05 -105.09 | -105.09 84.3 821 244 | -0.14 27.60 1.04 0.21
1 2.03e+05 -15.21 | -15.21 22.7 1000 0 | -0.01 17.96 36.95 0.45
1 3.87e+05 59.39 | 54.09 160.7 756 223 | 0.00 16.57 88.99 0.73
1 4.03e+05 59.39 | 56.16 103.5 908 120 | 0.06 16.47 84.27 0.71
1 5.10e+05 186.59 | 186.59 103.6 547 257 | -0.02 12.72 67.97 0.57
1 5.89e+05 226.93 | 226.93 20.0 486 154 | 0.13 9.27 68.29 0.51
| UsedTime: 3407 |
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
1 4.15e+03 -169.01 | -169.01 87.9 110 59 | -2.18 11.86 0.10 0.15
1 1.09e+05 -84.47 | -84.47 80.1 465 293 | -0.30 30.64 -6.29 0.20
1 4.25e+05 -8.33 | -8.33 48.4 994 26 | 0.07 13.51 76.99 0.62
1 4.39e+05 87.29 | 87.29 86.9 892 141 | 0.04 12.76 70.37 0.61
1 5.57e+05 159.17 | 159.17 65.7 721 159 | 0.10 10.31 59.90 0.51
1 5.87e+05 190.09 | 190.09 71.7 577 175 | 0.09 9.45 61.74 0.48
1 6.20e+05 206.74 | 206.74 29.1 497 108 | 0.09 9.21 62.06 0.47
| UsedTime: 4433 |
"""
env_func = gym.make
env_args = {'env_num': 1,
'env_name': 'LunarLanderContinuous-v2',
'max_step': 1000,
'state_dim': 8,
'action_dim': 2,
'if_discrete': False,
'target_return': 200,
'id': 'LunarLanderContinuous-v2'}
args = Arguments(agent, env_func=env_func, env_args=env_args)
args.target_step = args.max_step
args.gamma = 0.99
args.eval_times = 2 ** 5
elif env_name == 'BipedalWalker-v3':
env_func = gym.make
env_args = {'env_num': 1,
'env_name': 'BipedalWalker-v3',
'max_step': 1600,
'state_dim': 24,
'action_dim': 4,
'if_discrete': False,
'target_return': 300,
'id': 'BipedalWalker-v3', }
args = Arguments(agent, env_func=env_func, env_args=env_args)
args.target_step = args.max_step
args.gamma = 0.98
args.eval_times = 2 ** 4
"""
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
3 7.51e+03 -111.59 | -111.59 0.2 97 7 | -0.18 4.23 -0.03 0.02
3 1.48e+05 -110.19 | -110.19 1.6 84 30 | -0.59 2.46 3.18 0.03
3 5.02e+05 -31.84 | -102.27 54.0 1359 335 | -0.06 0.85 2.84 0.04
3 1.00e+06 -7.94 | -7.94 73.2 411 276 | -0.17 0.72 1.96 0.03
3 1.04e+06 131.50 | 131.50 168.3 990 627 | 0.06 0.46 1.69 0.04
3 1.11e+06 214.12 | 214.12 146.6 1029 405 | 0.09 0.50 1.63 0.04
3 1.20e+06 308.34 | 308.34 0.7 1106 20 | 0.29 0.72 4.56 0.05
| UsedTime: 8611 |
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
3 6.75e+03 -92.44 | -92.44 0.2 120 3 | -0.18 1.94 -0.00 0.02
3 3.95e+05 -37.16 | -37.16 9.2 1600 0 | -0.06 1.90 4.20 0.07
3 6.79e+05 -23.32 | -42.54 90.0 1197 599 | -0.02 0.91 1.57 0.04
3 6.93e+05 46.92 | 46.92 96.9 808 395 | -0.04 0.57 1.34 0.04
3 8.38e+05 118.86 | 118.86 154.5 999 538 | 0.14 1.44 0.75 0.05
3 1.00e+06 225.56 | 225.56 124.1 1207 382 | 0.13 0.72 4.75 0.06
3 1.02e+06 283.37 | 283.37 86.3 1259 245 | 0.14 0.80 3.96 0.06
3 1.19e+06 313.36 | 313.36 0.9 1097 20 | 0.21 0.78 6.80 0.06
| UsedTime: 9354 | SavedDir: ./BipedalWalker-v3_ModSAC_3
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
3 6.55e+03 -109.86 | -109.86 4.5 156 30 | -0.06 0.71 -0.01 0.02
3 1.24e+05 -88.28 | -88.28 26.2 475 650 | -0.15 0.15 0.04 0.02
3 3.01e+05 -47.89 | -56.76 21.7 1341 540 | -0.03 0.19 -2.76 0.05
3 3.82e+05 80.89 | 53.79 140.1 983 596 | -0.01 0.18 0.46 0.05
3 4.35e+05 137.70 | 28.54 104.7 936 581 | -0.01 0.21 0.63 0.06
3 4.80e+05 158.71 | 25.54 114.7 524 338 | 0.18 0.17 6.17 0.06
3 5.31e+05 205.81 | 203.27 143.9 1048 388 | 0.14 0.15 4.00 0.06
3 6.93e+05 254.40 | 252.74 121.1 992 280 | 0.21 0.12 7.34 0.06
3 7.11e+05 304.79 | 304.79 73.4 1015 151 | 0.21 0.12 5.69 0.06
| UsedTime: 3215 |
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
1 7.08e+03 -106.48 | -106.48 6.0 170 17 | -0.14 0.70 0.03 0.02
1 2.38e+05 -89.62 | -89.62 29.8 775 728 | -0.30 0.31 -13.44 0.04
1 4.12e+05 -33.40 | -34.50 27.6 1342 516 | -0.01 0.20 1.34 0.06
1 5.05e+05 2.54 | -47.29 20.9 1342 516 | 0.02 0.17 0.24 0.05
1 5.43e+05 52.93 | 52.93 107.6 1084 540 | -0.21 0.15 0.32 0.05
1 5.80e+05 138.30 | 136.60 77.6 1460 176 | 0.10 0.16 2.14 0.05
1 6.16e+05 188.98 | 171.72 99.2 1386 305 | 0.12 0.16 -0.40 0.05
1 7.06e+05 250.72 | 231.97 142.9 1247 448 | 0.12 0.13 2.81 0.05
1 8.06e+05 287.28 | -68.06 5.9 211 19 | -0.08 0.12 7.83 0.06
1 8.56e+05 291.10 | 286.19 56.0 1181 63 | 0.17 0.13 6.37 0.06
1 8.83e+05 314.54 | 314.54 1.0 1252 19 | 0.11 0.12 7.23 0.06
| UsedTime: 5008 |
"""
"""
| Arguments Remove cwd: ./BipedalWalker-v3_ReliableSAC_2
################################################################################
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
2 7.27e+03 -117.98 |
2 7.27e+03 -117.98 | -117.98 2.5 43 6 | -0.09 0.62 0.03 0.02
2 1.03e+05 -102.54 |
2 1.03e+05 -102.54 | -102.54 2.3 71 6 | -0.97 0.11 -1.68 0.02
2 1.51e+05 -46.60 |
2 1.51e+05 -46.60 | -46.60 8.4 1600 0 | -0.05 0.62 -8.64 0.07
2 1.89e+05 -41.07 |
2 1.89e+05 -41.07 | -41.07 0.0 1600 0 | -0.08 0.36 0.74 0.05
2 2.20e+05 -30.91 |
2 2.20e+05 -30.91 | -30.91 1.7 1600 0 | -0.11 0.23 0.60 0.04
2 2.48e+05 -30.91 | -59.86 16.5 1600 0 | -0.04 0.17 0.45 0.03
2 2.73e+05 -30.91 | -66.04 29.2 713 724 | -0.03 0.12 -0.53 0.03
2 2.97e+05 -30.91 | -90.05 35.6 783 485 | -0.10 0.16 -1.07 0.03
2 3.22e+05 -30.91 | -38.24 41.4 507 251 | -0.18 0.15 -3.86 0.04
2 3.48e+05 235.88 |
2 3.48e+05 235.88 | 235.88 124.6 1210 376 | -0.06 0.17 -2.53 0.04
2 3.70e+05 235.88 | -79.56 3.8 138 12 | 0.08 0.19 0.85 0.05
2 3.88e+05 235.88 | 171.11 174.6 933 517 | -0.14 0.21 2.51 0.05
2 4.08e+05 322.22 |
2 4.08e+05 322.22 | 322.22 0.6 1291 12 | -0.39 0.20 0.15 0.06
| UsedTime: 1686 | SavedDir: ./BipedalWalker-v3_ReliableSAC_2
| Learner: Save in ./BipedalWalker-v3_ReliableSAC_2
| LearnerPipe.run: ReplayBuffer saving in ./BipedalWalker-v3_ReliableSAC_2
"""
elif env_name == 'Hopper-v2':
env_func = gym.make
env_args = {
'env_num': 1,
'env_name': 'Hopper-v2',
'max_step': 1000,
'state_dim': 11,
'action_dim': 3,
'if_discrete': False,
'target_return': 3800.,
}
args = Arguments(agent, env_func=env_func, env_args=env_args)
args.eval_times = 2 ** 2
args.reward_scale = 2 ** -4
args.target_step = args.max_step * 2
args.worker_num = 2
args.net_dim = 2 ** 8
args.num_layer = 3
args.batch_size = int(args.net_dim * 2)
args.repeat_times = 2 ** 4
args.gamma = 0.993 # todo
args.if_allow_break = False
args.break_step = int(8e6)
"""
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
5 1.61e+04 131.99 | 131.99 3.6 81 2 | 0.03 0.09 0.03 -0.54
5 2.20e+05 391.44 | 391.44 0.3 158 0 | 0.08 0.01 -0.06 -0.75
5 4.25e+05 860.96 | 860.96 11.9 280 5 | 0.09 0.11 0.12 -0.84
5 6.27e+05 3001.43 | 3001.43 7.9 1000 0 | 0.10 0.78 -0.01 -0.85
5 1.64e+06 3203.09 | 3103.14 0.0 1000 0 | 0.10 1.82 -0.06 -0.76
5 2.86e+06 3256.43 | 3152.72 0.0 1000 0 | 0.10 0.75 0.01 -0.67
5 3.88e+06 3256.43 | 1549.69 0.0 512 0 | 0.10 0.86 0.00 -0.71
| UsedTime: 2565 |
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
2 1.60e+04 328.68 | 328.68 6.2 262 6 | 0.02 0.01 -0.02 -0.54
2 2.16e+05 2460.57 | 2460.57 14.3 1000 0 | 0.09 0.86 0.20 -0.74
2 6.22e+05 2789.97 | 2788.28 30.9 1000 0 | 0.10 0.40 -0.11 -1.04
2 1.23e+06 3263.16 | 3216.96 0.0 1000 0 | 0.10 1.06 0.12 -1.05
2 2.46e+06 3378.50 | 3364.02 0.0 1000 0 | 0.11 0.87 0.02 -0.92
2 3.90e+06 3397.88 | 3302.80 0.0 1000 0 | 0.11 0.46 0.01 -0.93
| UsedTime: 2557 |
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
4 2.41e+04 222.39 | 222.39 1.5 120 1 | 0.94 8.45 0.05 -0.55
4 5.34e+05 344.58 | 344.58 0.4 142 0 | 2.41 1.91 0.02 -0.94
4 8.74e+05 540.69 | 540.69 20.1 180 4 | 2.96 5.82 0.00 -1.10
4 1.39e+06 989.51 | 989.51 2.2 308 2 | 3.20 16.75 0.07 -1.08
4 1.73e+06 3161.60 | 3149.35 0.0 1000 0 | 3.26 43.84 -0.02 -1.08
4 2.06e+06 3367.27 | 3105.77 0.0 1000 0 | 3.32 44.14 0.00 -1.13
4 3.92e+06 3604.42 | 3565.39 0.0 1000 0 | 3.44 30.54 0.04 -1.04
4 5.76e+06 3717.06 | 3607.94 0.0 1000 0 | 3.40 51.92 0.07 -0.95
4 6.26e+06 3840.95 | 3409.25 0.0 1000 0 | 3.32 66.48 -0.02 -0.94
| UsedTime: 6251 |
| Arguments Remove cwd: ./Hopper-v2_PPO_4
################################################################################
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
4 4.00e+03 80.27 |
4 4.00e+03 80.27 | 80.27 0.7 50 0 | 0.07 0.92 0.07 0.00
4 1.46e+05 408.17 |
4 1.46e+05 408.17 | 408.17 1.5 145 1 | 0.17 0.03 0.13 0.00
4 2.90e+05 1856.89 |
4 2.90e+05 1856.89 | 1856.89 589.7 692 219 | 0.19 1.01 -0.05 0.00
4 4.34e+05 1856.89 | 1768.29 0.0 544 0 | 0.20 0.19 0.08 0.00
4 5.81e+05 2750.76 |
4 5.81e+05 2750.76 | 2750.76 15.5 1000 0 | 0.18 2.98 0.10 0.00
4 7.24e+05 3036.12 |
4 7.24e+05 3036.12 | 3036.12 2.2 1000 0 | 0.19 2.75 0.05 0.00
4 8.70e+05 3036.12 | 2790.94 0.0 1000 0 | 0.19 2.01 0.05 0.00
4 1.01e+06 3220.42 |
4 1.01e+06 3220.42 | 3220.42 2.7 1000 0 | 0.20 1.70 0.05 0.00
4 1.15e+06 3220.42 | 3059.18 312.9 939 105 | 0.20 1.30 0.05 0.00
4 1.30e+06 3220.42 | 2892.04 0.0 1000 0 | 0.19 2.23 -0.06 0.00
4 1.44e+06 3220.42 | 3153.15 0.0 1000 0 | 0.20 1.04 0.05 0.00
4 1.59e+06 3220.42 | 3083.19 0.0 1000 0 | 0.20 1.40 0.05 0.00
4 1.73e+06 3220.42 | 2999.16 0.0 1000 0 | 0.19 2.53 0.03 0.00
4 1.88e+06 3220.42 | 3219.83 31.4 1000 0 | 0.20 1.11 0.04 0.00
4 2.01e+06 3220.42 | 1465.88 0.0 499 0 | 0.19 2.71 0.22 0.00
4 2.16e+06 3220.42 | 3157.03 0.0 1000 0 | 0.21 0.62 0.08 0.00
4 2.30e+06 3220.42 | 1256.07 0.0 379 0 | 0.20 2.89 0.07 0.00
4 2.45e+06 3265.09 |
4 2.45e+06 3265.09 | 3265.09 14.0 1000 0 | 0.19 3.52 0.01 0.00
4 2.59e+06 3265.09 | 1562.53 0.0 498 0 | 0.18 2.96 0.08 0.00
4 2.73e+06 3265.09 | 3238.68 0.0 1000 0 | 0.20 1.73 0.07 0.00
4 2.87e+06 3265.09 | 3240.99 0.0 1000 0 | 0.20 3.32 -0.16 0.00
4 3.02e+06 3265.09 | 3141.53 0.0 1000 0 | 0.19 3.55 -0.04 0.00
4 3.16e+06 3265.09 | 3252.13 0.0 1000 0 | 0.21 1.44 -0.03 0.00
4 3.30e+06 3265.09 | 3164.95 0.0 1000 0 | 0.20 2.48 0.10 0.00
| UsedTime: 3049 | SavedDir: ./Hopper-v2_PPO_4
| Arguments Remove cwd: ./Hopper-v2_ReliableSAC_3
################################################################################
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
3 8.09e+03 32.31 |
3 8.09e+03 32.31 | 32.31 0.6 29 0 | 0.05 0.12 0.44 0.05
3 4.86e+04 282.45 |
3 4.86e+04 282.45 | 282.45 2.6 112 1 | 0.14 0.03 6.95 0.07
3 6.93e+04 282.45 | 82.75 0.0 56 0 | 0.16 0.54 31.61 0.28
3 9.00e+04 282.45 | 247.28 0.0 124 0 | 0.12 0.53 54.26 0.26
3 1.06e+05 306.45 |
3 1.06e+05 306.45 | 306.45 1.4 120 0 | 0.15 0.50 55.85 0.38
3 1.18e+05 406.01 |
3 1.18e+05 406.01 | 406.01 2.9 177 1 | 0.14 0.59 61.50 0.51
3 1.31e+05 450.03 |
3 1.31e+05 450.03 | 450.03 5.5 170 2 | 0.12 0.72 66.32 0.43
3 1.47e+05 450.03 | 155.34 0.0 88 0 | 0.13 0.90 87.74 0.47
3 1.64e+05 450.03 | 154.29 0.0 85 0 | 0.15 0.84 83.98 0.59
3 1.76e+05 450.03 | 276.25 0.0 132 0 | 0.13 0.91 91.40 0.46
3 1.89e+05 1351.93 |
3 1.89e+05 1351.93 | 1351.93 360.9 686 202 | 0.14 0.81 87.22 0.47
3 2.01e+05 1351.93 | 278.82 0.0 117 0 | 0.07 1.26 105.55 0.74
3 2.14e+05 1351.93 | 891.33 0.0 659 0 | 0.14 1.23 124.07 0.52
3 2.27e+05 1351.93 | 645.46 0.0 252 0 | 0.10 1.24 103.56 0.56
3 2.39e+05 1351.93 | 231.23 0.0 109 0 | 0.11 2.02 151.70 0.45
3 2.52e+05 1351.93 | 603.45 0.0 239 0 | 0.15 1.75 134.23 0.75
3 2.64e+05 1351.93 | 1030.42 0.0 1000 0 | 0.12 1.13 107.67 0.67
3 2.73e+05 1351.93 | 1047.41 0.0 1000 0 | 0.07 0.74 93.73 0.50
3 2.82e+05 1351.93 | 1111.93 0.0 1000 0 | 0.08 0.62 81.83 0.38
3 2.91e+05 1351.93 | 1039.49 0.0 1000 0 | 0.09 0.52 66.07 0.34
3 3.00e+05 1490.20 |
3 3.00e+05 1490.20 | 1490.20 0.7 1000 0 | 0.08 0.34 55.97 0.23
3 3.09e+05 1526.75 |
3 3.09e+05 1526.75 | 1526.75 36.5 1000 0 | 0.10 0.21 41.72 0.17
3 3.18e+05 1526.75 | 240.00 0.0 107 0 | 0.13 1.18 83.82 0.59
3 3.27e+05 1526.75 | 670.09 0.0 268 0 | 0.12 0.81 107.00 0.44
3 3.35e+05 1526.75 | 712.00 0.0 442 0 | 0.16 0.71 81.89 0.33
3 3.43e+05 1526.75 | 544.57 0.0 276 0 | 0.13 0.43 60.21 0.18
3 3.52e+05 1526.75 | 379.76 0.0 136 0 | 0.16 0.59 66.49 0.25
3 3.61e+05 1526.75 | 1025.86 0.0 1000 0 | 0.17 0.77 98.66 0.46
3 3.69e+05 1526.75 | 1039.17 0.0 1000 0 | 0.06 0.66 88.29 0.39
3 3.77e+05 1782.66 |
3 3.77e+05 1782.66 | 1782.66 2.0 1000 0 | 0.10 0.40 65.66 0.25
3 3.86e+05 1782.66 | 1031.96 0.0 1000 0 | 0.13 0.23 45.79 0.16
3 3.94e+05 2410.15 |
3 3.94e+05 2410.15 | 2410.15 4.9 1000 0 | 0.12 0.14 32.34 0.09
3 4.04e+05 2556.36 |
3 4.04e+05 2556.36 | 2556.36 3.4 1000 0 | 0.15 0.09 24.99 0.08
3 4.13e+05 2575.00 |
3 4.13e+05 2575.00 | 2575.00 6.8 1000 0 | 0.17 0.07 22.31 0.07
3 4.21e+05 2575.00 | 1018.50 0.0 1000 0 | 0.16 0.09 29.45 0.11
3 4.27e+05 2575.00 | 1001.91 0.0 1000 0 | 0.12 0.08 27.80 0.11
3 4.31e+05 2575.00 | 863.46 0.0 1000 0 | 0.07 0.08 27.16 0.10
3 4.35e+05 2575.00 | 1058.56 0.0 1000 0 | 0.06 0.10 32.01 0.12
3 4.39e+05 2575.00 | 1038.11 0.0 1000 0 | 0.06 0.09 28.62 0.10
3 4.44e+05 2575.00 | 2124.24 0.0 1000 0 | 0.09 0.07 26.10 0.07
3 4.48e+05 2761.82 |
3 4.48e+05 2761.82 | 2761.82 0.8 1000 0 | 0.07 0.06 24.11 0.07
3 4.52e+05 2761.82 | 2732.77 0.0 1000 0 | 0.14 0.05 23.25 0.06
3 4.56e+05 2822.69 |
3 4.56e+05 2822.69 | 2822.69 0.5 1000 0 | 0.17 0.05 22.39 0.06
3 4.60e+05 2994.40 |
3 4.60e+05 2994.40 | 2994.40 1.9 1000 0 | 0.17 0.04 22.00 0.06
3 4.64e+05 2994.40 | 2824.77 0.0 1000 0 | 0.18 0.05 21.46 0.06
3 4.68e+05 2994.40 | 2826.93 0.0 1000 0 | 0.19 0.04 21.57 0.07
3 4.73e+05 2994.40 | 2963.28 0.0 1000 0 | 0.19 0.04 21.16 0.06
3 4.77e+05 2994.40 | 2928.26 0.0 1000 0 | 0.18 0.04 21.61 0.06
3 4.82e+05 3005.36 |
3 4.82e+05 3005.36 | 3005.36 1.0 1000 0 | 0.19 0.04 21.32 0.06
3 4.86e+05 3141.08 |
3 4.86e+05 3141.08 | 3141.08 1.9 1000 0 | 0.18 0.04 21.49 0.05
3 4.90e+05 3141.08 | 3004.14 0.0 1000 0 | 0.19 0.04 21.65 0.06
3 4.94e+05 3141.08 | 3052.78 0.0 1000 0 | 0.19 0.04 21.54 0.06
3 4.98e+05 3141.08 | 3045.90 0.0 1000 0 | 0.19 0.04 22.11 0.06
3 5.02e+05 3228.76 |
3 5.02e+05 3228.76 | 3228.76 2.8 1000 0 | 0.19 0.04 21.98 0.06
3 5.06e+05 3228.76 | 3173.43 0.0 1000 0 | 0.19 0.04 21.85 0.06
3 5.10e+05 3228.76 | 3154.30 0.0 1000 0 | 0.19 0.04 22.53 0.06
3 5.14e+05 3228.76 | 3207.25 0.0 1000 0 | 0.19 0.04 22.33 0.06
3 5.18e+05 3228.76 | 3131.76 0.0 1000 0 | 0.20 0.04 22.29 0.06
3 5.22e+05 3278.78 |
3 5.22e+05 3278.78 | 3278.78 3.8 1000 0 | 0.20 0.03 22.38 0.06
3 5.27e+05 3278.78 | 3236.48 0.0 1000 0 | 0.19 0.04 22.67 0.05
3 5.31e+05 3278.78 | 3152.81 0.0 1000 0 | 0.20 0.03 22.13 0.05
3 5.35e+05 3278.78 | 3140.72 0.0 1000 0 | 0.20 0.04 21.65 0.05
3 5.39e+05 3278.78 | 3270.06 0.0 1000 0 | 0.20 0.03 22.16 0.05
3 5.43e+05 3278.78 | 3189.89 0.0 1000 0 | 0.20 0.03 22.27 0.05
3 5.48e+05 3278.78 | 3178.73 0.0 1000 0 | 0.20 0.03 22.80 0.05
3 5.52e+05 3278.78 | 3269.01 0.0 1000 0 | 0.20 0.03 22.18 0.05
3 5.56e+05 3318.49 |
3 5.56e+05 3318.49 | 3318.49 1.9 1000 0 | 0.20 0.03 22.41 0.05
3 5.61e+05 3346.12 |
3 5.61e+05 3346.12 | 3346.12 2.3 1000 0 | 0.20 0.03 21.79 0.05
3 5.65e+05 3346.12 | 3285.40 0.0 1000 0 | 0.20 0.03 22.62 0.05
3 5.69e+05 3346.12 | 3253.44 0.0 1000 0 | 0.21 0.03 22.43 0.05
3 5.73e+05 3346.12 | 3235.30 0.0 1000 0 | 0.20 0.03 22.33 0.05
3 5.78e+05 3346.12 | 3119.58 0.0 1000 0 | 0.21 0.04 22.57 0.05
3 5.83e+05 3346.12 | 3171.89 0.0 1000 0 | 0.20 0.04 22.48 0.05
3 5.87e+05 3346.12 | 3185.86 0.0 1000 0 | 0.19 0.03 23.00 0.05
3 5.91e+05 3346.12 | 3240.08 0.0 1000 0 | 0.20 0.03 23.02 0.05
3 5.95e+05 3346.12 | 3204.16 0.0 1000 0 | 0.20 0.03 22.30 0.05
3 5.99e+05 3346.12 | 3270.83 0.0 1000 0 | 0.20 0.03 22.61 0.05
3 6.04e+05 3346.12 | 3241.98 0.0 1000 0 | 0.20 0.03 22.94 0.05
3 6.08e+05 3346.12 | 3179.65 0.0 1000 0 | 0.20 0.03 22.36 0.05
3 6.13e+05 3346.12 | 3216.45 0.0 1000 0 | 0.21 0.03 22.43 0.05
3 6.17e+05 3346.12 | 3282.53 0.0 1000 0 | 0.20 0.03 22.51 0.05
3 6.21e+05 3346.12 | 3301.64 0.0 1000 0 | 0.20 0.03 22.65 0.05
3 6.26e+05 3346.12 | 3233.07 0.0 1000 0 | 0.21 0.03 22.66 0.05
3 6.31e+05 3346.12 | 3285.32 0.0 1000 0 | 0.21 0.03 22.35 0.05
3 6.35e+05 3346.12 | 3244.01 0.0 1000 0 | 0.20 0.03 22.82 0.05
3 6.39e+05 3346.12 | 3210.21 0.0 1000 0 | 0.21 0.03 22.64 0.05
3 6.45e+05 3346.12 | 3209.60 0.0 1000 0 | 0.21 0.03 22.88 0.05
3 6.50e+05 3346.12 | 3259.00 0.0 1000 0 | 0.21 0.03 22.76 0.05
3 6.54e+05 3346.12 | 3245.06 0.0 1000 0 | 0.20 0.04 23.39 0.05
3 6.59e+05 3346.12 | 598.90 0.0 212 0 | 0.20 0.05 25.07 0.07
3 6.64e+05 3346.12 | 730.34 0.0 221 0 | 0.21 0.05 26.25 0.07
3 6.68e+05 3346.12 | 3193.28 0.0 1000 0 | 0.20 0.06 26.30 0.07
3 6.73e+05 3346.12 | 3196.86 0.0 1000 0 | 0.21 0.04 25.20 0.05
3 6.77e+05 3346.12 | 3244.45 0.0 1000 0 | 0.20 0.04 23.90 0.05
3 6.83e+05 3346.12 | 3233.50 0.0 1000 0 | 0.21 0.04 23.41 0.05
3 6.88e+05 3346.12 | 3186.67 0.0 1000 0 | 0.21 0.04 23.17 0.05
3 6.92e+05 3346.12 | 3246.38 0.0 1000 0 | 0.22 0.04 23.16 0.05
3 6.97e+05 3346.12 | 3242.70 0.0 1000 0 | 0.21 0.03 22.85 0.05
3 7.02e+05 3346.12 | 3264.54 0.0 1000 0 | 0.21 0.03 22.97 0.05
3 7.07e+05 3346.12 | 3248.13 0.0 1000 0 | 0.22 0.03 23.05 0.05
3 7.11e+05 3346.12 | 3257.00 0.0 1000 0 | 0.20 0.03 22.99 0.04
3 7.16e+05 3346.12 | 3250.57 0.0 1000 0 | 0.19 0.03 23.07 0.05
3 7.21e+05 3346.12 | 3286.31 0.0 1000 0 | 0.21 0.03 22.99 0.05
3 7.25e+05 3346.12 | 3226.14 0.0 1000 0 | 0.21 0.03 23.28 0.05
3 7.30e+05 3346.12 | 3222.68 0.0 1000 0 | 0.22 0.03 23.10 0.05
3 7.34e+05 3346.12 | 3275.78 0.0 1000 0 | 0.22 0.03 22.91 0.04
3 7.39e+05 3346.12 | 3254.49 0.0 1000 0 | 0.21 0.03 22.53 0.04
3 7.44e+05 3346.12 | 3292.13 0.0 1000 0 | 0.22 0.03 22.92 0.05
3 7.49e+05 3346.12 | 3274.65 0.0 1000 0 | 0.22 0.03 22.91 0.05
3 7.53e+05 3346.12 | 3308.70 0.0 1000 0 | 0.22 0.03 23.01 0.04
3 7.59e+05 3346.12 | 3274.37 0.0 1000 0 | 0.22 0.03 23.36 0.04
3 7.63e+05 3346.12 | 3320.37 0.0 1000 0 | 0.22 0.03 23.14 0.05
3 7.68e+05 3346.12 | 3324.92 0.0 1000 0 | 0.23 0.03 23.02 0.05
3 7.73e+05 3346.12 | 3259.66 0.0 1000 0 | 0.21 0.03 23.23 0.05
3 7.77e+05 3346.12 | 3260.96 0.0 1000 0 | 0.22 0.03 22.98 0.05
3 7.81e+05 3346.12 | 3302.02 0.0 1000 0 | 0.22 0.03 23.00 0.05
3 7.86e+05 3346.12 | 28.78 0.0 27 0 | 0.20 0.03 23.68 0.06
3 7.91e+05 3346.12 | 3297.69 0.0 1000 0 | 0.22 0.03 24.46 0.05
3 7.96e+05 3346.12 | 3323.15 0.0 1000 0 | 0.20 0.03 23.52 0.05
3 8.00e+05 3346.12 | 3314.14 0.0 1000 0 | 0.21 0.03 23.75 0.05
3 8.05e+05 3346.12 | 471.67 0.0 181 0 | 0.22 0.04 24.19 0.06
3 8.10e+05 3346.12 | 3219.53 0.0 1000 0 | 0.22 0.04 23.87 0.05
3 8.14e+05 3346.12 | 3254.78 0.0 1000 0 | 0.17 0.03 23.57 0.05
3 8.18e+05 3346.12 | 3174.39 0.0 1000 0 | 0.21 0.04 24.03 0.05
3 8.22e+05 3346.12 | 1044.23 0.0 1000 0 | 0.21 0.04 26.59 0.06
3 8.27e+05 3346.12 | 3258.03 0.0 1000 0 | 0.21 0.04 24.35 0.05
3 8.31e+05 3346.12 | 854.32 0.0 258 0 | 0.07 0.11 25.23 0.07
3 8.36e+05 3346.12 | 964.44 0.0 430 0 | 0.21 0.22 62.71 0.18
3 8.41e+05 3346.12 | 2235.00 0.0 1000 0 | 0.19 0.14 47.49 0.13
3 8.45e+05 3346.12 | 2899.15 0.0 1000 0 | 0.16 4.11 43.89 2.50
3 8.50e+05 3346.12 | 2099.78 0.0 1000 0 | 0.14 0.64 95.06 0.41
3 8.54e+05 3346.12 | 1020.43 0.0 1000 0 | 0.16 0.35 66.75 0.24
3 8.59e+05 3346.12 | 2483.12 0.0 1000 0 | 0.13 0.23 45.98 0.14
3 8.64e+05 3346.12 | 289.95 0.0 115 0 | 0.06 0.37 41.44 0.20
3 8.69e+05 3346.12 | 1026.99 0.0 1000 0 | 0.16 0.13 35.91 0.08
3 8.73e+05 3346.12 | 1426.79 0.0 475 0 | 0.14 0.08 28.36 0.06
3 8.78e+05 3422.72 |
3 8.78e+05 3422.72 | 3422.72 5.7 1000 0 | 0.07 0.06 25.28 0.05
3 8.82e+05 3422.72 | 3372.57 0.0 1000 0 | 0.17 0.04 23.51 0.05
3 8.87e+05 3422.72 | 3331.27 0.0 1000 0 | 0.20 0.04 22.86 0.05
3 8.91e+05 3422.72 | 3309.30 0.0 1000 0 | 0.21 0.04 22.95 0.05
3 8.96e+05 3422.72 | 3277.77 0.0 1000 0 | 0.22 0.04 22.96 0.05
3 9.00e+05 3422.72 | 3320.82 0.0 1000 0 | 0.21 0.04 23.49 0.05
3 9.05e+05 3422.72 | 3326.58 0.0 1000 0 | 0.20 0.04 23.32 0.05
3 9.09e+05 3422.72 | 975.64 0.0 1000 0 | 0.23 0.11 27.91 0.13
3 9.14e+05 3422.72 | 1042.28 0.0 1000 0 | 0.22 0.09 33.67 0.13
3 9.18e+05 3422.72 | 1658.80 0.0 1000 0 | 0.06 0.06 29.10 0.07
3 9.23e+05 3422.72 | 3276.92 0.0 1000 0 | 0.08 0.04 25.73 0.05
3 9.27e+05 3422.72 | 1156.36 0.0 1000 0 | 0.15 0.05 27.06 0.07
3 9.32e+05 3422.72 | 3223.98 0.0 1000 0 | 0.21 0.05 24.56 0.05
3 9.36e+05 3422.72 | 3224.42 0.0 1000 0 | 0.08 0.04 23.76 0.05
3 9.41e+05 3422.72 | 3346.42 0.0 1000 0 | 0.20 0.03 23.10 0.04
3 9.45e+05 3422.72 | 3321.12 0.0 1000 0 | 0.21 0.04 22.89 0.05
3 9.50e+05 3422.72 | 3307.79 0.0 1000 0 | 0.22 0.03 23.41 0.04
3 9.55e+05 3422.72 | 3388.66 0.0 1000 0 | 0.23 0.03 23.29 0.04
3 9.60e+05 3571.28 |
3 9.60e+05 3571.28 | 3571.28 153.4 994 11 | 0.22 0.03 22.61 0.04
3 9.64e+05 3571.28 | 2208.20 0.0 604 0 | 0.22 0.03 22.94 0.04
3 9.69e+05 3571.28 | 3360.15 0.0 1000 0 | 0.22 0.03 23.31 0.04
3 9.73e+05 3571.28 | 3333.36 0.0 1000 0 | 0.23 0.03 22.83 0.04
3 9.78e+05 3571.28 | 3310.99 0.0 1000 0 | 0.23 0.03 23.30 0.05
3 9.82e+05 3571.28 | 3490.81 0.0 1000 0 | 0.23 0.03 23.15 0.05
3 9.87e+05 3571.28 | 3320.36 0.0 1000 0 | 0.23 0.03 22.84 0.04
3 9.91e+05 3571.28 | 3332.88 0.0 1000 0 | 0.23 0.03 22.66 0.04
3 9.96e+05 3571.28 | 3379.00 0.0 1000 0 | 0.23 0.03 23.04 0.04
3 1.00e+06 3571.28 | 3400.09 0.0 1000 0 | 0.22 0.03 22.75 0.04
3 1.01e+06 3571.28 | 3336.84 0.0 1000 0 | 0.23 0.03 23.23 0.04
3 1.01e+06 3571.28 | 3343.45 0.0 1000 0 | 0.22 0.03 22.86 0.05
3 1.02e+06 3571.28 | 3386.21 0.0 1000 0 | 0.22 0.03 23.12 0.04
3 1.02e+06 3571.28 | 3526.69 0.0 1000 0 | 0.22 0.03 23.02 0.04
3 1.03e+06 3571.28 | 3117.71 0.0 827 0 | 0.23 0.03 23.20 0.04
3 1.03e+06 3571.28 | 3156.30 0.0 853 0 | 0.23 0.03 23.28 0.04
3 1.03e+06 3571.28 | 294.54 0.0 113 0 | 0.23 0.17 43.11 0.16
3 1.04e+06 3571.28 | 3199.89 0.0 1000 0 | 0.23 0.09 33.76 0.08
3 1.04e+06 3571.28 | 3196.45 0.0 1000 0 | 0.16 0.05 26.77 0.06
3 1.05e+06 3571.28 | 3350.85 0.0 1000 0 | 0.20 0.04 24.78 0.05
3 1.05e+06 3571.28 | 3282.41 0.0 1000 0 | 0.21 0.04 23.54 0.05
3 1.06e+06 3571.28 | 1015.27 0.0 1000 0 | 0.22 0.11 39.46 0.20
3 1.06e+06 3571.28 | 1011.59 0.0 1000 0 | 0.21 0.09 37.02 0.11
3 1.06e+06 3571.28 | 3270.80 0.0 1000 0 | 0.06 0.05 28.34 0.06
3 1.07e+06 3571.28 | 3296.79 0.0 1000 0 | 0.06 0.04 24.83 0.05
3 1.07e+06 3571.28 | 1010.46 0.0 1000 0 | 0.20 0.16 42.20 0.20
3 1.08e+06 3571.28 | 1031.59 0.0 1000 0 | 0.21 0.17 49.98 0.19
3 1.08e+06 3571.28 | 3305.42 0.0 1000 0 | 0.06 0.09 34.40 0.08
3 1.09e+06 3571.28 | 3317.12 0.0 1000 0 | 0.06 0.05 27.39 0.06
3 1.09e+06 3571.28 | 3300.44 0.0 1000 0 | 0.20 0.04 24.40 0.05
3 1.10e+06 3571.28 | 3374.11 0.0 1000 0 | 0.20 0.04 23.73 0.05
3 1.10e+06 3571.28 | 3356.14 0.0 1000 0 | 0.20 0.03 22.98 0.04
3 1.11e+06 3571.28 | 3429.12 0.0 1000 0 | 0.21 0.03 23.23 0.04
3 1.11e+06 3571.28 | 3546.16 0.0 1000 0 | 0.22 0.03 23.31 0.04
3 1.12e+06 3571.28 | 3353.44 0.0 1000 0 | 0.23 0.03 22.94 0.04
3 1.12e+06 3571.28 | 3330.81 0.0 1000 0 | 0.23 0.03 22.57 0.04
3 1.13e+06 3571.28 | 3539.38 0.0 1000 0 | 0.23 0.03 22.59 0.04
3 1.13e+06 3571.28 | 3367.10 0.0 1000 0 | 0.23 0.03 22.98 0.04
3 1.14e+06 3571.28 | 3400.75 0.0 1000 0 | 0.23 0.03 22.64 0.04
3 1.14e+06 3571.28 | 3353.39 0.0 1000 0 | 0.23 0.03 22.98 0.04
3 1.15e+06 3571.28 | 3350.79 0.0 1000 0 | 0.23 0.03 23.00 0.04
3 1.15e+06 3571.28 | 3409.38 0.0 1000 0 | 0.23 0.03 23.08 0.04
3 1.15e+06 3571.28 | 3322.69 0.0 1000 0 | 0.22 0.03 23.28 0.05
3 1.16e+06 3571.28 | 3480.63 0.0 1000 0 | 0.22 0.03 23.43 0.04
3 1.16e+06 3571.28 | 3471.95 0.0 1000 0 | 0.23 0.03 22.56 0.04
3 1.17e+06 3571.28 | 3420.43 0.0 1000 0 | 0.23 0.03 23.00 0.04
3 1.17e+06 3571.28 | 3451.60 0.0 1000 0 | 0.23 0.03 22.84 0.04
3 1.18e+06 3571.28 | 3480.65 0.0 1000 0 | 0.23 0.03 23.21 0.04
3 1.18e+06 3571.28 | 3299.38 0.0 1000 0 | 0.23 0.03 23.08 0.04
3 1.19e+06 3571.28 | 3424.38 0.0 1000 0 | 0.23 0.03 22.86 0.04
3 1.19e+06 3571.28 | 3479.01 0.0 1000 0 | 0.23 0.03 23.10 0.04
3 1.20e+06 3571.28 | 3445.37 0.0 1000 0 | 0.23 0.03 22.98 0.04
3 1.20e+06 3571.28 | 3379.36 0.0 1000 0 | 0.24 0.03 22.98 0.04
3 1.21e+06 3571.28 | 3406.81 0.0 1000 0 | 0.23 0.03 23.53 0.04
3 1.21e+06 3571.28 | 3393.73 0.0 1000 0 | 0.23 0.03 23.01 0.04
3 1.21e+06 3571.28 | 3484.27 0.0 1000 0 | 0.23 0.02 23.16 0.04
3 1.22e+06 3571.28 | 1042.91 0.0 1000 0 | 0.23 0.03 25.02 0.05
3 1.22e+06 3571.28 | 3328.04 0.0 1000 0 | 0.23 0.03 23.60 0.04
3 1.23e+06 3571.28 | 431.63 0.0 161 0 | 0.07 0.03 23.69 0.04
3 1.23e+06 3571.28 | 3322.50 0.0 1000 0 | 0.23 0.03 22.57 0.04
3 1.24e+06 3571.28 | 3283.49 0.0 1000 0 | 0.22 0.03 23.31 0.04
3 1.24e+06 3571.28 | 1090.55 0.0 1000 0 | 0.22 0.05 27.79 0.10
3 1.25e+06 3571.28 | 3300.28 0.0 1000 0 | 0.23 0.03 25.05 0.05
3 1.25e+06 3571.28 | 1051.65 0.0 1000 0 | 0.07 0.04 25.91 0.06
3 1.25e+06 3571.28 | 3308.98 0.0 1000 0 | 0.21 0.03 24.53 0.05
3 1.26e+06 3571.28 | 3304.30 0.0 1000 0 | 0.13 0.03 24.05 0.04
3 1.26e+06 3571.28 | 3509.68 0.0 1000 0 | 0.22 0.03 23.51 0.04
3 1.27e+06 3571.28 | 1866.43 0.0 528 0 | 0.21 0.03 23.08 0.04
3 1.27e+06 3571.28 | 3329.80 0.0 1000 0 | 0.23 0.03 23.43 0.05
3 1.28e+06 3571.28 | 3422.68 326.1 944 98 | 0.23 0.03 23.62 0.04
3 1.28e+06 3571.28 | 1058.56 0.0 450 0 | 0.22 0.06 28.74 0.10
3 1.29e+06 3571.28 | 3205.49 0.0 1000 0 | 0.23 0.04 25.44 0.05
3 1.29e+06 3571.28 | 3327.98 0.0 1000 0 | 0.17 0.03 23.57 0.05
3 1.29e+06 3571.28 | 3366.74 0.0 1000 0 | 0.21 0.03 23.18 0.05
3 1.30e+06 3571.28 | 3394.69 0.0 1000 0 | 0.23 0.03 23.19 0.04
3 1.30e+06 3571.28 | 3355.44 0.0 1000 0 | 0.22 0.03 22.85 0.04
3 1.31e+06 3571.28 | 3503.05 0.0 1000 0 | 0.22 0.03 23.22 0.04
3 1.31e+06 3571.28 | 3368.96 0.0 1000 0 | 0.23 0.03 23.36 0.05
3 1.32e+06 3571.28 | 3515.65 0.0 959 0 | 0.23 0.03 23.59 0.04
| UsedTime: 56106 | SavedDir: ./Hopper-v2_ReliableSAC_3
"""
elif env_name == 'Hopper-v2':
env_func = gym.make
env_args = {
'env_num': 1,
'env_name': 'Hopper-v2',
'max_step': 1000,
'state_dim': 11,
'action_dim': 3,
'if_discrete': False,
'target_return': 3800.,
}
args = Arguments(agent, env_func=env_func, env_args=env_args)
args.eval_times = 2 ** 2
args.reward_scale = 2 ** -4
args.target_step = args.max_step * 2
args.worker_num = 2
args.net_dim = 2 ** 8
args.num_layer = 3
args.batch_size = int(args.net_dim * 2)
args.repeat_times = 2 ** 4
args.gamma = 0.993 # todo
args.if_allow_break = False
args.break_step = int(8e6)
"""
################################################################################
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
6 4.05e+03 34.11 |
6 4.05e+03 34.11 | 34.11 0.4 38 0 | 0.05 0.80 0.84 0.33
6 1.17e+05 62.90 |
6 1.17e+05 62.90 | 62.90 0.7 38 0 | 0.11 0.33 14.94 0.28
6 1.96e+05 313.13 |
6 1.96e+05 313.13 | 313.13 0.8 140 0 | 0.13 0.59 30.46 0.20
6 2.56e+05 313.13 | 288.39 0.0 125 0 | 0.14 0.59 36.48 0.15
6 3.04e+05 313.13 | 268.59 0.0 117 0 | 0.14 0.49 32.35 0.14
6 3.44e+05 313.13 | 7.47 0.0 33 0 | 0.12 0.36 25.97 0.13
6 3.83e+05 1038.82 |
6 3.83e+05 1038.82 | 1038.82 0.2 1000 0 | 0.07 0.32 29.84 0.17
6 4.22e+05 1038.82 | 1028.53 0.0 1000 0 | 0.08 0.32 31.94 0.18
6 4.57e+05 1038.82 | 1024.58 0.0 1000 0 | 0.09 0.31 29.22 0.14
6 4.89e+05 1054.37 |
6 4.89e+05 1054.37 | 1054.37 6.0 1000 0 | 0.07 0.30 32.58 0.15
6 5.18e+05 1054.37 | 345.63 0.0 152 0 | 0.14 0.32 33.13 0.14
6 5.44e+05 1054.37 | 181.06 0.0 110 0 | 0.10 0.28 34.14 0.14
6 5.71e+05 1054.37 | 602.82 0.0 215 0 | 0.15 0.39 31.36 0.12
6 5.95e+05 1054.37 | 1035.55 0.0 1000 0 | 0.10 0.40 33.95 0.15
6 6.19e+05 1054.37 | 295.51 0.0 126 0 | 0.15 0.51 31.59 0.14
6 6.44e+05 1054.37 | 64.50 0.0 43 0 | 0.07 0.46 33.29 0.17
6 6.66e+05 1054.37 | 643.23 0.0 284 0 | 0.14 0.37 34.44 0.15
6 6.89e+05 1054.37 | 501.73 0.0 173 0 | 0.11 0.32 35.48 0.16
6 7.08e+05 1054.37 | 388.54 0.0 214 0 | 0.13 0.27 34.18 0.13
6 7.29e+05 1054.37 | 458.66 0.0 304 0 | 0.08 0.26 31.83 0.14
6 7.48e+05 1054.37 | 254.32 0.0 146 0 | 0.12 0.22 29.52 0.11
6 7.68e+05 1054.37 | 1028.87 0.0 1000 0 | 0.08 0.19 26.58 0.10
6 7.86e+05 1054.37 | 240.32 0.0 196 0 | 0.08 0.16 25.03 0.10
6 8.03e+05 1054.37 | 108.17 0.0 73 0 | 0.08 0.15 23.71 0.10
6 8.22e+05 1054.37 | 1029.23 0.0 1000 0 | 0.08 0.15 22.94 0.08
6 8.43e+05 1054.37 | 1039.32 0.0 1000 0 | 0.07 0.13 22.86 0.08
6 8.64e+05 1054.37 | 1036.23 0.0 1000 0 | 0.07 0.12 21.10 0.07
6 8.83e+05 2471.51 |
6 8.83e+05 2471.51 | 2471.51 2.0 1000 0 | 0.14 0.11 20.02 0.07
6 8.99e+05 2471.51 | 271.53 0.0 136 0 | 0.14 0.10 19.55 0.06
6 9.16e+05 2471.51 | 788.17 0.0 328 0 | 0.15 0.11 19.51 0.07
6 9.32e+05 2471.51 | 305.98 0.0 143 0 | 0.14 0.10 19.81 0.07
6 9.49e+05 2471.51 | 213.25 0.0 115 0 | 0.16 0.11 19.30 0.06
6 9.65e+05 2471.51 | 212.62 0.0 116 0 | 0.17 0.09 18.55 0.06
6 9.80e+05 2471.51 | 231.38 0.0 121 0 | 0.16 0.09 18.55 0.06
6 9.96e+05 2816.96 |
6 9.96e+05 2816.96 | 2816.96 1.5 1000 0 | 0.18 0.09 18.83 0.06
6 1.01e+06 2816.96 | 2526.01 0.0 1000 0 | 0.19 0.08 19.41 0.06
6 1.03e+06 2816.96 | 2502.35 0.0 1000 0 | 0.19 0.09 19.39 0.06
6 1.04e+06 2816.96 | 2792.51 0.0 1000 0 | 0.19 0.09 19.62 0.06
6 1.06e+06 2816.96 | 2807.12 18.1 1000 0 | 0.18 0.09 19.92 0.06
6 1.07e+06 2816.96 | 1274.49 0.0 452 0 | 0.20 0.08 19.97 0.06
6 1.08e+06 2827.08 |
6 1.08e+06 2827.08 | 2827.08 8.4 1000 0 | 0.19 0.08 20.43 0.06
6 1.10e+06 2827.08 | 1578.28 0.0 569 0 | 0.19 0.08 20.81 0.06
6 1.11e+06 2871.91 |
6 1.11e+06 2871.91 | 2871.91 0.9 1000 0 | 0.20 0.08 20.87 0.06
6 1.13e+06 2871.91 | 2688.35 0.0 1000 0 | 0.19 0.08 21.17 0.06
6 1.14e+06 2871.91 | 2681.34 0.0 1000 0 | 0.18 0.08 21.20 0.06
6 1.16e+06 2871.91 | 2810.03 0.0 1000 0 | 0.18 0.08 22.26 0.06
6 1.18e+06 2871.91 | 1660.03 0.0 584 0 | 0.18 0.08 21.62 0.06
6 1.19e+06 2871.91 | 2639.25 0.0 1000 0 | 0.18 0.07 21.81 0.06
6 1.21e+06 2871.91 | 939.60 0.0 312 0 | 0.18 0.07 21.66 0.06
6 1.22e+06 2871.91 | 2716.22 0.0 1000 0 | 0.18 0.08 21.85 0.06
6 1.24e+06 2871.91 | 2697.94 0.0 1000 0 | 0.19 0.07 21.58 0.06
6 1.25e+06 2871.91 | 2739.97 0.0 1000 0 | 0.19 0.07 22.32 0.06
6 1.26e+06 2871.91 | 2726.54 0.0 1000 0 | 0.19 0.07 22.24 0.06
6 1.27e+06 2871.91 | 2596.29 0.0 1000 0 | 0.20 0.07 22.64 0.06
6 1.29e+06 2871.91 | 2695.79 0.0 1000 0 | 0.19 0.07 22.49 0.06
6 1.30e+06 2871.91 | 2513.97 0.0 1000 0 | 0.18 0.07 22.17 0.06
6 1.31e+06 2871.91 | 2653.65 0.0 1000 0 | 0.20 0.06 21.88 0.06
6 1.32e+06 2871.91 | 2545.89 0.0 1000 0 | 0.19 0.06 22.11 0.06
6 1.34e+06 2871.91 | 2627.76 0.0 1000 0 | 0.17 0.06 22.41 0.06
6 1.35e+06 2871.91 | 2512.66 0.0 1000 0 | 0.18 0.06 21.69 0.06
6 1.36e+06 2871.91 | 2614.05 0.0 1000 0 | 0.19 0.06 22.41 0.06
6 1.37e+06 2871.91 | 2511.88 0.0 1000 0 | 0.18 0.06 22.86 0.06
6 1.38e+06 2871.91 | 2511.73 0.0 1000 0 | 0.18 0.06 22.40 0.06
6 1.39e+06 2871.91 | 2576.39 0.0 1000 0 | 0.18 0.06 22.36 0.06
6 1.40e+06 2871.91 | 2593.05 0.0 1000 0 | 0.18 0.06 22.56 0.06
6 1.42e+06 2871.91 | 2612.13 0.0 1000 0 | 0.19 0.06 22.38 0.06
6 1.43e+06 2871.91 | 2709.74 0.0 1000 0 | 0.18 0.06 22.08 0.06
6 1.44e+06 2871.91 | 2762.59 0.0 1000 0 | 0.18 0.06 22.09 0.06
6 1.45e+06 2871.91 | 2746.69 0.0 1000 0 | 0.18 0.06 21.86 0.06
6 1.46e+06 2871.91 | 2637.90 0.0 1000 0 | 0.18 0.06 22.09 0.06
6 1.48e+06 2871.91 | 2712.50 0.0 1000 0 | 0.18 0.05 22.10 0.06
6 1.49e+06 2871.91 | 2703.42 0.0 1000 0 | 0.18 0.06 22.62 0.06
6 1.50e+06 2871.91 | 2767.33 0.0 1000 0 | 0.17 0.05 21.92 0.06
6 1.51e+06 2919.71 |
6 1.51e+06 2919.71 | 2919.71 4.6 1000 0 | 0.18 0.06 22.39 0.06
6 1.52e+06 2919.71 | 2878.41 0.0 1000 0 | 0.18 0.06 22.34 0.06
6 1.54e+06 2919.71 | 2706.40 0.0 1000 0 | 0.19 0.06 22.33 0.05
6 1.55e+06 2919.71 | 2766.00 0.0 1000 0 | 0.19 0.05 22.25 0.05
6 1.56e+06 2919.71 | 2686.77 0.0 1000 0 | 0.19 0.05 22.11 0.05
6 1.57e+06 2919.71 | 2806.31 0.0 1000 0 | 0.19 0.05 22.06 0.05
6 1.58e+06 2919.71 | 2806.25 0.0 1000 0 | 0.18 0.05 21.52 0.05
6 1.59e+06 2919.71 | 2851.65 0.0 1000 0 | 0.19 0.05 21.15 0.05
6 1.60e+06 2919.71 | 2799.51 0.0 1000 0 | 0.18 0.05 21.29 0.05
6 1.61e+06 2919.71 | 2853.32 0.0 1000 0 | 0.18 0.05 21.43 0.05
6 1.62e+06 2919.71 | 2776.67 0.0 1000 0 | 0.18 0.05 21.82 0.05
6 1.63e+06 2919.71 | 2846.76 0.0 1000 0 | 0.18 0.05 21.45 0.05
6 1.64e+06 2919.71 | 2792.80 0.0 1000 0 | 0.19 0.05 21.70 0.05
6 1.65e+06 2919.71 | 2827.58 0.0 1000 0 | 0.19 0.05 21.97 0.05
6 1.66e+06 2919.71 | 2784.43 0.0 1000 0 | 0.19 0.05 21.33 0.05
6 1.67e+06 2919.71 | 2737.03 0.0 1000 0 | 0.19 0.04 21.52 0.05
6 1.68e+06 2919.71 | 2812.33 0.0 1000 0 | 0.18 0.04 21.24 0.05
6 1.69e+06 2919.71 | 2788.36 0.0 1000 0 | 0.18 0.05 21.54 0.05
6 1.70e+06 2919.71 | 2786.58 0.0 1000 0 | 0.19 0.04 21.31 0.05
6 1.71e+06 2919.71 | 2742.50 0.0 1000 0 | 0.18 0.04 21.51 0.05
6 1.72e+06 2919.71 | 2720.79 0.0 1000 0 | 0.19 0.05 21.70 0.05
6 1.73e+06 2919.71 | 2786.67 0.0 1000 0 | 0.18 0.04 21.73 0.05
6 1.74e+06 2919.71 | 2843.51 0.0 1000 0 | 0.19 0.05 21.66 0.05
6 1.75e+06 2919.71 | 2808.91 0.0 1000 0 | 0.19 0.05 21.34 0.05
6 1.76e+06 2919.71 | 2796.23 0.0 1000 0 | 0.19 0.04 21.98 0.05
6 1.78e+06 2919.71 | 2887.21 0.0 1000 0 | 0.19 0.05 21.69 0.05
6 1.79e+06 2919.71 | 2779.83 0.0 1000 0 | 0.18 0.05 21.79 0.05
6 1.80e+06 2919.71 | 2910.02 0.0 1000 0 | 0.19 0.05 21.81 0.05
6 1.81e+06 2978.96 |
6 1.81e+06 2978.96 | 2978.96 0.6 1000 0 | 0.19 0.04 22.15 0.05
6 1.82e+06 2990.69 |
6 1.82e+06 2990.69 | 2990.69 4.2 1000 0 | 0.20 0.04 21.37 0.05
6 1.83e+06 2990.69 | 2946.43 0.0 1000 0 | 0.19 0.05 22.07 0.05
6 1.84e+06 2990.69 | 2840.06 0.0 1000 0 | 0.19 0.04 22.10 0.05
6 1.85e+06 2990.69 | 2939.27 0.0 1000 0 | 0.19 0.05 21.63 0.05
6 1.86e+06 2990.69 | 2851.73 0.0 1000 0 | 0.19 0.05 22.16 0.05
6 1.87e+06 2990.69 | 2902.68 0.0 1000 0 | 0.19 0.05 22.01 0.05
6 1.88e+06 2990.69 | 2891.08 0.0 1000 0 | 0.19 0.05 22.01 0.05
6 1.89e+06 2990.69 | 2874.25 0.0 1000 0 | 0.19 0.04 21.42 0.05
6 1.90e+06 2990.69 | 2858.17 0.0 1000 0 | 0.19 0.04 22.03 0.05
6 1.91e+06 2990.69 | 2885.14 0.0 1000 0 | 0.19 0.04 21.90 0.05
6 1.92e+06 2990.69 | 2835.17 0.0 1000 0 | 0.19 0.04 21.43 0.05
6 1.93e+06 2990.69 | 2842.48 0.0 1000 0 | 0.18 0.04 21.61 0.05
6 1.94e+06 2990.69 | 2881.02 0.0 1000 0 | 0.19 0.04 21.86 0.05
6 1.95e+06 2990.69 | 2960.67 0.0 1000 0 | 0.18 0.04 22.14 0.05
6 1.96e+06 2990.69 | 2947.27 0.0 1000 0 | 0.19 0.04 22.05 0.05
6 1.97e+06 2990.69 | 2901.40 0.0 1000 0 | 0.20 0.04 21.81 0.05
6 1.98e+06 2990.69 | 2927.26 0.0 1000 0 | 0.19 0.04 22.16 0.05
6 1.99e+06 2990.69 | 2960.03 0.0 1000 0 | 0.20 0.04 21.71 0.04
6 2.00e+06 2993.62 |
6 2.00e+06 2993.62 | 2993.62 2.0 1000 0 | 0.19 0.04 21.76 0.04
6 2.01e+06 2993.62 | 2903.15 0.0 1000 0 | 0.20 0.04 21.60 0.04
6 2.02e+06 2993.62 | 2811.17 0.0 1000 0 | 0.19 0.04 21.50 0.04
6 2.03e+06 2993.62 | 2878.24 0.0 1000 0 | 0.19 0.04 21.86 0.04
6 2.04e+06 2993.62 | 2916.72 0.0 1000 0 | 0.19 0.04 21.96 0.04
6 2.05e+06 2993.62 | 2891.63 0.0 1000 0 | 0.19 0.04 21.99 0.04
6 2.06e+06 2993.62 | 2965.31 0.0 1000 0 | 0.19 0.04 21.86 0.04
6 2.07e+06 2993.62 | 2910.02 0.0 1000 0 | 0.19 0.04 21.89 0.04
6 2.08e+06 2993.62 | 2942.60 0.0 1000 0 | 0.19 0.04 21.88 0.04
6 2.09e+06 2999.49 |
6 2.09e+06 2999.49 | 2999.49 1.1 1000 0 | 0.19 0.04 21.68 0.04
6 2.09e+06 2999.49 | 2967.17 0.0 1000 0 | 0.19 0.04 22.16 0.04
6 2.10e+06 2999.49 | 2937.72 0.0 1000 0 | 0.19 0.04 21.36 0.04
6 2.10e+06 2999.49 | 2937.72 0.0 1000 0 | 0.19 0.04 21.36 0.04
6 2.11e+06 2999.49 | 2947.81 0.0 1000 0 | 0.20 0.04 20.62 0.04
6 2.12e+06 2999.49 | 2928.85 0.0 1000 0 | 0.20 0.04 21.45 0.04
6 2.12e+06 3005.13 |
6 2.12e+06 3005.13 | 3005.13 0.9 1000 0 | 0.19 0.04 21.66 0.04
6 2.13e+06 3005.13 | 2968.58 0.0 1000 0 | 0.19 0.04 21.54 0.04
6 2.14e+06 3007.51 |
6 2.14e+06 3007.51 | 3007.51 0.5 1000 0 | 0.20 0.04 21.40 0.04
6 2.15e+06 3007.51 | 2958.19 0.0 1000 0 | 0.20 0.04 21.94 0.04
6 2.16e+06 3059.47 |
6 2.16e+06 3059.47 | 3059.47 1.8 1000 0 | 0.19 0.04 21.89 0.04
6 2.17e+06 3059.47 | 3039.30 0.0 1000 0 | 0.19 0.04 22.13 0.04
6 2.18e+06 3079.37 |
6 2.18e+06 3079.37 | 3079.37 0.4 1000 0 | 0.20 0.04 22.02 0.04
6 2.18e+06 3079.37 | 3036.29 0.0 1000 0 | 0.20 0.03 21.91 0.04
6 2.20e+06 3079.37 | 3045.43 0.0 1000 0 | 0.20 0.04 21.75 0.04
6 2.21e+06 3079.37 | 3078.21 0.0 1000 0 | 0.20 0.04 21.72 0.04
6 2.21e+06 3079.37 | 3030.94 0.0 1000 0 | 0.19 0.03 21.58 0.04
6 2.22e+06 3079.37 | 3034.21 0.0 1000 0 | 0.19 0.03 21.51 0.04
6 2.23e+06 3079.37 | 3065.70 0.0 1000 0 | 0.19 0.03 21.91 0.04
6 2.23e+06 3079.37 | 3027.77 0.0 1000 0 | 0.19 0.03 21.56 0.04
6 2.24e+06 3079.37 | 3050.05 0.0 1000 0 | 0.19 0.03 21.51 0.04
6 2.25e+06 3079.37 | 3055.75 0.0 1000 0 | 0.19 0.03 21.59 0.04
6 2.26e+06 3079.37 | 3029.73 0.0 1000 0 | 0.20 0.03 21.99 0.04
6 2.26e+06 3079.37 | 3075.19 0.0 1000 0 | 0.20 0.03 21.55 0.04
6 2.27e+06 3079.37 | 3020.89 0.0 1000 0 | 0.19 0.03 21.20 0.04
6 2.28e+06 3079.37 | 3069.39 0.0 1000 0 | 0.19 0.03 21.37 0.04
6 2.28e+06 3079.37 | 3065.39 0.0 1000 0 | 0.19 0.03 21.35 0.04
6 2.29e+06 3079.37 | 3073.13 0.0 1000 0 | 0.19 0.03 22.03 0.04
6 2.30e+06 3079.37 | 3050.63 0.0 1000 0 | 0.19 0.03 21.24 0.04
6 2.30e+06 3079.37 | 3078.68 0.0 1000 0 | 0.20 0.03 21.41 0.04
6 2.31e+06 3079.37 | 3036.35 0.0 1000 0 | 0.19 0.03 21.59 0.04
6 2.32e+06 3079.37 | 414.22 0.0 278 0 | 0.01 0.30 49.33 0.06
6 2.33e+06 3079.37 | 1001.89 0.0 1000 0 | 0.06 0.17 42.27 0.08
6 2.33e+06 3079.37 | 1015.33 0.0 1000 0 | 0.06 0.13 37.14 0.11
6 2.34e+06 3079.37 | 1011.02 0.0 1000 0 | 0.06 0.10 34.35 0.10
6 2.35e+06 3079.37 | 2813.60 0.0 1000 0 | 0.07 0.12 30.99 0.08
6 2.35e+06 3079.37 | 505.06 0.0 195 0 | 0.18 0.10 29.30 0.08
6 2.36e+06 3079.37 | 333.13 0.0 125 0 | 0.17 0.10 29.47 0.08
6 2.37e+06 3079.37 | 628.32 0.0 262 0 | 0.15 0.08 29.50 0.08
6 2.37e+06 3079.37 | 1799.29 0.0 623 0 | 0.15 0.08 27.85 0.07
6 2.38e+06 3079.37 | 3069.86 10.1 1000 0 | 0.16 0.08 26.93 0.07
6 2.39e+06 3079.37 | 939.58 0.0 278 0 | 0.18 0.07 25.53 0.06
6 2.39e+06 3079.37 | 3046.63 0.0 1000 0 | 0.20 0.08 25.15 0.06
6 2.40e+06 3187.65 |
6 2.40e+06 3187.65 | 3187.65 3.1 1000 0 | 0.19 0.07 24.49 0.05
"""
elif env_name == 'Humanoid-v3.9400.best':
from elegantrl.envs.CustomGymEnv import HumanoidEnv
env_func = HumanoidEnv
env_args = {
'env_num': 1,
'env_name': 'Humanoid-v3',
'max_step': 1000,
'state_dim': 376,
'action_dim': 17,
'if_discrete': False,
'target_return': 3000.,
}
args = Arguments(agent, env_func=env_func, env_args=env_args)
args.eval_times = 2 ** 2
args.reward_scale = 2 ** -2
args.max_memo = 2 ** 21
args.learning_rate = 2 ** -14
args.lambda_a_log_std = 2 ** -6
args.target_step = args.max_step
args.worker_num = 4
args.net_dim = 2 ** 9
args.batch_size = args.net_dim // 2
args.num_layer = 3
args.repeat_times = 2 ** 0
args.gamma = 0.96
args.if_act_target = False
import numpy as np
args.target_entropy = np.log(env_args['action_dim'])
args.if_allow_break = False
args.break_step = int(4e6)
"""
| Arguments Remove cwd: ./Humanoid-v3_ReliableSAC_3
################################################################################
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
3 8.09e+03 176.45 |
3 8.09e+03 176.45 | 176.45 29.6 34 6 | 1.19 0.69 2.81 0.06
3 1.47e+05 216.06 |
3 1.47e+05 216.06 | 216.06 12.1 41 2 | 1.27 0.79 32.29 0.03
3 2.25e+05 289.98 |
3 2.25e+05 289.98 | 289.98 13.7 56 2 | 1.34 0.68 31.95 0.01
3 2.83e+05 316.69 |
3 2.83e+05 316.69 | 316.69 17.4 58 3 | 1.34 0.45 27.33 0.01
3 3.28e+05 316.69 | 287.80 0.0 57 0 | 1.28 0.33 24.88 0.01
3 3.70e+05 379.81 |
3 3.70e+05 379.81 | 379.81 36.3 71 7 | 1.31 0.29 24.75 0.01
3 4.07e+05 379.81 | 209.17 0.0 41 0 | 1.35 0.26 25.31 0.01
3 4.40e+05 379.81 | 356.76 0.0 67 0 | 1.36 0.24 25.37 0.01
3 4.74e+05 379.81 | 374.84 36.5 67 6 | 1.34 0.22 25.21 0.01
3 5.03e+05 525.94 |
3 5.03e+05 525.94 | 525.94 41.6 100 11 | 1.36 0.21 25.63 0.01
3 5.32e+05 525.94 | 497.22 0.0 89 0 | 1.36 0.20 25.51 0.01
3 5.62e+05 525.94 | 334.79 0.0 59 0 | 1.37 0.20 26.24 0.01
3 5.87e+05 525.94 | 428.25 0.0 76 0 | 1.39 0.19 25.51 0.01
3 6.12e+05 525.94 | 423.34 0.0 74 0 | 1.37 0.18 26.50 0.01
3 6.37e+05 525.94 | 479.20 0.0 84 0 | 1.40 0.18 26.26 0.01
3 6.62e+05 551.04 |
3 6.62e+05 551.04 | 551.04 83.8 98 16 | 1.39 0.18 26.49 0.01
3 6.83e+05 551.04 | 397.43 0.0 70 0 | 1.36 0.18 27.22 0.01
3 7.04e+05 745.68 |
3 7.04e+05 745.68 | 745.68 106.0 134 15 | 1.35 0.17 26.33 0.01
3 7.25e+05 745.68 | 509.76 0.0 89 0 | 1.42 0.17 26.93 0.01
3 7.47e+05 745.68 | 376.85 0.0 70 0 | 1.41 0.18 28.16 0.01
3 7.69e+05 745.68 | 580.24 127.2 104 23 | 1.38 0.18 27.97 0.01
3 7.91e+05 745.68 | 491.18 0.0 85 0 | 1.40 0.18 27.98 0.01
3 8.12e+05 745.68 | 492.97 0.0 87 0 | 1.41 0.18 29.00 0.01
3 8.34e+05 801.10 |
3 8.34e+05 801.10 | 801.10 244.9 146 39 | 1.43 0.18 28.95 0.01
3 8.51e+05 801.10 | 522.10 0.0 93 0 | 1.42 0.18 28.90 0.01
3 8.69e+05 801.10 | 620.43 0.0 105 0 | 1.44 0.18 29.90 0.01
3 8.85e+05 829.16 |
3 8.85e+05 829.16 | 829.16 109.8 152 30 | 1.42 0.17 29.57 0.01
3 9.03e+05 829.16 | 733.06 127.1 135 32 | 1.47 0.17 30.11 0.01
3 9.20e+05 1018.17 |
3 9.20e+05 1018.17 | 1018.17 329.5 174 53 | 1.43 0.17 30.46 0.01
3 9.37e+05 1018.17 | 739.87 0.0 135 0 | 1.45 0.18 28.93 0.01
3 9.55e+05 1018.17 | 744.00 0.0 129 0 | 1.46 0.18 31.50 0.01
3 9.73e+05 1208.41 |
3 9.73e+05 1208.41 | 1208.41 378.3 204 57 | 1.48 0.17 29.71 0.01
3 9.90e+05 1208.41 | 647.54 0.0 117 0 | 1.45 0.18 30.89 0.01
3 1.01e+06 1208.41 | 929.52 0.0 163 0 | 1.47 0.18 30.55 0.01
3 1.02e+06 2111.40 |
3 1.02e+06 2111.40 | 2111.40 513.4 344 77 | 1.50 0.18 30.26 0.01
3 1.04e+06 2961.21 |
3 1.04e+06 2961.21 | 2961.21 1907.8 467 300 | 1.49 0.17 31.73 0.01
3 1.06e+06 2961.21 | 1923.17 0.0 307 0 | 1.51 0.18 31.26 0.01
3 1.08e+06 2961.21 | 665.96 0.0 115 0 | 1.51 0.17 32.32 0.01
3 1.10e+06 2961.21 | 2009.69 0.0 308 0 | 1.56 0.17 32.11 0.01
3 1.11e+06 2961.21 | 1253.18 0.0 193 0 | 1.54 0.17 31.96 0.02
3 1.13e+06 2961.21 | 822.65 0.0 125 0 | 1.56 0.17 32.47 0.02
3 1.15e+06 2961.21 | 808.09 0.0 126 0 | 1.58 0.18 32.09 0.02
3 1.16e+06 2961.21 | 1995.99 0.0 317 0 | 1.58 0.17 32.54 0.02
3 1.17e+06 2961.21 | 804.38 0.0 128 0 | 1.59 0.18 33.59 0.02
3 1.19e+06 2961.21 | 1058.70 0.0 169 0 | 1.58 0.18 32.22 0.02
3 1.20e+06 2961.21 | 954.06 0.0 155 0 | 1.61 0.18 33.44 0.02
3 1.21e+06 2961.21 | 1245.58 0.0 195 0 | 1.62 0.18 32.46 0.02
3 1.23e+06 2961.21 | 2780.23 0.0 415 0 | 1.62 0.18 33.10 0.02
3 1.24e+06 4273.43 |
3 1.24e+06 4273.43 | 4273.43 1977.1 643 289 | 1.63 0.17 33.10 0.02
3 1.26e+06 4273.43 | 304.42 0.0 53 0 | 1.63 0.18 33.53 0.02
3 1.27e+06 4273.43 | 4017.09 2192.0 596 319 | 1.65 0.18 33.96 0.02
3 1.29e+06 4273.43 | 4190.22 2639.0 604 374 | 1.65 0.18 34.71 0.02
3 1.30e+06 4273.43 | 1137.88 0.0 185 0 | 1.68 0.18 33.78 0.02
3 1.31e+06 4273.43 | 977.47 0.0 143 0 | 1.65 0.18 34.35 0.02
3 1.33e+06 4969.29 |
3 1.33e+06 4969.29 | 4969.29 2784.2 712 393 | 1.72 0.18 34.51 0.02
3 1.34e+06 4969.29 | 4573.45 0.0 634 0 | 1.71 0.18 35.18 0.02
3 1.36e+06 4969.29 | 4896.34 0.0 663 0 | 1.76 0.18 35.41 0.02
3 1.37e+06 4969.29 | 1326.51 0.0 194 0 | 1.67 0.18 34.70 0.02
3 1.39e+06 4969.29 | 1680.32 0.0 238 0 | 1.80 0.18 35.17 0.02
3 1.40e+06 4969.29 | 3260.77 0.0 451 0 | 1.74 0.18 34.56 0.02
3 1.42e+06 4969.29 | 1140.55 0.0 162 0 | 1.80 0.18 34.71 0.02
3 1.43e+06 4969.29 | 2484.06 2403.7 340 320 | 1.79 0.18 35.37 0.02
3 1.45e+06 4969.29 | 2997.63 0.0 422 0 | 1.81 0.19 35.35 0.02
3 1.46e+06 4969.29 | 4737.24 1827.3 641 242 | 1.85 0.18 35.85 0.02
3 1.48e+06 4969.29 | 1047.71 0.0 148 0 | 1.83 0.19 35.50 0.02
3 1.49e+06 4969.29 | 173.17 0.0 33 0 | 1.84 0.19 36.82 0.02
3 1.51e+06 4969.29 | 3679.41 0.0 497 0 | 1.86 0.19 36.89 0.02
3 1.52e+06 4969.29 | 4962.11 2734.9 652 348 | 1.88 0.19 37.78 0.02
3 1.53e+06 4969.29 | 2338.43 0.0 305 0 | 1.86 0.19 36.17 0.02
3 1.55e+06 4969.29 | 2442.01 0.0 309 0 | 1.81 0.19 36.69 0.02
3 1.56e+06 4969.29 | 4154.86 2039.7 522 250 | 1.85 0.19 37.91 0.02
3 1.58e+06 4969.29 | 4003.55 0.0 502 0 | 1.84 0.18 37.31 0.02
3 1.59e+06 4969.29 | 3509.02 0.0 445 0 | 1.88 0.19 37.35 0.02
3 1.61e+06 4969.29 | 3969.27 2935.2 520 379 | 1.86 0.19 36.67 0.02
3 1.62e+06 4969.29 | 2483.33 0.0 323 0 | 1.86 0.19 37.52 0.02
3 1.64e+06 4969.29 | 2687.55 0.0 354 0 | 1.93 0.19 38.44 0.02
3 1.65e+06 4969.29 | 4662.24 0.0 574 0 | 1.90 0.18 38.91 0.02
3 1.66e+06 4969.29 | 2818.31 0.0 363 0 | 1.98 0.19 38.51 0.02
3 1.68e+06 4969.29 | 1649.55 0.0 219 0 | 1.84 0.20 37.76 0.02
3 1.69e+06 4969.29 | 4783.08 0.0 580 0 | 1.92 0.19 39.04 0.02
3 1.70e+06 4969.29 | 406.79 0.0 65 0 | 1.89 0.19 37.27 0.02
3 1.71e+06 4969.29 | 2765.69 0.0 338 0 | 1.92 0.20 38.05 0.02
3 1.72e+06 4969.29 | 1396.78 0.0 179 0 | 1.92 0.19 37.59 0.02
3 1.73e+06 4969.29 | 1609.04 0.0 209 0 | 1.92 0.20 37.77 0.02
3 1.74e+06 4969.29 | 4467.71 0.0 560 0 | 1.96 0.19 38.12 0.02
3 1.75e+06 5073.69 |
3 1.75e+06 5073.69 | 5073.69 3289.1 624 396 | 1.97 0.19 38.57 0.02
3 1.76e+06 5073.69 | 2309.20 0.0 281 0 | 1.96 0.19 39.72 0.02
3 1.77e+06 7728.06 |
3 1.77e+06 7728.06 | 7728.06 851.9 914 95 | 1.93 0.19 38.74 0.02
3 1.78e+06 7728.06 | 1083.30 0.0 144 0 | 2.01 0.19 39.00 0.02
3 1.79e+06 7728.06 | 4592.06 0.0 551 0 | 1.94 0.19 39.21 0.02
3 1.80e+06 7728.06 | 1914.95 0.0 254 0 | 2.03 0.19 39.01 0.02
3 1.81e+06 7728.06 | 708.27 0.0 99 0 | 1.99 0.19 38.98 0.02
3 1.82e+06 7728.06 | 7678.90 1510.8 896 179 | 2.00 0.19 38.46 0.02
3 1.83e+06 7728.06 | 4612.89 0.0 554 0 | 2.05 0.20 40.58 0.02
3 1.84e+06 7728.06 | 5765.75 3283.5 670 370 | 2.01 0.19 39.72 0.02
3 1.85e+06 7728.06 | 5138.14 0.0 609 0 | 2.03 0.20 41.17 0.02
3 1.86e+06 7728.06 | 2317.73 0.0 282 0 | 2.04 0.19 39.38 0.02
3 1.87e+06 7728.06 | 4502.98 0.0 518 0 | 1.92 0.20 39.25 0.02
3 1.88e+06 7728.06 | 434.40 0.0 66 0 | 2.05 0.19 39.97 0.02
3 1.89e+06 7728.06 | 2278.33 0.0 304 0 | 1.99 0.19 40.53 0.02
3 1.90e+06 7728.06 | 1075.64 0.0 139 0 | 1.99 0.21 40.48 0.02
3 1.91e+06 7728.06 | 5303.26 1961.5 643 238 | 2.03 0.19 40.77 0.02
3 1.92e+06 7728.06 | 7610.01 1916.9 876 215 | 1.96 0.19 39.49 0.02
3 1.93e+06 7728.06 | 7504.85 1400.1 897 159 | 1.94 0.19 41.41 0.02
3 1.94e+06 7728.06 | 7434.55 1282.9 860 141 | 2.00 0.19 40.33 0.02
3 1.95e+06 7728.06 | 1779.93 0.0 215 0 | 2.07 0.19 40.77 0.02
3 1.96e+06 7728.06 | 525.02 0.0 76 0 | 2.04 0.20 41.53 0.02
3 1.97e+06 7728.06 | 459.73 0.0 71 0 | 2.06 0.19 39.72 0.02
3 1.98e+06 7728.06 | 4457.85 4074.2 524 466 | 2.05 0.19 42.10 0.02
3 1.99e+06 7728.06 | 6060.01 2013.8 717 224 | 2.02 0.19 41.74 0.02
3 2.00e+06 7728.06 | 3763.48 0.0 434 0 | 1.99 0.19 42.00 0.02
3 2.01e+06 7728.06 | 2920.24 3370.0 346 379 | 2.00 0.20 40.89 0.02
3 2.03e+06 7728.06 | 5806.59 0.0 662 0 | 2.05 0.19 42.19 0.02
3 2.03e+06 7728.06 | 6983.07 3317.2 789 365 | 2.07 0.20 41.56 0.02
3 2.05e+06 7728.06 | 2810.41 0.0 331 0 | 2.06 0.20 41.36 0.02
3 2.06e+06 7728.06 | 7325.62 1785.0 814 193 | 2.04 0.19 42.16 0.02
3 2.07e+06 7728.06 | 5472.22 0.0 624 0 | 2.08 0.19 41.91 0.02
3 2.08e+06 7728.06 | 5224.22 2573.9 596 285 | 2.06 0.20 42.81 0.02
3 2.08e+06 7728.06 | 3663.78 0.0 424 0 | 2.04 0.20 41.13 0.02
3 2.09e+06 7788.26 |
3 2.09e+06 7788.26 | 7788.26 1759.1 876 189 | 2.00 0.19 41.34 0.02
3 2.10e+06 7830.41 |
3 2.10e+06 7830.41 | 7830.41 1640.3 890 190 | 2.11 0.19 43.17 0.02
3 2.11e+06 7830.41 | 2744.79 0.0 334 0 | 2.07 0.20 41.95 0.02
3 2.12e+06 7830.41 | 338.01 0.0 52 0 | 2.08 0.19 43.14 0.02
3 2.13e+06 7830.41 | 378.62 0.0 57 0 | 1.95 0.19 41.59 0.02
3 2.14e+06 7830.41 | 193.63 0.0 34 0 | 1.88 0.19 42.16 0.02
3 2.15e+06 8726.12 |
3 2.15e+06 8726.12 | 8726.12 592.7 966 58 | 2.12 0.19 43.00 0.02
3 2.16e+06 8726.12 | 180.76 0.0 31 0 | 2.09 0.18 41.18 0.02
3 2.17e+06 8726.12 | 5604.62 3839.7 616 407 | 2.10 0.19 43.04 0.02
3 2.18e+06 8726.12 | 8339.71 0.0 932 0 | 2.09 0.19 42.43 0.02
3 2.20e+06 8726.12 | 2646.60 0.0 300 0 | 2.11 0.18 44.49 0.02
3 2.20e+06 8726.12 | 5454.00 2853.0 618 313 | 1.92 0.19 43.55 0.02
3 2.21e+06 8726.12 | 4760.50 0.0 523 0 | 1.93 0.19 42.93 0.02
3 2.22e+06 9094.07 |
3 2.22e+06 9094.07 | 9094.07 80.9 1000 0 | 2.10 0.18 43.27 0.02
3 2.23e+06 9094.07 | 6217.18 0.0 674 0 | 2.03 0.19 44.04 0.02
3 2.24e+06 9094.07 | 8890.46 0.0 1000 0 | 2.19 0.18 44.23 0.02
3 2.25e+06 9400.97 |
3 2.25e+06 9400.97 | 9400.97 79.1 1000 0 | 2.12 0.18 44.17 0.02
3 2.26e+06 9400.97 | 9185.07 0.0 1000 0 | 2.20 0.18 43.76 0.02
3 2.27e+06 9400.97 | 9208.88 0.0 1000 0 | 2.01 0.18 44.20 0.02
3 2.28e+06 9400.97 | 8215.99 1686.5 900 173 | 2.21 0.18 43.55 0.02
3 2.29e+06 9400.97 | 7827.44 0.0 840 0 | 2.21 0.19 43.74 0.02
3 2.30e+06 9400.97 | 567.31 0.0 78 0 | 2.18 0.18 44.26 0.02
3 2.31e+06 9400.97 | 4230.70 0.0 468 0 | 2.07 0.18 44.48 0.02
3 2.32e+06 9400.97 | 336.20 0.0 52 0 | 2.03 0.19 44.77 0.02
3 2.33e+06 9400.97 | 9327.56 0.0 1000 0 | 1.94 0.19 44.30 0.02
3 2.34e+06 9400.97 | 2688.67 3918.1 296 409 | 2.09 0.18 45.14 0.02
3 2.35e+06 9400.97 | 270.88 0.0 43 0 | 2.09 0.18 44.38 0.02
3 2.36e+06 9400.97 | 4219.46 0.0 457 0 | 2.10 0.18 46.13 0.02
3 2.37e+06 9400.97 | 934.99 0.0 118 0 | 2.09 0.19 45.69 0.02
3 2.38e+06 9400.97 | 9338.99 0.0 1000 0 | 2.06 0.18 45.48 0.02
3 2.39e+06 9400.97 | 5507.83 0.0 584 0 | 1.92 0.18 46.07 0.02
3 2.40e+06 9400.97 | 3810.83 0.0 412 0 | 1.90 0.19 44.47 0.02
3 2.41e+06 9400.97 | 4665.77 0.0 506 0 | 1.99 0.18 45.91 0.02
3 2.42e+06 9400.97 | 1511.40 0.0 174 0 | 1.95 0.18 46.20 0.02
3 2.42e+06 9400.97 | 2301.35 0.0 255 0 | 1.97 0.18 46.06 0.02
3 2.43e+06 9400.97 | 1289.04 0.0 157 0 | 2.14 0.18 46.75 0.02
3 2.44e+06 9400.97 | 3766.25 0.0 425 0 | 2.09 0.18 46.02 0.02
3 2.45e+06 9400.97 | 1576.04 0.0 188 0 | 2.18 0.18 46.27 0.02
3 2.46e+06 9400.97 | 338.50 0.0 51 0 | 2.21 0.19 46.15 0.02
3 2.47e+06 9400.97 | 1363.64 0.0 162 0 | 2.02 0.19 46.61 0.02
3 2.48e+06 9400.97 | 2311.31 0.0 260 0 | 2.12 0.20 47.16 0.02
3 2.49e+06 9400.97 | 1103.78 0.0 138 0 | 2.30 0.19 46.52 0.02
3 2.50e+06 9400.97 | 1327.52 0.0 156 0 | 2.16 0.19 45.45 0.02
3 2.51e+06 9400.97 | 6124.39 2098.5 640 210 | 2.23 0.19 47.28 0.02
3 2.52e+06 9400.97 | 3947.05 0.0 427 0 | 2.23 0.20 47.51 0.02
3 2.53e+06 9400.97 | 365.90 0.0 55 0 | 2.26 0.18 47.74 0.02
3 2.54e+06 9400.97 | 3208.60 0.0 341 0 | 1.93 0.19 48.40 0.02
3 2.55e+06 9400.97 | 7360.38 2959.7 748 289 | 2.12 0.18 47.52 0.02
3 2.56e+06 9400.97 | 6598.35 2526.5 693 255 | 2.25 0.20 47.14 0.02
3 2.57e+06 9400.97 | 4869.49 4685.1 516 484 | 2.32 0.20 47.71 0.02
3 2.58e+06 9400.97 | 8345.87 2688.1 847 265 | 2.25 0.20 48.28 0.02
3 2.59e+06 9400.97 | 2920.38 0.0 314 0 | 2.28 0.19 47.91 0.02
3 2.60e+06 9400.97 | 5261.52 0.0 550 0 | 2.27 0.19 48.32 0.02
3 2.60e+06 9400.97 | 2043.06 0.0 223 0 | 2.21 0.20 48.21 0.02
3 2.61e+06 9400.97 | 4010.91 0.0 433 0 | 2.10 0.20 48.61 0.02
3 2.62e+06 9400.97 | 3848.38 0.0 408 0 | 2.30 0.20 48.81 0.02
3 2.63e+06 9400.97 | 389.13 0.0 58 0 | 2.29 0.19 47.63 0.02
3 2.64e+06 9400.97 | 365.81 0.0 54 0 | 2.16 0.20 48.71 0.02
3 2.65e+06 9400.97 | 3056.22 0.0 328 0 | 2.31 0.20 48.48 0.02
3 2.66e+06 9400.97 | 889.49 0.0 111 0 | 2.08 0.19 48.70 0.02
3 2.67e+06 9400.97 | 165.39 0.0 29 0 | 2.20 0.19 48.89 0.02
3 2.68e+06 9400.97 | 3100.69 0.0 360 0 | 2.08 0.21 49.12 0.02
3 2.68e+06 9400.97 | 498.45 0.0 69 0 | 2.28 0.20 49.01 0.02
3 2.69e+06 9400.97 | 1110.05 0.0 131 0 | 1.95 0.20 48.85 0.02
3 2.70e+06 9400.97 | 3564.61 0.0 367 0 | 2.09 0.20 49.62 0.02
3 2.71e+06 9400.97 | 3891.63 0.0 418 0 | 2.23 0.20 49.66 0.02
3 2.72e+06 9400.97 | 3446.70 0.0 368 0 | 2.19 0.20 50.11 0.02
3 2.73e+06 9400.97 | 2262.99 0.0 240 0 | 2.12 0.21 50.37 0.02
3 2.74e+06 9400.97 | 316.87 0.0 48 0 | 2.09 0.21 49.94 0.02
3 2.75e+06 9400.97 | 8746.19 0.0 877 0 | 2.02 0.21 49.60 0.02
3 2.76e+06 9400.97 | 2905.47 0.0 312 0 | 2.29 0.22 49.86 0.02
3 2.76e+06 9400.97 | 3270.80 0.0 336 0 | 2.07 0.20 50.74 0.02
3 2.77e+06 9400.97 | 2539.63 0.0 265 0 | 2.19 0.22 48.64 0.02
3 2.78e+06 9400.97 | 5086.21 0.0 524 0 | 2.23 0.21 50.41 0.02
3 2.79e+06 9400.97 | 6139.51 0.0 612 0 | 2.38 0.22 51.37 0.02
3 2.80e+06 9400.97 | 1076.67 0.0 128 0 | 2.20 0.22 49.96 0.02
3 2.81e+06 9400.97 | 7106.03 0.0 682 0 | 2.12 0.20 50.93 0.02
3 2.82e+06 9400.97 | 828.86 0.0 103 0 | 2.27 0.21 50.35 0.02
3 2.83e+06 9400.97 | 2867.47 0.0 300 0 | 2.06 0.21 50.02 0.02
3 2.84e+06 9400.97 | 439.11 0.0 62 0 | 2.29 0.21 51.19 0.02
3 2.85e+06 9400.97 | 4167.51 0.0 421 0 | 2.19 0.20 50.30 0.02
3 2.85e+06 9400.97 | 2720.88 0.0 279 0 | 2.19 0.21 51.17 0.02
3 2.86e+06 9400.97 | 3175.01 0.0 323 0 | 2.24 0.22 50.80 0.02
3 2.87e+06 9400.97 | 1955.77 0.0 211 0 | 2.06 0.22 50.54 0.02
3 2.88e+06 9400.97 | 3316.37 0.0 341 0 | 2.13 0.21 50.84 0.02
3 2.89e+06 9400.97 | 722.73 0.0 108 0 | 2.22 0.26 52.52 0.02
3 2.90e+06 9400.97 | 189.10 0.0 37 0 | 1.33 0.23 51.74 0.02
3 2.91e+06 9400.97 | 2395.07 0.0 252 0 | 1.88 0.22 51.33 0.02
3 2.92e+06 9400.97 | 2206.58 0.0 238 0 | 2.04 0.21 52.45 0.02
3 2.93e+06 9400.97 | 260.01 0.0 42 0 | 2.14 0.21 50.83 0.02
3 2.93e+06 9400.97 | 9167.51 0.0 892 0 | 2.11 0.22 52.46 0.02
3 2.94e+06 9400.97 | 2142.60 0.0 235 0 | 2.14 0.21 51.50 0.02
3 2.95e+06 9400.97 | 663.20 0.0 85 0 | 2.32 0.22 51.99 0.02
3 2.96e+06 9400.97 | 6153.73 0.0 614 0 | 2.20 0.21 52.28 0.02
3 2.97e+06 9400.97 | 1746.93 0.0 184 0 | 2.33 0.22 52.50 0.02
3 2.98e+06 9400.97 | 4008.55 0.0 411 0 | 2.14 0.22 51.22 0.02
3 2.99e+06 9400.97 | 323.49 0.0 49 0 | 2.23 0.23 52.69 0.02
3 3.00e+06 9400.97 | 6496.10 0.0 629 0 | 2.28 0.24 52.76 0.02
3 3.01e+06 9400.97 | 839.82 0.0 103 0 | 2.35 0.23 52.15 0.02
3 3.02e+06 9400.97 | 6746.13 3928.6 648 359 | 2.22 0.23 52.27 0.02
3 3.02e+06 9400.97 | 2614.53 0.0 273 0 | 2.40 0.21 51.97 0.02
3 3.03e+06 9400.97 | 6482.44 2960.4 632 274 | 2.29 0.22 52.42 0.02
3 3.04e+06 9400.97 | 2710.71 0.0 272 0 | 2.38 0.23 53.30 0.02
3 3.05e+06 9400.97 | 2630.47 0.0 279 0 | 2.26 0.22 52.33 0.02
3 3.06e+06 9400.97 | 6490.97 0.0 627 0 | 2.41 0.22 53.16 0.02
3 3.07e+06 9400.97 | 5756.57 3020.6 558 278 | 2.20 0.21 53.43 0.02
3 3.08e+06 9400.97 | 2955.34 0.0 301 0 | 2.42 0.22 53.79 0.02
3 3.09e+06 9400.97 | 545.33 0.0 74 0 | 2.27 0.23 52.33 0.02
3 3.10e+06 9400.97 | 2198.62 0.0 229 0 | 2.35 0.22 53.38 0.02
3 3.11e+06 9400.97 | 3655.70 0.0 362 0 | 2.25 0.22 53.73 0.02
3 3.12e+06 9400.97 | 7572.88 0.0 688 0 | 2.40 0.23 53.36 0.02
3 3.13e+06 9400.97 | 686.92 0.0 88 0 | 2.31 0.25 53.30 0.02
3 3.14e+06 9400.97 | 4784.15 0.0 470 0 | 2.34 0.22 53.50 0.02
3 3.15e+06 9400.97 | 6257.92 0.0 597 0 | 2.40 0.23 54.19 0.02
3 3.16e+06 9400.97 | 381.11 0.0 56 0 | 2.55 0.22 54.06 0.02
3 3.17e+06 9400.97 | 4226.98 0.0 408 0 | 2.36 0.23 53.91 0.02
3 3.18e+06 9400.97 | 4583.93 0.0 446 0 | 2.33 0.23 54.37 0.02
3 3.19e+06 9400.97 | 6077.15 3476.0 576 311 | 2.27 0.24 54.81 0.02
3 3.20e+06 9400.97 | 5583.01 3175.2 534 278 | 2.34 0.22 54.06 0.02
3 3.21e+06 9400.97 | 6684.09 2633.0 644 234 | 2.33 0.25 54.21 0.02
3 3.22e+06 9400.97 | 2594.13 0.0 277 0 | 2.45 0.24 54.45 0.02
3 3.23e+06 9400.97 | 3951.93 0.0 381 0 | 2.39 0.23 54.81 0.02
3 3.24e+06 9400.97 | 6620.14 0.0 618 0 | 2.37 0.23 54.77 0.02
3 3.24e+06 9400.97 | 3264.37 0.0 323 0 | 2.38 0.25 55.88 0.02
3 3.25e+06 9400.97 | 3717.48 0.0 369 0 | 2.28 0.23 54.36 0.02
3 3.26e+06 9400.97 | 6228.22 3159.0 590 283 | 2.39 0.24 55.27 0.02
3 3.27e+06 9400.97 | 3191.35 0.0 313 0 | 2.42 0.25 53.25 0.02
3 3.28e+06 9400.97 | 6677.04 0.0 652 0 | 2.38 0.24 56.30 0.02
3 3.29e+06 9400.97 | 1202.97 0.0 135 0 | 2.34 0.23 55.98 0.02
3 3.30e+06 9400.97 | 3834.14 0.0 378 0 | 2.26 0.23 55.60 0.02
3 3.31e+06 9400.97 | 7547.63 0.0 715 0 | 2.28 0.25 56.10 0.02
3 3.32e+06 9400.97 | 3160.17 0.0 305 0 | 2.39 0.25 55.70 0.02
3 3.33e+06 9400.97 | 3366.77 0.0 330 0 | 2.20 0.26 56.55 0.02
3 3.34e+06 9400.97 | 2180.08 0.0 226 0 | 2.51 0.25 55.42 0.02
3 3.35e+06 9400.97 | 4012.17 3974.3 392 356 | 2.43 0.26 55.38 0.02
3 3.35e+06 9400.97 | 2136.97 0.0 221 0 | 2.27 0.25 56.35 0.02
3 3.36e+06 9400.97 | 2565.83 0.0 254 0 | 2.27 0.24 56.11 0.02
3 3.38e+06 9400.97 | 1909.27 0.0 205 0 | 2.47 0.25 56.66 0.02
3 3.38e+06 9400.97 | 4336.54 0.0 418 0 | 2.46 0.26 56.28 0.02
3 3.39e+06 9400.97 | 5321.48 3593.4 494 307 | 2.40 0.25 56.29 0.02
3 3.40e+06 9400.97 | 2623.19 0.0 280 0 | 2.33 0.24 56.03 0.02
3 3.41e+06 9400.97 | 4583.58 0.0 446 0 | 2.37 0.26 56.75 0.02
3 3.42e+06 9400.97 | 2202.31 0.0 234 0 | 2.39 0.25 56.72 0.02
3 3.43e+06 9400.97 | 4711.35 0.0 450 0 | 2.34 0.25 57.02 0.02
3 3.44e+06 9400.97 | 222.00 0.0 36 0 | 2.40 0.26 57.51 0.02
3 3.45e+06 9400.97 | 583.82 0.0 95 0 | 2.51 0.32 60.83 0.03
3 3.46e+06 9400.97 | 1659.08 0.0 180 0 | 1.55 0.24 57.01 0.02
3 3.47e+06 9400.97 | 4795.89 0.0 475 0 | 2.46 0.25 56.82 0.02
3 3.48e+06 9400.97 | 3277.17 0.0 314 0 | 2.45 0.26 56.12 0.02
3 3.49e+06 9400.97 | 6135.82 2896.6 584 257 | 2.48 0.26 57.23 0.02
3 3.50e+06 9400.97 | 2316.13 0.0 239 0 | 2.48 0.24 56.64 0.02
3 3.51e+06 9400.97 | 2459.48 0.0 243 0 | 2.46 0.26 57.63 0.02
3 3.52e+06 9400.97 | 545.49 0.0 72 0 | 2.42 0.27 57.16 0.02
3 3.53e+06 9400.97 | 3056.77 0.0 315 0 | 2.49 0.26 56.49 0.02
3 3.54e+06 9400.97 | 3525.36 0.0 334 0 | 2.51 0.26 56.60 0.02
3 3.55e+06 9400.97 | 448.69 0.0 62 0 | 2.40 0.25 57.04 0.02
3 3.56e+06 9400.97 | 4425.29 0.0 417 0 | 2.46 0.25 58.06 0.02
3 3.57e+06 9400.97 | 7055.81 0.0 647 0 | 2.42 0.25 56.89 0.02
3 3.58e+06 9400.97 | 3547.77 0.0 343 0 | 2.40 0.24 57.90 0.02
3 3.59e+06 9400.97 | 1214.78 0.0 140 0 | 2.51 0.27 57.81 0.02
3 3.60e+06 9400.97 | 1943.99 0.0 203 0 | 2.43 0.26 57.63 0.02
3 3.60e+06 9400.97 | 2539.23 0.0 255 0 | 2.46 0.24 57.93 0.02
3 3.61e+06 9400.97 | 5755.68 0.0 533 0 | 2.44 0.27 57.88 0.02
3 3.62e+06 9400.97 | 521.56 0.0 69 0 | 2.38 0.25 57.91 0.02
3 3.63e+06 9400.97 | 2260.82 0.0 224 0 | 2.49 0.26 57.59 0.02
3 3.64e+06 9400.97 | 8032.42 3036.8 733 268 | 2.35 0.26 57.60 0.02
3 3.65e+06 9400.97 | 5434.70 0.0 494 0 | 2.45 0.27 58.28 0.02
3 3.66e+06 9400.97 | 3497.88 0.0 334 0 | 2.29 0.26 57.95 0.02
3 3.67e+06 9400.97 | 5385.06 0.0 530 0 | 2.36 0.27 58.82 0.02
3 3.68e+06 9400.97 | 7716.17 0.0 712 0 | 2.38 0.24 58.36 0.02
3 3.69e+06 9400.97 | 7525.99 0.0 678 0 | 2.33 0.27 57.81 0.02
3 3.70e+06 9400.97 | 970.74 0.0 115 0 | 2.51 0.26 58.44 0.02
3 3.71e+06 9400.97 | 3055.52 0.0 303 0 | 2.47 0.27 59.08 0.02
3 3.72e+06 9400.97 | 6156.14 0.0 593 0 | 2.51 0.27 58.46 0.02
3 3.73e+06 9400.97 | 757.89 0.0 93 0 | 2.50 0.25 58.00 0.02
3 3.74e+06 9400.97 | 2969.20 0.0 291 0 | 2.45 0.26 59.13 0.02
3 3.75e+06 9400.97 | 6579.89 3733.9 612 332 | 2.49 0.26 59.74 0.02
3 3.76e+06 9400.97 | 4382.62 4036.6 412 359 | 2.47 0.27 58.02 0.02
3 3.77e+06 9400.97 | 6604.70 0.0 627 0 | 2.61 0.25 58.69 0.02
3 3.78e+06 9400.97 | 4470.17 3493.4 428 324 | 2.51 0.25 58.66 0.02
3 3.79e+06 9400.97 | 873.06 0.0 108 0 | 2.45 0.26 58.98 0.02
3 3.80e+06 9400.97 | 3919.33 0.0 369 0 | 2.54 0.28 58.55 0.02
3 3.81e+06 9400.97 | 8246.80 4263.3 739 365 | 2.47 0.28 59.17 0.02
3 3.82e+06 9400.97 | 5343.21 0.0 497 0 | 2.50 0.27 59.11 0.02
3 3.83e+06 9400.97 | 3814.69 0.0 364 0 | 2.57 0.27 59.73 0.02
3 3.84e+06 9400.97 | 206.73 0.0 41 0 | 2.46 0.28 59.52 0.02
3 3.85e+06 9400.97 | 1580.95 0.0 165 0 | 1.89 0.26 58.67 0.02
3 3.86e+06 9400.97 | 8301.75 0.0 744 0 | 2.23 0.27 58.73 0.02
3 3.87e+06 9400.97 | 5613.82 4133.1 514 350 | 2.58 0.26 59.09 0.02
3 3.88e+06 9400.97 | 2753.20 0.0 268 0 | 2.60 0.27 59.82 0.02
3 3.89e+06 9400.97 | 3457.35 0.0 327 0 | 2.55 0.28 59.33 0.02
3 3.90e+06 9400.97 | 174.46 0.0 30 0 | 2.48 0.27 59.32 0.02
3 3.91e+06 9400.97 | 428.61 0.0 60 0 | 2.57 0.28 58.55 0.02
3 3.92e+06 9400.97 | 6091.70 0.0 554 0 | 2.56 0.26 60.11 0.02
3 3.93e+06 9400.97 | 7670.87 0.0 710 0 | 2.66 0.28 60.68 0.02
3 3.94e+06 9400.97 | 2778.81 0.0 276 0 | 2.15 0.27 60.50 0.02
3 3.95e+06 9400.97 | 6145.78 0.0 570 0 | 2.58 0.27 59.34 0.02
3 3.96e+06 9400.97 | 6133.93 0.0 551 0 | 2.53 0.27 59.78 0.02
3 3.97e+06 9400.97 | 4161.56 0.0 388 0 | 2.58 0.27 60.53 0.02
3 3.98e+06 9400.97 | 3202.24 0.0 306 0 | 2.47 0.28 59.90 0.02
3 3.99e+06 9400.97 | 5751.28 3699.0 526 318 | 2.62 0.28 60.64 0.02
3 4.00e+06 9400.97 | 9008.62 0.0 876 0 | 2.64 0.27 60.58 0.02
| UsedTime: 49475 | SavedDir: ./Humanoid-v3_ReliableSAC_3
| Learner: Save in ./Humanoid-v3_ReliableSAC_3
"""
elif env_name == 'Humanoid-v3.8140':
from elegantrl.envs.CustomGymEnv import HumanoidEnv
env_func = HumanoidEnv
env_args = {
'env_num': 1,
'env_name': 'Humanoid-v3',
'max_step': 1000,
'state_dim': 376,
'action_dim': 17,
'if_discrete': False,
'target_return': 3000.,
}
args = Arguments(agent, env_func=env_func, env_args=env_args)
args.eval_times = 2 ** 2
args.reward_scale = 2 ** -2
args.max_memo = int(2 ** 21 * 1.5)
args.learning_rate = 2 ** -14
args.lambda_a_log_std = 2 ** -6
args.target_step = args.max_step
args.worker_num = 4
args.net_dim = 2 ** 9
args.batch_size = args.net_dim // 2
args.gamma = 0.985
args.num_layer = 3
args.repeat_times = 2 ** 0
args.if_act_target = False
import numpy as np
args.target_entropy = np.log(env_args['action_dim']) # todo
args.if_allow_break = False
args.break_step = int(4e6)
"""
| Arguments Remove cwd: ./Humanoid-v3_ReliableSAC_2
################################################################################
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
2 8.10e+03 90.78 |
2 8.10e+03 90.78 | 90.78 9.5 18 2 | 1.20 0.69 2.78 0.06
2 1.14e+05 227.95 |
2 1.14e+05 227.95 | 227.95 8.4 44 2 | 1.27 0.79 26.12 0.04
2 1.76e+05 240.13 |
2 1.76e+05 240.13 | 240.13 10.1 45 2 | 1.32 0.77 33.01 0.02
2 2.26e+05 264.62 |
2 2.26e+05 264.62 | 264.62 20.5 49 3 | 1.34 0.63 32.48 0.02
2 2.67e+05 264.62 | 219.66 0.0 42 0 | 1.34 0.53 28.57 0.02
2 3.04e+05 341.61 |
2 3.04e+05 341.61 | 341.61 25.4 64 4 | 1.33 0.39 25.56 0.02
2 3.37e+05 341.61 | 260.65 0.0 55 0 | 1.32 0.32 25.71 0.01
2 3.66e+05 413.34 |
2 3.66e+05 413.34 | 413.34 40.6 78 8 | 1.30 0.30 26.26 0.01
2 3.91e+05 413.34 | 278.77 0.0 53 0 | 1.34 0.27 26.03 0.01
2 4.16e+05 413.34 | 274.65 0.0 54 0 | 1.35 0.25 26.42 0.01
2 4.41e+05 557.19 |
2 4.41e+05 557.19 | 557.19 107.9 108 16 | 1.35 0.24 25.52 0.01
2 4.66e+05 557.19 | 392.51 0.0 73 0 | 1.32 0.22 25.35 0.01
2 4.87e+05 557.19 | 385.15 0.0 70 0 | 1.36 0.21 24.85 0.01
2 5.08e+05 557.19 | 426.10 0.0 79 0 | 1.32 0.21 25.51 0.01
2 5.29e+05 557.19 | 399.47 0.0 71 0 | 1.34 0.20 25.57 0.01
2 5.50e+05 557.19 | 385.00 0.0 71 0 | 1.36 0.19 25.35 0.01
2 5.71e+05 557.19 | 435.28 0.0 76 0 | 1.36 0.19 25.96 0.01
2 5.87e+05 557.19 | 466.93 0.0 84 0 | 1.34 0.19 25.93 0.01
2 6.04e+05 557.19 | 470.94 0.0 84 0 | 1.39 0.18 26.30 0.01
2 6.21e+05 557.19 | 402.99 0.0 72 0 | 1.37 0.19 25.32 0.01
2 6.37e+05 557.19 | 385.18 0.0 67 0 | 1.39 0.18 26.13 0.01
2 6.54e+05 557.19 | 524.94 0.0 95 0 | 1.41 0.18 26.40 0.01
2 6.70e+05 557.19 | 540.23 0.0 95 0 | 1.38 0.17 27.68 0.01
2 6.87e+05 557.19 | 422.21 0.0 75 0 | 1.40 0.18 28.46 0.01
2 7.04e+05 557.19 | 291.22 0.0 55 0 | 1.40 0.17 27.04 0.01
2 7.21e+05 557.19 | 373.98 0.0 66 0 | 1.38 0.17 27.55 0.01
2 7.38e+05 557.19 | 531.67 83.8 95 15 | 1.36 0.17 27.87 0.01
2 7.54e+05 557.19 | 411.16 0.0 73 0 | 1.38 0.17 27.85 0.01
2 7.72e+05 663.21 |
2 7.72e+05 663.21 | 663.21 186.4 119 30 | 1.40 0.17 28.84 0.01
2 7.84e+05 663.21 | 530.18 0.0 94 0 | 1.39 0.17 27.86 0.01
2 7.97e+05 663.21 | 537.98 0.0 96 0 | 1.41 0.17 29.90 0.01
2 8.10e+05 765.51 |
2 8.10e+05 765.51 | 765.51 74.8 133 16 | 1.38 0.18 28.83 0.02
2 8.23e+05 765.51 | 746.94 0.0 132 0 | 1.38 0.16 28.68 0.02
2 8.36e+05 765.51 | 644.94 0.0 116 0 | 1.38 0.17 29.29 0.02
2 8.49e+05 765.51 | 754.08 0.0 126 0 | 1.39 0.17 28.72 0.02
2 8.62e+05 765.51 | 503.48 0.0 94 0 | 1.41 0.18 29.79 0.02
2 8.75e+05 765.51 | 537.22 0.0 99 0 | 1.44 0.18 30.48 0.02
2 8.87e+05 765.51 | 659.88 0.0 111 0 | 1.43 0.18 29.34 0.02
2 9.00e+05 765.51 | 761.09 177.9 129 28 | 1.46 0.18 30.42 0.02
2 9.13e+05 765.51 | 613.23 0.0 106 0 | 1.46 0.17 31.09 0.02
2 9.26e+05 1038.18 |
2 9.26e+05 1038.18 | 1038.18 227.4 177 34 | 1.45 0.17 29.79 0.02
2 9.39e+05 1038.18 | 915.45 311.8 154 51 | 1.44 0.17 30.75 0.02
2 9.52e+05 1038.18 | 695.13 0.0 119 0 | 1.49 0.18 30.36 0.02
2 9.65e+05 1038.18 | 646.47 0.0 118 0 | 1.50 0.18 30.80 0.02
2 9.78e+05 1038.18 | 974.30 299.1 163 49 | 1.48 0.18 30.86 0.02
2 9.91e+05 1038.18 | 604.55 0.0 103 0 | 1.49 0.18 31.58 0.02
2 1.00e+06 1038.18 | 922.67 0.0 152 0 | 1.48 0.18 30.21 0.02
2 1.02e+06 1038.18 | 673.91 0.0 106 0 | 1.50 0.18 31.29 0.02
2 1.03e+06 1038.18 | 982.81 297.8 160 49 | 1.52 0.18 31.76 0.02
2 1.04e+06 1038.18 | 855.41 0.0 136 0 | 1.53 0.18 32.46 0.02
2 1.06e+06 1824.70 |
2 1.06e+06 1824.70 | 1824.70 704.9 285 105 | 1.53 0.19 32.25 0.02
2 1.07e+06 1824.70 | 1319.13 0.0 207 0 | 1.53 0.18 32.58 0.02
2 1.08e+06 1824.70 | 1672.06 0.0 267 0 | 1.52 0.19 32.78 0.02
2 1.10e+06 1824.70 | 1325.30 0.0 207 0 | 1.58 0.19 33.83 0.02
2 1.11e+06 1824.70 | 1457.98 470.0 224 71 | 1.59 0.19 32.09 0.02
2 1.13e+06 1881.31 |
2 1.13e+06 1881.31 | 1881.31 714.1 289 100 | 1.58 0.19 34.07 0.02
2 1.14e+06 1881.31 | 1377.06 0.0 215 0 | 1.59 0.19 32.81 0.02
2 1.15e+06 1881.31 | 1335.53 0.0 205 0 | 1.63 0.19 32.02 0.02
2 1.17e+06 2130.46 |
2 1.17e+06 2130.46 | 2130.46 873.7 320 127 | 1.57 0.20 32.94 0.02
2 1.18e+06 2130.46 | 2002.78 0.0 292 0 | 1.59 0.20 34.26 0.02
2 1.19e+06 2130.46 | 1118.43 0.0 172 0 | 1.61 0.19 33.04 0.02
2 1.20e+06 2130.46 | 1210.14 0.0 187 0 | 1.62 0.19 34.59 0.02
2 1.21e+06 2130.46 | 889.89 0.0 139 0 | 1.66 0.19 34.45 0.02
2 1.22e+06 2211.02 |
2 1.22e+06 2211.02 | 2211.02 1027.2 336 144 | 1.62 0.19 33.81 0.02
2 1.23e+06 2211.02 | 955.95 0.0 149 0 | 1.67 0.19 34.10 0.02
2 1.24e+06 2211.02 | 1470.51 0.0 240 0 | 1.63 0.19 34.39 0.02
2 1.24e+06 2211.02 | 783.39 0.0 130 0 | 1.64 0.20 34.20 0.02
2 1.25e+06 2211.02 | 952.79 0.0 152 0 | 1.64 0.20 34.21 0.02
2 1.26e+06 2211.02 | 1436.46 0.0 230 0 | 1.63 0.20 34.65 0.02
2 1.27e+06 2211.02 | 1801.60 0.0 267 0 | 1.68 0.19 35.56 0.02
2 1.28e+06 4286.17 |
2 1.28e+06 4286.17 | 4286.17 2104.8 626 297 | 1.65 0.19 33.72 0.02
2 1.29e+06 4286.17 | 716.03 0.0 114 0 | 1.66 0.20 35.65 0.02
2 1.30e+06 4286.17 | 1972.81 0.0 300 0 | 1.66 0.19 35.24 0.02
2 1.31e+06 4286.17 | 1881.28 0.0 277 0 | 1.66 0.20 34.50 0.02
2 1.32e+06 4286.17 | 1420.99 0.0 213 0 | 1.67 0.19 35.51 0.02
2 1.33e+06 4286.17 | 2819.84 0.0 420 0 | 1.66 0.19 33.99 0.02
2 1.34e+06 4286.17 | 3262.76 0.0 466 0 | 1.66 0.19 35.15 0.02
2 1.35e+06 4286.17 | 4233.49 2461.5 600 332 | 1.71 0.19 34.08 0.02
2 1.36e+06 5612.00 |
2 1.36e+06 5612.00 | 5612.00 2030.8 778 275 | 1.69 0.19 35.28 0.02
2 1.37e+06 5612.00 | 1923.94 0.0 275 0 | 1.73 0.20 36.38 0.02
2 1.38e+06 5612.00 | 3570.13 2566.5 492 342 | 1.74 0.19 35.00 0.02
2 1.39e+06 5612.00 | 1569.53 0.0 219 0 | 1.67 0.20 35.52 0.02
2 1.40e+06 5612.00 | 2526.54 0.0 346 0 | 1.74 0.20 35.73 0.02
2 1.41e+06 7126.32 |
2 1.41e+06 7126.32 | 7126.32 249.9 980 35 | 1.70 0.20 36.92 0.02
2 1.42e+06 7126.32 | 463.55 0.0 74 0 | 1.74 0.19 36.85 0.02
2 1.43e+06 7126.32 | 5973.39 0.0 790 0 | 1.71 0.20 36.26 0.02
2 1.44e+06 7126.32 | 1466.78 0.0 207 0 | 1.74 0.20 37.44 0.02
2 1.45e+06 7126.32 | 5876.85 2582.9 800 346 | 1.78 0.19 37.04 0.02
2 1.46e+06 7331.79 |
2 1.46e+06 7331.79 | 7331.79 229.3 976 28 | 1.73 0.20 36.50 0.02
2 1.47e+06 7331.79 | 2664.43 0.0 366 0 | 1.76 0.19 37.18 0.02
2 1.48e+06 7331.79 | 1321.12 0.0 206 0 | 1.74 0.20 37.00 0.02
2 1.49e+06 7331.79 | 6368.94 2081.2 843 272 | 1.69 0.19 36.71 0.02
2 1.50e+06 7331.79 | 6667.05 876.8 887 118 | 1.79 0.20 37.61 0.02
2 1.51e+06 7331.79 | 5866.35 0.0 779 0 | 1.81 0.20 36.49 0.02
2 1.52e+06 7331.79 | 576.01 0.0 89 0 | 1.80 0.20 37.81 0.02
2 1.53e+06 7331.79 | 1688.60 0.0 233 0 | 1.77 0.20 37.29 0.02
2 1.54e+06 7331.79 | 5261.23 2435.0 700 319 | 1.77 0.20 37.64 0.02
2 1.55e+06 7331.79 | 5399.00 0.0 698 0 | 1.83 0.19 37.14 0.02
2 1.56e+06 7331.79 | 6157.42 1511.7 813 202 | 1.81 0.19 37.53 0.02
2 1.57e+06 7331.79 | 3162.86 0.0 410 0 | 1.82 0.19 37.39 0.02
2 1.58e+06 7331.79 | 3419.41 0.0 445 0 | 1.81 0.19 37.44 0.02
2 1.59e+06 7331.79 | 5282.29 0.0 709 0 | 1.83 0.20 37.65 0.02
2 1.59e+06 7331.79 | 445.82 0.0 73 0 | 1.75 0.19 37.69 0.02
2 1.60e+06 7331.79 | 5166.45 2919.7 662 364 | 1.75 0.20 37.73 0.02
2 1.61e+06 7331.79 | 1160.98 0.0 168 0 | 1.81 0.19 38.19 0.02
2 1.62e+06 7331.79 | 385.14 0.0 63 0 | 1.86 0.20 38.97 0.02
2 1.63e+06 7331.79 | 1296.00 0.0 177 0 | 1.76 0.20 38.75 0.02
2 1.64e+06 7331.79 | 3073.65 0.0 410 0 | 1.78 0.20 38.31 0.02
2 1.65e+06 7331.79 | 4470.72 0.0 591 0 | 1.81 0.20 39.00 0.02
2 1.66e+06 7331.79 | 333.14 0.0 56 0 | 1.79 0.20 39.33 0.02
2 1.67e+06 7331.79 | 5807.64 2430.3 741 302 | 1.85 0.19 37.65 0.02
2 1.68e+06 7331.79 | 4275.79 2694.9 561 335 | 1.89 0.19 39.04 0.02
2 1.69e+06 7331.79 | 1016.73 0.0 141 0 | 1.84 0.20 37.86 0.02
2 1.70e+06 7331.79 | 3605.95 0.0 471 0 | 1.77 0.20 38.81 0.02
2 1.71e+06 7331.79 | 736.54 0.0 107 0 | 1.83 0.20 39.10 0.02
2 1.72e+06 7331.79 | 996.17 0.0 141 0 | 1.74 0.20 38.28 0.02
2 1.73e+06 7331.79 | 4694.49 2852.3 600 358 | 1.85 0.20 38.42 0.02
2 1.74e+06 7331.79 | 2549.88 0.0 339 0 | 1.84 0.20 39.03 0.02
2 1.75e+06 7331.79 | 3115.12 0.0 396 0 | 1.76 0.20 40.11 0.02
2 1.76e+06 7331.79 | 1279.52 0.0 175 0 | 1.92 0.20 38.60 0.02
2 1.77e+06 7331.79 | 2957.39 0.0 386 0 | 1.84 0.20 40.33 0.02
2 1.78e+06 7331.79 | 1165.82 0.0 159 0 | 1.88 0.20 40.23 0.02
2 1.79e+06 7331.79 | 4275.53 0.0 520 0 | 1.86 0.20 39.45 0.02
2 1.80e+06 7331.79 | 5397.93 0.0 660 0 | 1.89 0.21 39.82 0.02
2 1.81e+06 7331.79 | 6072.07 0.0 738 0 | 1.91 0.21 37.96 0.02
2 1.82e+06 7331.79 | 2585.03 0.0 334 0 | 1.79 0.21 40.70 0.02
2 1.82e+06 7331.79 | 4416.40 2765.4 543 326 | 1.80 0.21 39.63 0.02
2 1.83e+06 7331.79 | 3399.75 0.0 432 0 | 1.88 0.21 40.33 0.02
2 1.84e+06 7331.79 | 6230.92 0.0 788 0 | 1.89 0.20 39.00 0.02
2 1.85e+06 7331.79 | 3259.26 0.0 410 0 | 1.87 0.21 40.84 0.02
2 1.86e+06 7331.79 | 1597.32 0.0 212 0 | 1.90 0.21 40.31 0.02
2 1.87e+06 7331.79 | 6815.74 1800.9 840 215 | 1.88 0.20 40.42 0.02
2 1.88e+06 7331.79 | 3414.72 0.0 436 0 | 1.93 0.20 40.98 0.02
2 1.89e+06 7331.79 | 571.97 0.0 87 0 | 1.84 0.21 41.38 0.02
2 1.90e+06 7331.79 | 3184.91 0.0 403 0 | 1.96 0.21 40.56 0.02
2 1.91e+06 8140.26 |
2 1.91e+06 8140.26 | 8140.26 84.2 1000 0 | 1.94 0.20 40.25 0.02
2 1.92e+06 8140.26 | 6630.22 0.0 803 0 | 1.91 0.21 42.25 0.02
2 1.93e+06 8140.26 | 5937.82 0.0 709 0 | 1.89 0.21 41.15 0.02
2 1.94e+06 8140.26 | 615.71 0.0 91 0 | 1.89 0.21 40.50 0.02
2 1.95e+06 8140.26 | 2642.54 0.0 355 0 | 2.01 0.22 40.92 0.02
2 1.96e+06 8140.26 | 1880.52 0.0 238 0 | 1.96 0.21 41.70 0.02
2 1.97e+06 8140.26 | 5411.17 0.0 644 0 | 1.91 0.21 40.88 0.02
2 1.98e+06 8140.26 | 3981.29 0.0 483 0 | 1.80 0.21 42.47 0.02
2 1.99e+06 8140.26 | 6557.22 3281.2 780 382 | 1.95 0.22 41.85 0.02
2 2.00e+06 8140.26 | 3041.03 0.0 371 0 | 1.91 0.21 41.13 0.02
"""
elif env_name == 'Humanoid-v3.8605.best':
from elegantrl.envs.CustomGymEnv import HumanoidEnv
env_func = HumanoidEnv
env_args = {
'env_num': 1,
'env_name': 'Humanoid-v3',
'max_step': 1000,
'state_dim': 376,
'action_dim': 17,
'if_discrete': False,
'target_return': 3000.,
}
args = Arguments(agent, env_func=env_func, env_args=env_args)
args.eval_times = 2 ** 2
args.reward_scale = 2 ** -2
args.max_memo = 2 ** 21
args.learning_rate = 2 ** -14
args.lambda_a_log_std = 2 ** -6
args.target_step = args.max_step
args.worker_num = 4
args.net_dim = 2 ** 9
args.batch_size = args.net_dim // 2
args.gamma = 0.985 # todo
args.num_layer = 3
args.repeat_times = 2 ** 0
args.if_act_target = False
import numpy as np
args.target_entropy = np.log(env_args['action_dim']) * 1.5 # todo
args.if_allow_break = False
args.break_step = int(2e6)
"""
| Arguments Remove cwd: ./Humanoid-v3_ReliableSAC_1
################################################################################
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
1 8.10e+03 110.28 |
1 8.10e+03 110.28 | 110.28 21.3 22 4 | 1.18 0.68 1.68 0.06
1 1.43e+05 316.51 |
1 1.43e+05 316.51 | 316.51 56.3 69 10 | 1.30 0.78 29.82 0.03
1 2.17e+05 316.51 | 255.03 0.0 48 0 | 1.33 0.67 33.83 0.02
1 2.71e+05 337.53 |
1 2.71e+05 337.53 | 337.53 16.6 61 3 | 1.32 0.50 28.05 0.02
1 3.16e+05 337.53 | 275.44 0.0 51 0 | 1.32 0.36 26.29 0.01
1 3.57e+05 337.53 | 265.05 0.0 49 0 | 1.30 0.31 24.74 0.01
1 3.94e+05 414.59 |
1 3.94e+05 414.59 | 414.59 53.0 80 9 | 1.31 0.27 25.89 0.01
1 4.27e+05 414.59 | 278.19 0.0 51 0 | 1.32 0.25 24.99 0.01
1 4.60e+05 542.04 |
1 4.60e+05 542.04 | 542.04 136.9 104 28 | 1.34 0.23 26.24 0.01
1 4.89e+05 542.04 | 519.01 0.0 95 0 | 1.32 0.22 25.69 0.01
1 5.18e+05 542.04 | 309.69 0.0 68 0 | 1.35 0.21 25.27 0.01
1 5.43e+05 542.04 | 305.88 0.0 58 0 | 1.30 0.20 25.49 0.01
1 5.68e+05 542.04 | 266.79 0.0 56 0 | 1.37 0.19 25.52 0.01
1 5.93e+05 542.04 | 378.07 0.0 71 0 | 1.35 0.19 26.46 0.01
1 6.18e+05 542.04 | 524.26 0.0 110 0 | 1.38 0.19 25.63 0.01
1 6.43e+05 542.04 | 488.47 0.0 86 0 | 1.37 0.18 25.97 0.01
1 6.64e+05 542.04 | 437.22 71.1 89 7 | 1.35 0.18 27.04 0.01
1 6.84e+05 542.04 | 530.90 0.0 97 0 | 1.37 0.18 27.17 0.01
1 7.05e+05 542.04 | 349.59 0.0 64 0 | 1.38 0.17 27.22 0.01
1 7.26e+05 542.04 | 388.24 0.0 70 0 | 1.35 0.18 27.55 0.01
1 7.47e+05 542.04 | 514.88 112.4 90 19 | 1.38 0.17 27.94 0.01
1 7.68e+05 608.88 |
1 7.68e+05 608.88 | 608.88 72.7 109 12 | 1.37 0.17 27.06 0.01
1 7.89e+05 608.88 | 524.12 0.0 96 0 | 1.37 0.17 27.96 0.01
1 8.10e+05 648.58 |
1 8.10e+05 648.58 | 648.58 84.8 118 19 | 1.35 0.17 28.42 0.01
1 8.27e+05 648.58 | 584.14 0.0 98 0 | 1.37 0.17 27.81 0.01
1 8.44e+05 648.58 | 616.88 0.0 103 0 | 1.35 0.16 29.21 0.01
1 8.61e+05 782.15 |
1 8.61e+05 782.15 | 782.15 41.1 136 12 | 1.40 0.17 27.39 0.02
1 8.78e+05 782.15 | 769.69 0.0 134 0 | 1.35 0.17 29.88 0.02
1 8.95e+05 782.15 | 773.94 0.0 137 0 | 1.40 0.17 28.86 0.02
1 9.12e+05 782.15 | 579.52 159.8 95 23 | 1.37 0.17 29.90 0.02
1 9.29e+05 782.15 | 368.24 0.0 64 0 | 1.38 0.17 29.71 0.02
1 9.46e+05 782.15 | 471.58 0.0 82 0 | 1.43 0.17 29.84 0.02
1 9.63e+05 977.21 |
1 9.63e+05 977.21 | 977.21 270.7 162 42 | 1.42 0.18 30.33 0.02
1 9.81e+05 977.21 | 856.29 0.0 162 0 | 1.45 0.18 30.16 0.02
1 9.98e+05 977.21 | 594.79 0.0 99 0 | 1.42 0.17 30.40 0.02
1 1.02e+06 977.21 | 729.72 0.0 130 0 | 1.46 0.17 30.52 0.02
1 1.03e+06 977.21 | 798.60 0.0 151 0 | 1.46 0.18 30.56 0.02
1 1.05e+06 1243.32 |
1 1.05e+06 1243.32 | 1243.32 129.2 213 27 | 1.43 0.18 31.40 0.02
1 1.07e+06 1243.32 | 1213.14 0.0 199 0 | 1.49 0.18 32.20 0.02
1 1.09e+06 1243.32 | 752.98 0.0 139 0 | 1.47 0.18 31.79 0.02
1 1.10e+06 1243.32 | 788.21 0.0 148 0 | 1.49 0.18 30.92 0.02
1 1.11e+06 1243.32 | 806.23 0.0 133 0 | 1.49 0.18 31.74 0.02
1 1.12e+06 1284.78 |
1 1.12e+06 1284.78 | 1284.78 212.0 207 38 | 1.48 0.18 31.87 0.02
1 1.14e+06 1284.78 | 682.50 0.0 113 0 | 1.50 0.18 32.15 0.02
1 1.15e+06 1284.78 | 468.61 0.0 81 0 | 1.51 0.18 32.10 0.02
1 1.16e+06 1284.78 | 986.22 0.0 174 0 | 1.51 0.18 32.51 0.02
1 1.18e+06 1284.78 | 933.67 0.0 172 0 | 1.54 0.18 31.68 0.02
1 1.19e+06 1284.78 | 1189.34 202.8 195 24 | 1.58 0.18 32.28 0.02
1 1.20e+06 1284.78 | 1183.09 0.0 197 0 | 1.54 0.18 33.36 0.02
1 1.22e+06 1284.78 | 1135.20 0.0 188 0 | 1.53 0.18 31.78 0.02
1 1.23e+06 1284.78 | 1147.86 0.0 183 0 | 1.61 0.19 34.01 0.02
1 1.25e+06 1284.78 | 1251.78 0.0 225 0 | 1.56 0.18 34.35 0.02
1 1.26e+06 2821.26 |
1 1.26e+06 2821.26 | 2821.26 412.2 429 55 | 1.55 0.18 33.30 0.02
1 1.27e+06 2821.26 | 1078.30 0.0 171 0 | 1.59 0.18 33.66 0.02
1 1.29e+06 2821.26 | 2256.06 1179.8 350 166 | 1.61 0.18 33.90 0.02
1 1.30e+06 2821.26 | 1868.22 0.0 305 0 | 1.62 0.18 34.38 0.02
1 1.32e+06 2821.26 | 2667.33 1740.0 396 247 | 1.59 0.18 34.13 0.02
1 1.33e+06 2821.26 | 1578.01 0.0 244 0 | 1.60 0.18 34.10 0.02
1 1.34e+06 2821.26 | 2315.74 907.4 361 142 | 1.64 0.19 34.61 0.02
1 1.36e+06 2821.26 | 1068.61 0.0 185 0 | 1.65 0.18 34.59 0.02
1 1.37e+06 2821.26 | 780.38 0.0 119 0 | 1.68 0.19 35.22 0.02
1 1.38e+06 2821.26 | 2128.08 909.8 340 138 | 1.68 0.19 34.24 0.02
1 1.40e+06 5116.59 |
1 1.40e+06 5116.59 | 5116.59 2166.1 734 297 | 1.77 0.19 32.93 0.02
1 1.41e+06 5116.59 | 2901.13 2543.3 403 345 | 1.71 0.19 35.32 0.02
1 1.43e+06 5116.59 | 1638.18 0.0 244 0 | 1.73 0.19 34.84 0.02
1 1.44e+06 5116.59 | 1007.29 0.0 169 0 | 1.72 0.18 34.59 0.02
1 1.46e+06 5116.59 | 3304.17 2510.8 469 341 | 1.76 0.19 35.45 0.02
1 1.47e+06 5116.59 | 3501.58 0.0 483 0 | 1.74 0.19 35.97 0.02
1 1.49e+06 5305.27 |
1 1.49e+06 5305.27 | 5305.27 2807.9 730 378 | 1.77 0.19 35.58 0.02
1 1.50e+06 5305.27 | 5014.42 2359.4 688 315 | 1.72 0.19 35.65 0.02
1 1.52e+06 5305.27 | 4736.14 0.0 639 0 | 1.72 0.19 36.84 0.02
1 1.53e+06 5305.27 | 4393.27 2047.5 598 265 | 1.76 0.19 37.57 0.02
1 1.55e+06 5305.27 | 1213.84 0.0 175 0 | 1.84 0.19 37.64 0.02
1 1.56e+06 5305.27 | 3804.35 2176.2 529 286 | 1.82 0.18 36.11 0.02
1 1.58e+06 5305.27 | 4753.45 0.0 649 0 | 1.82 0.19 35.78 0.02
1 1.59e+06 5305.27 | 3659.95 0.0 478 0 | 1.81 0.20 36.94 0.02
1 1.61e+06 5305.27 | 4564.50 0.0 606 0 | 1.85 0.19 36.93 0.02
1 1.62e+06 6495.10 |
1 1.62e+06 6495.10 | 6495.10 2253.1 837 283 | 1.83 0.19 37.61 0.02
1 1.63e+06 6495.10 | 6440.03 2628.1 819 314 | 1.85 0.19 37.76 0.02
1 1.64e+06 6495.10 | 5980.08 2214.3 784 282 | 1.91 0.19 37.79 0.02
1 1.66e+06 6495.10 | 1143.72 0.0 158 0 | 1.87 0.19 38.26 0.02
1 1.67e+06 6495.10 | 3229.25 0.0 447 0 | 1.87 0.19 38.75 0.02
1 1.68e+06 7820.89 |
1 1.68e+06 7820.89 | 7820.89 49.0 1000 0 | 1.86 0.19 38.04 0.02
1 1.69e+06 7820.89 | 6616.72 2186.4 843 272 | 1.89 0.19 38.41 0.02
1 1.70e+06 7820.89 | 2205.00 0.0 297 0 | 1.85 0.19 38.45 0.02
1 1.71e+06 8201.97 |
1 1.71e+06 8201.97 | 8201.97 60.7 1000 0 | 1.89 0.19 38.49 0.02
1 1.72e+06 8201.97 | 8053.00 0.0 1000 0 | 1.93 0.19 37.79 0.02
1 1.73e+06 8201.97 | 7974.46 0.0 1000 0 | 1.92 0.19 38.88 0.02
1 1.74e+06 8201.97 | 1736.69 0.0 237 0 | 1.88 0.19 38.00 0.02
1 1.75e+06 8201.97 | 7027.53 1871.2 873 220 | 1.94 0.19 37.89 0.02
1 1.76e+06 8201.97 | 4689.30 0.0 579 0 | 1.92 0.19 38.55 0.02
1 1.77e+06 8201.97 | 7855.02 0.0 1000 0 | 1.91 0.19 38.86 0.02
1 1.78e+06 8201.97 | 5215.32 0.0 673 0 | 1.92 0.19 38.98 0.02
1 1.79e+06 8201.97 | 8026.47 0.0 1000 0 | 1.92 0.19 39.59 0.02
1 1.80e+06 8201.97 | 2568.57 0.0 322 0 | 1.89 0.19 39.10 0.02
1 1.81e+06 8201.97 | 3905.44 0.0 516 0 | 1.91 0.20 39.09 0.02
1 1.82e+06 8201.97 | 6868.42 0.0 841 0 | 1.89 0.19 38.71 0.02
1 1.83e+06 8201.97 | 2328.69 0.0 302 0 | 1.93 0.19 39.10 0.02
1 1.84e+06 8201.97 | 7570.05 1112.7 922 135 | 1.97 0.19 39.31 0.02
1 1.85e+06 8201.97 | 5452.10 3047.4 648 353 | 1.81 0.19 39.20 0.02
1 1.85e+06 8201.97 | 5185.33 3187.5 621 365 | 1.95 0.19 39.28 0.02
1 1.87e+06 8201.97 | 3431.44 0.0 414 0 | 2.01 0.19 39.72 0.02
1 1.88e+06 8201.97 | 7174.34 2007.4 852 236 | 1.92 0.20 40.53 0.02
1 1.88e+06 8201.97 | 7000.72 2664.7 823 307 | 1.98 0.19 39.93 0.02
1 1.89e+06 8201.97 | 7756.40 1533.1 900 172 | 1.95 0.20 40.53 0.02
1 1.90e+06 8201.97 | 1015.23 0.0 138 0 | 1.97 0.20 40.52 0.02
1 1.91e+06 8201.97 | 7223.27 0.0 829 0 | 1.96 0.20 39.91 0.02
1 1.92e+06 8201.97 | 2276.04 0.0 271 0 | 1.93 0.20 41.08 0.02
1 1.93e+06 8201.97 | 4279.54 2531.4 512 290 | 1.92 0.20 41.14 0.02
1 1.94e+06 8601.43 |
1 1.94e+06 8601.43 | 8601.43 36.4 1000 0 | 2.01 0.19 41.16 0.02
1 1.95e+06 8605.06 |
1 1.95e+06 8605.06 | 8605.06 53.1 999 2 | 2.01 0.19 39.77 0.02
1 1.96e+06 8605.06 | 8604.10 0.0 1000 0 | 2.02 0.19 41.39 0.02
1 1.97e+06 8605.06 | 4942.93 2670.4 565 286 | 1.99 0.19 40.93 0.02
1 1.98e+06 8605.06 | 8122.71 1366.2 914 148 | 1.93 0.20 41.49 0.02
1 1.99e+06 8605.06 | 1545.50 0.0 194 0 | 1.96 0.19 40.50 0.02
1 2.00e+06 8605.06 | 8586.34 0.0 1000 0 | 1.98 0.20 40.69 0.02
| UsedTime: 17168 | SavedDir: ./Humanoid-v3_ReliableSAC_1
| Learner: Save in ./Humanoid-v3_ReliableSAC_1
"""
elif env_name == 'Humanoid-v3.backup.best.5684':
from elegantrl.envs.CustomGymEnv import HumanoidEnv
env_func = HumanoidEnv
env_args = {
'env_num': 1,
'env_name': 'Humanoid-v3',
'max_step': 1000,
'state_dim': 376,
'action_dim': 17,
'if_discrete': False,
'target_return': 3000.,
}
args = Arguments(agent, env_func=env_func, env_args=env_args)
args.eval_times = 2 ** 2
args.reward_scale = 2 ** -5 # todo
args.max_memo = 2 ** 21
args.learning_rate = 2 ** -14
args.lambda_a_log_std = 2 ** -6
args.target_step = args.max_step
args.worker_num = 4
args.net_dim = 2 ** 8
args.num_layer = 4
args.batch_size = args.net_dim
args.repeat_times = 2 ** 1
args.gamma = 0.99
args.if_act_target = False # todo
# import numpy as np
# args.target_entropy = np.log(env_args['action_dim']) * 1.5 # ???
args.if_allow_break = False
args.break_step = int(2e6)
"""
| Arguments Remove cwd: ./Humanoid-v3_ReliableSAC_2
################################################################################
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
2 8.07e+03 61.53 |
2 8.07e+03 61.53 | 61.53 0.2 13 0 | 0.30 0.54 0.06 0.00
2 8.94e+04 280.97 |
2 8.94e+04 280.97 | 280.97 31.6 65 7 | 0.27 0.07 7.21 0.00
2 1.30e+05 482.54 |
2 1.30e+05 482.54 | 482.54 81.2 104 18 | 0.29 0.14 12.59 0.00
2 1.63e+05 482.54 | 214.11 0.0 45 0 | 0.33 0.19 14.43 0.00
2 1.92e+05 482.54 | 316.52 0.0 68 0 | 0.28 0.21 14.28 0.00
2 2.17e+05 482.54 | 420.99 62.4 85 13 | 0.32 0.21 14.13 0.01
2 2.37e+05 482.54 | 431.52 86.9 93 20 | 0.31 0.17 12.33 0.01
2 2.58e+05 482.54 | 327.86 0.0 66 0 | 0.31 0.16 11.73 0.02
2 2.79e+05 482.54 | 242.40 0.0 52 0 | 0.29 0.15 11.19 0.02
2 2.96e+05 482.54 | 320.37 0.0 69 0 | 0.30 0.14 11.86 0.02
2 3.13e+05 482.54 | 322.18 0.0 63 0 | 0.31 0.13 11.78 0.02
2 3.30e+05 482.54 | 329.25 0.0 65 0 | 0.30 0.13 12.85 0.02
2 3.46e+05 482.54 | 325.96 0.0 64 0 | 0.31 0.13 13.95 0.02
2 3.63e+05 482.54 | 404.71 0.0 86 0 | 0.30 0.13 13.56 0.02
2 3.76e+05 482.54 | 470.03 0.0 90 0 | 0.31 0.14 13.65 0.02
2 3.88e+05 482.54 | 476.55 0.0 105 0 | 0.31 0.14 14.21 0.02
2 4.01e+05 482.54 | 442.83 129.8 88 23 | 0.31 0.14 14.80 0.02
2 4.13e+05 634.66 |
2 4.13e+05 634.66 | 634.66 120.2 129 21 | 0.30 0.15 13.76 0.02
2 4.26e+05 634.66 | 559.63 50.0 121 16 | 0.30 0.15 15.50 0.02
2 4.39e+05 634.66 | 523.28 170.8 112 31 | 0.29 0.15 15.04 0.02
2 4.51e+05 634.66 | 357.70 0.0 77 0 | 0.30 0.16 15.47 0.02
2 4.64e+05 634.66 | 324.52 0.0 73 0 | 0.30 0.17 15.74 0.02
2 4.77e+05 634.66 | 605.87 211.2 128 35 | 0.31 0.18 15.78 0.02
2 4.90e+05 634.66 | 525.32 0.0 102 0 | 0.30 0.18 16.98 0.02
2 5.03e+05 634.66 | 606.06 0.0 119 0 | 0.30 0.20 17.79 0.02
2 5.16e+05 754.18 |
2 5.16e+05 754.18 | 754.18 187.2 152 40 | 0.30 0.20 18.10 0.02
2 5.28e+05 754.18 | 588.85 0.0 121 0 | 0.30 0.20 18.44 0.02
2 5.41e+05 754.18 | 645.80 0.0 137 0 | 0.29 0.21 18.65 0.02
2 5.54e+05 754.18 | 599.06 180.4 127 37 | 0.29 0.21 17.64 0.02
2 5.68e+05 754.18 | 598.60 125.8 116 27 | 0.30 0.22 18.42 0.02
2 5.80e+05 754.18 | 648.31 153.8 139 28 | 0.29 0.22 21.32 0.02
2 5.93e+05 754.18 | 687.98 0.0 154 0 | 0.30 0.23 19.56 0.02
2 6.02e+05 754.18 | 433.99 0.0 95 0 | 0.30 0.23 20.28 0.02
2 6.11e+05 754.18 | 592.46 233.4 127 41 | 0.30 0.23 21.65 0.02
2 6.19e+05 754.18 | 443.31 0.0 89 0 | 0.30 0.23 20.45 0.02
2 6.28e+05 754.18 | 630.86 127.6 124 24 | 0.30 0.23 21.10 0.02
2 6.37e+05 844.03 |
2 6.37e+05 844.03 | 844.03 237.1 164 45 | 0.31 0.24 21.83 0.02
2 6.46e+05 995.82 |
2 6.46e+05 995.82 | 995.82 296.4 204 53 | 0.31 0.24 21.79 0.02
2 6.55e+05 995.82 | 704.54 0.0 146 0 | 0.31 0.25 22.99 0.02
2 6.64e+05 995.82 | 597.17 0.0 120 0 | 0.31 0.25 23.18 0.02
2 6.73e+05 995.82 | 578.13 0.0 127 0 | 0.31 0.26 23.02 0.02
2 6.82e+05 995.82 | 985.69 0.0 188 0 | 0.30 0.26 22.20 0.02
2 6.90e+05 1329.88 |
2 6.90e+05 1329.88 | 1329.88 453.5 271 86 | 0.30 0.26 21.81 0.02
2 6.99e+05 1329.88 | 984.74 242.2 202 52 | 0.30 0.26 24.70 0.02
2 7.08e+05 1329.88 | 1282.09 424.1 252 80 | 0.31 0.26 24.36 0.02
2 7.17e+05 1609.77 |
2 7.17e+05 1609.77 | 1609.77 986.8 321 199 | 0.30 0.26 25.79 0.02
2 7.26e+05 1835.22 |
2 7.26e+05 1835.22 | 1835.22 846.6 361 168 | 0.31 0.26 22.76 0.02
2 7.35e+05 1835.22 | 1455.07 0.0 301 0 | 0.31 0.27 24.73 0.02
2 7.45e+05 1835.22 | 1424.00 0.0 284 0 | 0.31 0.26 25.26 0.02
2 7.54e+05 1835.22 | 1585.16 471.9 319 96 | 0.31 0.26 24.13 0.02
2 7.63e+05 1835.22 | 502.12 0.0 99 0 | 0.30 0.27 24.48 0.02
2 7.72e+05 1957.16 |
2 7.72e+05 1957.16 | 1957.16 1026.3 374 191 | 0.31 0.27 25.86 0.02
2 7.81e+05 1957.16 | 518.58 0.0 106 0 | 0.31 0.27 25.86 0.02
2 7.91e+05 1957.16 | 1099.69 0.0 223 0 | 0.31 0.27 25.92 0.02
2 8.01e+05 1957.16 | 1239.12 0.0 246 0 | 0.31 0.27 26.76 0.02
2 8.10e+05 1957.16 | 1706.44 0.0 318 0 | 0.31 0.27 25.48 0.02
2 8.20e+05 1957.16 | 1875.97 612.2 369 110 | 0.31 0.27 26.70 0.02
2 8.30e+05 1957.16 | 797.77 0.0 158 0 | 0.31 0.28 26.81 0.02
2 8.39e+05 1957.16 | 1699.40 0.0 339 0 | 0.31 0.27 26.47 0.02
2 8.48e+05 1957.16 | 854.85 0.0 166 0 | 0.32 0.28 28.31 0.02
2 8.58e+05 1957.16 | 1492.19 0.0 290 0 | 0.32 0.28 25.77 0.02
2 8.67e+05 1957.16 | 1687.29 0.0 332 0 | 0.31 0.28 26.35 0.02
2 8.76e+05 2319.36 |
2 8.76e+05 2319.36 | 2319.36 1121.7 436 208 | 0.31 0.28 27.42 0.02
2 8.86e+05 2319.36 | 1523.18 0.0 287 0 | 0.32 0.28 27.89 0.02
2 8.95e+05 3929.77 |
2 8.95e+05 3929.77 | 3929.77 1606.8 757 308 | 0.31 0.28 28.16 0.02
2 9.05e+05 3929.77 | 1623.65 0.0 312 0 | 0.31 0.28 27.18 0.02
2 9.15e+05 3929.77 | 3908.78 0.0 752 0 | 0.32 0.28 28.58 0.02
2 9.25e+05 3929.77 | 1302.67 0.0 258 0 | 0.32 0.27 29.20 0.02
2 9.35e+05 3929.77 | 1261.39 0.0 245 0 | 0.32 0.27 27.75 0.02
2 9.45e+05 3929.77 | 759.79 0.0 169 0 | 0.31 0.27 28.00 0.02
2 9.55e+05 3929.77 | 2116.41 0.0 402 0 | 0.31 0.26 28.82 0.02
2 9.65e+05 3929.77 | 1699.71 0.0 315 0 | 0.32 0.27 30.17 0.02
2 9.74e+05 3929.77 | 726.84 0.0 160 0 | 0.32 0.27 28.64 0.02
2 9.84e+05 4231.71 |
2 9.84e+05 4231.71 | 4231.71 1425.9 799 257 | 0.32 0.27 28.88 0.02
2 9.94e+05 4231.71 | 2501.40 1341.9 474 253 | 0.31 0.27 30.48 0.02
2 1.00e+06 4231.71 | 3515.81 1836.7 660 333 | 0.32 0.27 30.17 0.02
2 1.01e+06 4231.71 | 828.37 0.0 171 0 | 0.33 0.27 30.49 0.02
2 1.02e+06 4231.71 | 1462.77 0.0 270 0 | 0.32 0.27 31.05 0.02
2 1.03e+06 4231.71 | 1928.92 0.0 356 0 | 0.33 0.26 31.43 0.02
2 1.04e+06 4231.71 | 609.80 0.0 128 0 | 0.32 0.26 30.16 0.02
2 1.05e+06 4231.71 | 3092.45 1241.4 596 244 | 0.32 0.27 31.47 0.02
2 1.06e+06 4231.71 | 1380.05 0.0 261 0 | 0.32 0.25 32.00 0.02
2 1.07e+06 4231.71 | 2293.69 0.0 423 0 | 0.32 0.26 32.25 0.02
2 1.08e+06 4231.71 | 904.86 0.0 180 0 | 0.32 0.25 32.23 0.02
2 1.10e+06 4231.71 | 1727.42 0.0 351 0 | 0.32 0.25 31.05 0.02
2 1.11e+06 4231.71 | 2375.34 0.0 441 0 | 0.33 0.25 30.80 0.02
2 1.12e+06 4231.71 | 3723.47 0.0 684 0 | 0.33 0.25 32.45 0.02
2 1.13e+06 4231.71 | 4135.63 1886.7 768 342 | 0.32 0.25 31.90 0.02
2 1.14e+06 4231.71 | 765.19 0.0 142 0 | 0.33 0.24 32.01 0.02
2 1.15e+06 4231.71 | 1945.57 0.0 366 0 | 0.33 0.24 34.65 0.02
2 1.16e+06 4231.71 | 2542.68 1734.2 465 311 | 0.32 0.24 32.80 0.02
2 1.17e+06 4231.71 | 2590.14 0.0 471 0 | 0.32 0.24 31.36 0.02
2 1.18e+06 4231.71 | 2468.01 0.0 447 0 | 0.33 0.25 33.19 0.02
2 1.19e+06 4231.71 | 1560.16 0.0 285 0 | 0.33 0.24 31.76 0.02
2 1.19e+06 4231.71 | 223.32 0.0 43 0 | 0.33 0.24 34.08 0.02
2 1.20e+06 4231.71 | 123.22 0.0 25 0 | 0.33 0.25 32.51 0.02
2 1.21e+06 4231.71 | 1063.34 0.0 205 0 | 0.32 0.24 33.16 0.02
2 1.21e+06 4231.71 | 2342.22 2161.3 434 392 | 0.32 0.24 32.86 0.02
2 1.22e+06 4231.71 | 1376.66 0.0 254 0 | 0.33 0.24 33.61 0.02
2 1.22e+06 4231.71 | 1939.27 0.0 345 0 | 0.33 0.24 32.21 0.02
2 1.23e+06 4231.71 | 1450.92 0.0 282 0 | 0.33 0.23 34.04 0.02
2 1.23e+06 4231.71 | 3652.45 0.0 657 0 | 0.34 0.24 34.21 0.02
2 1.24e+06 4231.71 | 1252.34 0.0 240 0 | 0.33 0.24 33.65 0.02
2 1.24e+06 4231.71 | 1768.35 0.0 326 0 | 0.34 0.24 33.81 0.02
2 1.25e+06 4231.71 | 1952.18 0.0 350 0 | 0.33 0.24 34.21 0.02
2 1.25e+06 4231.71 | 1479.76 0.0 278 0 | 0.33 0.23 34.37 0.02
2 1.26e+06 4231.71 | 4231.34 0.0 757 0 | 0.34 0.24 33.61 0.02
2 1.26e+06 4231.71 | 4202.22 0.0 755 0 | 0.33 0.23 32.39 0.02
2 1.27e+06 4231.71 | 3597.61 2100.9 658 379 | 0.33 0.24 32.62 0.02
2 1.27e+06 4231.71 | 430.31 0.0 92 0 | 0.33 0.23 34.13 0.02
2 1.28e+06 4231.71 | 2833.13 1841.9 511 320 | 0.33 0.23 34.23 0.01
2 1.28e+06 4351.07 |
2 1.28e+06 4351.07 | 4351.07 1734.1 778 304 | 0.33 0.23 32.08 0.01
2 1.29e+06 4351.07 | 2608.48 0.0 470 0 | 0.33 0.24 34.04 0.01
2 1.29e+06 4351.07 | 2364.01 1791.9 428 311 | 0.33 0.23 34.24 0.01
2 1.30e+06 4351.07 | 3731.13 1500.9 686 270 | 0.33 0.23 35.38 0.01
2 1.30e+06 4351.07 | 805.48 0.0 158 0 | 0.33 0.23 31.95 0.01
2 1.31e+06 4351.07 | 491.94 0.0 109 0 | 0.33 0.23 33.86 0.01
2 1.31e+06 4351.07 | 1352.71 0.0 244 0 | 0.33 0.22 33.14 0.01
2 1.32e+06 4351.07 | 1908.86 0.0 352 0 | 0.33 0.23 32.84 0.01
2 1.32e+06 4351.07 | 950.31 0.0 171 0 | 0.33 0.22 34.09 0.01
2 1.33e+06 4351.07 | 639.88 0.0 124 0 | 0.33 0.22 32.27 0.01
2 1.34e+06 4351.07 | 2889.20 0.0 515 0 | 0.33 0.22 34.52 0.01
2 1.34e+06 4351.07 | 3991.38 0.0 768 0 | 0.33 0.22 33.87 0.01
2 1.35e+06 4351.07 | 3834.92 0.0 699 0 | 0.34 0.23 35.08 0.01
2 1.35e+06 4351.07 | 1375.02 0.0 253 0 | 0.33 0.23 33.69 0.01
2 1.35e+06 4351.07 | 3717.74 0.0 671 0 | 0.33 0.23 31.91 0.01
2 1.36e+06 4351.07 | 3654.43 1926.9 668 345 | 0.32 0.22 33.76 0.01
2 1.36e+06 4351.07 | 4149.08 1117.4 737 191 | 0.33 0.22 33.57 0.01
2 1.37e+06 4584.25 |
2 1.37e+06 4584.25 | 4584.25 1056.6 819 187 | 0.33 0.22 33.02 0.01
2 1.38e+06 4584.25 | 745.19 0.0 149 0 | 0.34 0.23 34.83 0.01
2 1.38e+06 4584.25 | 764.75 0.0 143 0 | 0.33 0.22 33.36 0.01
2 1.38e+06 4584.25 | 1127.75 0.0 221 0 | 0.33 0.22 34.09 0.01
2 1.39e+06 4584.25 | 1979.66 0.0 355 0 | 0.34 0.21 34.31 0.01
2 1.39e+06 4584.25 | 1755.43 0.0 343 0 | 0.34 0.22 34.75 0.01
2 1.40e+06 4584.25 | 332.25 0.0 63 0 | 0.34 0.22 35.14 0.01
2 1.40e+06 4584.25 | 1491.16 0.0 266 0 | 0.33 0.22 34.39 0.01
2 1.41e+06 4980.79 |
2 1.41e+06 4980.79 | 4980.79 558.8 895 105 | 0.34 0.21 34.81 0.01
2 1.41e+06 4980.79 | 1351.99 0.0 245 0 | 0.34 0.21 34.57 0.01
2 1.42e+06 5684.42 |
2 1.42e+06 5684.42 | 5684.42 131.2 1000 0 | 0.33 0.21 33.68 0.01
2 1.42e+06 5684.42 | 4778.06 0.0 879 0 | 0.33 0.21 33.75 0.01
2 1.43e+06 5684.42 | 3606.03 2215.2 640 386 | 0.34 0.20 33.83 0.01
2 1.43e+06 5684.42 | 1853.79 0.0 332 0 | 0.33 0.21 34.58 0.01
2 1.44e+06 5684.42 | 1923.59 0.0 357 0 | 0.34 0.21 33.56 0.01
2 1.45e+06 5684.42 | 3439.89 0.0 628 0 | 0.35 0.21 35.52 0.01
2 1.45e+06 5684.42 | 1380.56 0.0 271 0 | 0.33 0.21 34.46 0.01
2 1.46e+06 5684.42 | 4449.71 1530.1 798 258 | 0.33 0.21 36.05 0.01
2 1.46e+06 5684.42 | 1432.35 0.0 283 0 | 0.34 0.21 34.44 0.01
2 1.47e+06 5684.42 | 1907.75 0.0 343 0 | 0.34 0.21 34.38 0.01
2 1.47e+06 5684.42 | 1346.14 0.0 251 0 | 0.32 0.21 34.43 0.01
2 1.48e+06 5684.42 | 4292.50 0.0 802 0 | 0.34 0.21 35.61 0.01
2 1.48e+06 5684.42 | 4377.58 0.0 768 0 | 0.34 0.21 35.64 0.01
2 1.49e+06 5684.42 | 814.67 0.0 147 0 | 0.34 0.21 34.39 0.01
2 1.49e+06 5684.42 | 3326.43 0.0 585 0 | 0.33 0.21 35.33 0.01
2 1.50e+06 5684.42 | 1169.90 0.0 221 0 | 0.32 0.22 34.27 0.01
2 1.50e+06 5684.42 | 352.07 0.0 74 0 | 0.33 0.25 35.59 0.02
2 1.51e+06 5684.42 | 432.39 0.0 84 0 | 0.32 0.26 37.55 0.02
2 1.51e+06 5684.42 | 3580.22 0.0 677 0 | 0.31 0.25 38.36 0.01
2 1.52e+06 5684.42 | 3384.96 0.0 586 0 | 0.31 0.24 36.76 0.01
2 1.52e+06 5684.42 | 1773.22 0.0 361 0 | 0.32 0.23 36.11 0.01
2 1.53e+06 5684.42 | 2135.71 0.0 398 0 | 0.35 0.22 35.34 0.01
2 1.53e+06 5684.42 | 860.46 0.0 156 0 | 0.34 0.22 35.35 0.01
2 1.54e+06 5684.42 | 5422.32 0.0 1000 0 | 0.34 0.22 36.33 0.01
2 1.54e+06 5684.42 | 675.59 0.0 127 0 | 0.34 0.21 35.75 0.01
2 1.55e+06 5684.42 | 1234.09 0.0 222 0 | 0.33 0.21 34.51 0.01
2 1.55e+06 5684.42 | 4229.33 0.0 753 0 | 0.34 0.20 35.09 0.01
2 1.56e+06 5684.42 | 1366.60 0.0 244 0 | 0.33 0.20 33.57 0.01
2 1.56e+06 5684.42 | 5525.51 0.0 1000 0 | 0.33 0.21 35.46 0.01
2 1.57e+06 5684.42 | 1769.33 0.0 339 0 | 0.34 0.20 34.62 0.01
2 1.57e+06 5684.42 | 2902.24 0.0 546 0 | 0.34 0.20 34.76 0.01
2 1.58e+06 5684.42 | 4058.17 0.0 721 0 | 0.34 0.21 34.88 0.01
2 1.58e+06 5684.42 | 5075.46 1003.3 900 173 | 0.34 0.21 34.74 0.01
2 1.59e+06 5684.42 | 3907.85 0.0 694 0 | 0.34 0.21 36.51 0.01
2 1.59e+06 5684.42 | 5449.51 0.0 1000 0 | 0.34 0.20 34.68 0.01
2 1.60e+06 5684.42 | 4781.07 0.0 863 0 | 0.34 0.21 35.13 0.01
2 1.61e+06 5684.42 | 797.45 0.0 151 0 | 0.34 0.20 35.76 0.01
2 1.61e+06 5684.42 | 1150.24 0.0 217 0 | 0.33 0.20 35.66 0.01
2 1.62e+06 5684.42 | 5660.03 0.0 1000 0 | 0.34 0.20 35.80 0.01
2 1.62e+06 5684.42 | 3585.73 1437.3 617 237 | 0.35 0.20 34.86 0.01
2 1.63e+06 5684.42 | 4281.01 1572.7 744 258 | 0.33 0.19 35.23 0.01
2 1.63e+06 5684.42 | 2157.23 0.0 399 0 | 0.34 0.20 34.19 0.01
2 1.64e+06 5684.42 | 5280.96 0.0 1000 0 | 0.35 0.19 33.86 0.01
2 1.64e+06 5684.42 | 5135.08 0.0 871 0 | 0.34 0.20 34.85 0.01
2 1.65e+06 5684.42 | 1028.12 0.0 187 0 | 0.34 0.19 35.61 0.01
2 1.65e+06 5684.42 | 1541.23 0.0 272 0 | 0.35 0.19 35.61 0.01
2 1.66e+06 5684.42 | 2266.63 0.0 416 0 | 0.34 0.19 33.94 0.01
2 1.66e+06 5684.42 | 1899.89 0.0 342 0 | 0.35 0.19 34.28 0.01
2 1.67e+06 5684.42 | 4176.02 1000.3 717 164 | 0.34 0.19 33.48 0.01
2 1.67e+06 5684.42 | 5189.92 1227.2 882 205 | 0.34 0.19 35.69 0.01
2 1.68e+06 5684.42 | 195.31 0.0 38 0 | 0.35 0.19 34.47 0.01
2 1.68e+06 5684.42 | 5663.44 0.0 1000 0 | 0.35 0.19 36.95 0.01
2 1.69e+06 5684.42 | 823.29 0.0 153 0 | 0.34 0.19 35.86 0.01
2 1.69e+06 5684.42 | 3310.77 0.0 587 0 | 0.34 0.19 35.26 0.01
2 1.70e+06 5684.42 | 5610.64 0.0 1000 0 | 0.34 0.19 36.32 0.01
2 1.70e+06 5684.42 | 2492.52 0.0 441 0 | 0.35 0.20 35.55 0.01
2 1.71e+06 5684.42 | 1382.81 0.0 251 0 | 0.34 0.19 35.50 0.01
2 1.71e+06 5684.42 | 5502.84 0.0 965 0 | 0.34 0.19 35.44 0.01
2 1.72e+06 5684.42 | 2653.70 0.0 464 0 | 0.34 0.19 35.49 0.01
2 1.72e+06 5684.42 | 2569.08 0.0 446 0 | 0.34 0.20 34.85 0.01
2 1.73e+06 5684.42 | 1960.59 0.0 356 0 | 0.35 0.20 35.89 0.01
2 1.73e+06 5684.42 | 569.35 0.0 122 0 | 0.35 0.20 35.76 0.01
2 1.74e+06 5684.42 | 1555.08 0.0 302 0 | 0.33 0.19 34.31 0.01
2 1.74e+06 5684.42 | 825.29 0.0 181 0 | 0.33 0.20 35.71 0.01
2 1.75e+06 5684.42 | 884.30 0.0 182 0 | 0.33 0.20 35.93 0.01
2 1.75e+06 5684.42 | 754.74 0.0 154 0 | 0.33 0.20 35.86 0.01
2 1.76e+06 5684.42 | 840.29 0.0 166 0 | 0.32 0.19 35.76 0.01
2 1.76e+06 5684.42 | 5375.29 0.0 927 0 | 0.32 0.18 35.98 0.01
2 1.76e+06 5684.42 | 2216.25 0.0 376 0 | 0.34 0.19 35.01 0.01
2 1.77e+06 5684.42 | 5582.28 0.0 1000 0 | 0.34 0.19 36.68 0.01
2 1.77e+06 5684.42 | 3306.34 0.0 592 0 | 0.35 0.18 36.32 0.01
2 1.78e+06 5684.42 | 5509.94 0.0 957 0 | 0.34 0.19 35.58 0.01
2 1.78e+06 5684.42 | 1581.59 0.0 275 0 | 0.34 0.19 34.64 0.01
2 1.79e+06 5684.42 | 4884.17 1757.6 831 292 | 0.34 0.19 34.52 0.01
2 1.79e+06 5684.42 | 520.76 0.0 102 0 | 0.34 0.19 36.42 0.01
2 1.80e+06 5684.42 | 2075.62 0.0 360 0 | 0.36 0.19 34.56 0.01
2 1.80e+06 5684.42 | 2849.00 0.0 504 0 | 0.35 0.19 36.11 0.01
"""
elif env_name == 'Humanoid-v3.backup.5606':
from elegantrl.envs.CustomGymEnv import HumanoidEnv
env_func = HumanoidEnv
env_args = {
'env_num': 1,
'env_name': 'Humanoid-v3',
'max_step': 1000,
'state_dim': 376,
'action_dim': 17,
'if_discrete': False,
'target_return': 3000.,
}
args = Arguments(agent, env_func=env_func, env_args=env_args)
args.eval_times = 2 ** 2
args.reward_scale = 2 ** -4
args.max_memo = 2 ** 21
args.learning_rate = 2 ** -14
args.lambda_a_log_std = 2 ** -6
args.target_step = args.max_step
args.worker_num = 4
args.net_dim = 2 ** 8
args.num_layer = 4
args.batch_size = args.net_dim
args.repeat_times = 2 ** 1
args.gamma = 0.99
args.if_allow_break = False
args.break_step = int(2e6)
"""
| Arguments Remove cwd: ./Humanoid-v3_ReliableSAC_2
################################################################################
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
2 8.07e+03 76.16 |
2 8.07e+03 76.16 | 76.16 0.1 16 0 | 0.30 0.55 -0.11 0.00
2 8.47e+04 226.51 |
2 8.47e+04 226.51 | 226.51 12.0 45 2 | 0.29 0.03 4.31 0.00
2 1.26e+05 330.59 |
2 1.26e+05 330.59 | 330.59 12.2 70 2 | 0.29 0.07 8.89 0.00
2 1.59e+05 502.37 |
2 1.59e+05 502.37 | 502.37 74.8 102 13 | 0.33 0.08 10.22 0.00
2 1.89e+05 502.37 | 271.74 0.0 51 0 | 0.32 0.13 13.05 0.00
2 2.13e+05 502.37 | 263.78 0.0 58 0 | 0.32 0.16 12.73 0.01
2 2.34e+05 502.37 | 333.15 0.0 65 0 | 0.28 0.15 13.12 0.01
2 2.55e+05 502.37 | 480.34 70.0 105 13 | 0.32 0.13 11.47 0.02
2 2.76e+05 538.58 |
2 2.76e+05 538.58 | 538.58 108.7 108 19 | 0.31 0.11 12.34 0.02
2 2.92e+05 538.58 | 357.07 0.0 68 0 | 0.30 0.12 12.55 0.02
2 3.09e+05 538.58 | 401.06 0.0 79 0 | 0.30 0.12 12.48 0.02
2 3.26e+05 538.58 | 359.38 0.0 78 0 | 0.31 0.13 14.05 0.02
2 3.43e+05 538.58 | 415.86 0.0 98 0 | 0.30 0.14 14.95 0.02
2 3.59e+05 538.58 | 427.16 0.0 80 0 | 0.31 0.15 14.31 0.02
2 3.77e+05 538.58 | 486.99 0.0 93 0 | 0.30 0.16 14.94 0.02
2 3.89e+05 538.58 | 462.94 0.0 101 0 | 0.30 0.17 15.75 0.02
2 4.01e+05 538.58 | 419.89 0.0 99 0 | 0.30 0.18 15.39 0.02
2 4.14e+05 538.58 | 479.96 0.0 90 0 | 0.31 0.19 15.36 0.02
2 4.27e+05 538.58 | 537.61 0.0 119 0 | 0.30 0.20 15.81 0.02
2 4.39e+05 538.58 | 363.96 0.0 75 0 | 0.30 0.21 15.95 0.02
2 4.52e+05 538.58 | 535.53 158.0 110 35 | 0.30 0.21 17.68 0.02
2 4.65e+05 538.58 | 434.56 0.0 90 0 | 0.31 0.22 17.65 0.02
2 4.78e+05 538.58 | 421.31 0.0 88 0 | 0.31 0.22 16.96 0.02
2 4.91e+05 538.58 | 372.28 0.0 74 0 | 0.30 0.23 17.25 0.02
2 5.03e+05 538.58 | 455.47 128.7 96 29 | 0.30 0.23 18.11 0.02
2 5.16e+05 538.58 | 428.26 0.0 86 0 | 0.31 0.24 18.75 0.02
2 5.29e+05 538.58 | 316.51 0.0 62 0 | 0.31 0.24 19.18 0.02
2 5.42e+05 615.80 |
2 5.42e+05 615.80 | 615.80 96.7 123 21 | 0.31 0.25 21.45 0.02
2 5.54e+05 826.89 |
2 5.54e+05 826.89 | 826.89 104.2 168 26 | 0.30 0.27 20.43 0.02
2 5.67e+05 826.89 | 450.51 0.0 92 0 | 0.31 0.27 19.76 0.02
2 5.80e+05 826.89 | 498.25 0.0 92 0 | 0.31 0.27 21.87 0.02
2 5.93e+05 826.89 | 815.60 147.8 166 33 | 0.31 0.27 22.05 0.02
2 6.02e+05 826.89 | 699.31 0.0 147 0 | 0.30 0.28 22.44 0.02
2 6.10e+05 826.89 | 643.56 0.0 126 0 | 0.31 0.28 23.44 0.02
2 6.19e+05 826.89 | 167.29 0.0 33 0 | 0.31 0.28 23.14 0.02
2 6.28e+05 826.89 | 367.48 0.0 74 0 | 0.31 0.29 23.11 0.02
2 6.36e+05 826.89 | 658.05 0.0 127 0 | 0.31 0.29 22.56 0.02
2 6.45e+05 826.89 | 746.85 0.0 147 0 | 0.31 0.29 23.29 0.02
2 6.54e+05 826.89 | 767.08 0.0 168 0 | 0.30 0.29 21.61 0.02
2 6.62e+05 826.89 | 736.44 0.0 139 0 | 0.30 0.30 23.38 0.02
2 6.71e+05 826.89 | 436.42 0.0 94 0 | 0.30 0.30 22.17 0.02
2 6.80e+05 826.89 | 634.87 0.0 120 0 | 0.30 0.29 24.19 0.02
2 6.89e+05 826.89 | 595.90 189.0 123 44 | 0.31 0.29 26.35 0.02
2 6.97e+05 826.89 | 567.10 0.0 107 0 | 0.31 0.31 24.67 0.02
2 7.06e+05 826.89 | 595.54 0.0 114 0 | 0.31 0.31 24.35 0.02
2 7.15e+05 826.89 | 399.45 0.0 77 0 | 0.31 0.30 23.58 0.02
2 7.23e+05 826.89 | 434.58 0.0 85 0 | 0.31 0.31 25.30 0.02
2 7.32e+05 826.89 | 446.36 0.0 83 0 | 0.31 0.31 26.40 0.02
2 7.40e+05 826.89 | 537.46 0.0 97 0 | 0.31 0.31 24.95 0.02
2 7.49e+05 826.89 | 671.12 0.0 137 0 | 0.32 0.30 24.95 0.02
2 7.58e+05 826.89 | 453.14 0.0 87 0 | 0.31 0.31 25.86 0.02
2 7.67e+05 826.89 | 691.16 0.0 130 0 | 0.31 0.30 25.07 0.02
2 7.75e+05 1530.83 |
2 7.75e+05 1530.83 | 1530.83 396.3 297 80 | 0.30 0.31 23.88 0.02
2 7.84e+05 1530.83 | 891.09 0.0 180 0 | 0.31 0.30 25.45 0.02
2 7.93e+05 1530.83 | 360.46 0.0 70 0 | 0.31 0.31 26.00 0.02
2 8.01e+05 1530.83 | 452.85 0.0 90 0 | 0.30 0.30 24.52 0.02
2 8.10e+05 1530.83 | 663.09 0.0 131 0 | 0.32 0.30 26.27 0.02
2 8.19e+05 1530.83 | 1212.53 511.4 247 106 | 0.31 0.30 26.67 0.02
2 8.28e+05 1530.83 | 799.14 0.0 151 0 | 0.31 0.30 23.82 0.02
2 8.37e+05 1530.83 | 779.43 0.0 156 0 | 0.31 0.30 25.61 0.02
2 8.45e+05 1530.83 | 631.44 0.0 118 0 | 0.31 0.30 25.03 0.02
2 8.54e+05 1530.83 | 1248.43 0.0 248 0 | 0.31 0.30 25.75 0.02
2 8.63e+05 1530.83 | 928.86 0.0 182 0 | 0.31 0.30 26.13 0.02
2 8.73e+05 1530.83 | 1125.56 0.0 219 0 | 0.31 0.30 26.08 0.02
2 8.82e+05 1530.83 | 698.18 0.0 145 0 | 0.31 0.30 26.49 0.02
2 8.91e+05 1530.83 | 961.80 0.0 212 0 | 0.30 0.30 26.33 0.02
2 9.00e+05 1530.83 | 1174.05 0.0 230 0 | 0.31 0.30 26.08 0.02
2 9.09e+05 1530.83 | 1100.58 0.0 239 0 | 0.31 0.30 27.55 0.02
2 9.18e+05 1868.20 |
2 9.18e+05 1868.20 | 1868.20 164.8 371 30 | 0.30 0.30 26.45 0.02
2 9.28e+05 1868.20 | 1073.36 0.0 201 0 | 0.31 0.30 26.89 0.02
2 9.37e+05 1868.20 | 1205.66 0.0 230 0 | 0.31 0.30 26.77 0.02
2 9.46e+05 1868.20 | 1372.51 0.0 267 0 | 0.31 0.29 28.57 0.02
2 9.56e+05 1868.20 | 798.34 0.0 154 0 | 0.31 0.30 28.85 0.02
2 9.66e+05 1868.20 | 1428.51 788.3 277 150 | 0.32 0.29 27.15 0.02
2 9.75e+05 1868.20 | 608.42 0.0 116 0 | 0.31 0.28 29.42 0.02
2 9.85e+05 1868.20 | 325.33 0.0 64 0 | 0.31 0.29 28.10 0.02
2 9.95e+05 1928.41 |
2 9.95e+05 1928.41 | 1928.41 822.3 379 159 | 0.32 0.29 29.61 0.02
2 1.00e+06 1928.41 | 1149.56 0.0 226 0 | 0.31 0.29 28.76 0.02
2 1.01e+06 1928.41 | 1721.60 0.0 345 0 | 0.31 0.28 28.38 0.02
2 1.02e+06 1928.41 | 1185.92 0.0 223 0 | 0.32 0.29 27.91 0.02
2 1.03e+06 1928.41 | 1233.72 0.0 244 0 | 0.31 0.28 28.91 0.02
2 1.04e+06 1928.41 | 1551.67 0.0 303 0 | 0.31 0.28 29.68 0.02
2 1.05e+06 1928.41 | 978.83 0.0 192 0 | 0.31 0.28 28.76 0.02
2 1.06e+06 2257.10 |
2 1.06e+06 2257.10 | 2257.10 674.7 421 120 | 0.31 0.28 29.41 0.02
2 1.07e+06 2257.10 | 2150.05 0.0 401 0 | 0.32 0.28 29.53 0.02
2 1.08e+06 2257.10 | 775.42 0.0 149 0 | 0.31 0.28 29.71 0.02
2 1.09e+06 2257.10 | 681.05 0.0 134 0 | 0.31 0.28 29.51 0.02
2 1.10e+06 2257.10 | 1053.45 0.0 209 0 | 0.31 0.28 28.97 0.02
2 1.11e+06 2257.10 | 850.63 0.0 170 0 | 0.31 0.27 29.28 0.02
2 1.12e+06 2257.10 | 1736.51 0.0 344 0 | 0.31 0.28 30.47 0.02
2 1.13e+06 2257.10 | 1936.67 0.0 370 0 | 0.32 0.27 29.64 0.02
2 1.14e+06 2257.10 | 2247.72 1388.4 426 262 | 0.31 0.26 30.76 0.02
2 1.15e+06 2825.53 |
2 1.15e+06 2825.53 | 2825.53 1191.8 556 232 | 0.32 0.26 30.33 0.02
2 1.16e+06 2825.53 | 2546.58 1666.1 498 332 | 0.32 0.27 30.56 0.02
2 1.17e+06 2825.53 | 850.81 0.0 166 0 | 0.32 0.26 29.23 0.01
2 1.18e+06 2825.53 | 1411.25 0.0 280 0 | 0.32 0.26 28.02 0.01
2 1.19e+06 2825.53 | 538.52 0.0 109 0 | 0.32 0.26 31.44 0.01
2 1.19e+06 2825.53 | 2693.81 0.0 508 0 | 0.31 0.26 30.05 0.01
2 1.20e+06 2978.43 |
2 1.20e+06 2978.43 | 2978.43 1663.4 573 317 | 0.32 0.25 30.95 0.01
2 1.20e+06 3575.62 |
2 1.20e+06 3575.62 | 3575.62 1612.5 694 314 | 0.31 0.26 31.57 0.01
2 1.21e+06 3575.62 | 993.93 0.0 186 0 | 0.32 0.25 29.87 0.01
2 1.21e+06 3575.62 | 1999.92 0.0 392 0 | 0.31 0.26 30.52 0.01
2 1.22e+06 3575.62 | 889.42 0.0 171 0 | 0.33 0.25 30.81 0.01
2 1.22e+06 3575.62 | 3405.88 1731.5 668 338 | 0.32 0.25 31.85 0.01
2 1.23e+06 3575.62 | 892.11 0.0 168 0 | 0.32 0.25 31.85 0.01
2 1.23e+06 3575.62 | 778.46 0.0 147 0 | 0.32 0.25 31.28 0.01
2 1.24e+06 3575.62 | 1535.40 0.0 310 0 | 0.32 0.25 31.43 0.01
2 1.24e+06 3575.62 | 2843.25 1210.4 554 243 | 0.32 0.25 29.70 0.01
2 1.25e+06 3575.62 | 3353.49 0.0 631 0 | 0.31 0.25 30.64 0.01
2 1.25e+06 3575.62 | 883.32 0.0 170 0 | 0.32 0.25 31.49 0.01
2 1.26e+06 3575.62 | 3092.77 1210.6 606 226 | 0.32 0.25 31.16 0.01
2 1.26e+06 3575.62 | 569.80 0.0 112 0 | 0.32 0.24 31.06 0.01
2 1.27e+06 3575.62 | 1041.53 0.0 197 0 | 0.31 0.24 31.33 0.01
2 1.28e+06 3575.62 | 3255.92 0.0 638 0 | 0.33 0.24 30.84 0.01
2 1.28e+06 3575.62 | 2279.13 0.0 434 0 | 0.33 0.24 33.50 0.01
2 1.29e+06 3575.62 | 559.01 0.0 107 0 | 0.32 0.24 32.44 0.01
2 1.29e+06 3575.62 | 3277.19 0.0 649 0 | 0.32 0.25 32.05 0.01
2 1.29e+06 3575.62 | 1050.02 0.0 204 0 | 0.33 0.24 31.84 0.01
2 1.30e+06 3575.62 | 715.11 0.0 138 0 | 0.32 0.24 32.69 0.01
2 1.31e+06 3575.62 | 569.46 0.0 111 0 | 0.32 0.24 31.83 0.01
2 1.31e+06 3575.62 | 948.73 0.0 180 0 | 0.33 0.25 32.41 0.01
2 1.31e+06 3575.62 | 1140.72 0.0 224 0 | 0.33 0.24 30.14 0.01
2 1.32e+06 3575.62 | 1303.37 0.0 249 0 | 0.32 0.24 30.97 0.01
2 1.32e+06 3575.62 | 2585.92 0.0 511 0 | 0.33 0.24 30.48 0.01
2 1.33e+06 4376.07 |
2 1.33e+06 4376.07 | 4376.07 1031.6 854 199 | 0.33 0.24 31.88 0.01
2 1.34e+06 4376.07 | 2329.53 0.0 447 0 | 0.32 0.24 31.45 0.01
2 1.34e+06 4376.07 | 2766.31 1240.2 565 254 | 0.32 0.24 32.76 0.01
2 1.35e+06 4376.07 | 3559.24 0.0 672 0 | 0.32 0.24 32.08 0.01
2 1.35e+06 4376.07 | 2982.04 1761.5 557 330 | 0.31 0.24 31.67 0.01
2 1.36e+06 4376.07 | 1431.25 0.0 282 0 | 0.32 0.23 31.13 0.01
2 1.36e+06 4376.07 | 1818.30 0.0 373 0 | 0.32 0.24 30.68 0.01
2 1.37e+06 4376.07 | 911.64 0.0 167 0 | 0.33 0.24 31.94 0.01
2 1.37e+06 4376.07 | 2429.27 0.0 442 0 | 0.32 0.24 31.20 0.01
2 1.38e+06 4376.07 | 1491.57 0.0 294 0 | 0.33 0.23 31.37 0.01
2 1.38e+06 4376.07 | 1535.84 0.0 294 0 | 0.33 0.22 32.09 0.01
2 1.39e+06 4376.07 | 1724.81 0.0 331 0 | 0.33 0.24 31.07 0.01
2 1.39e+06 4376.07 | 1426.36 0.0 273 0 | 0.33 0.23 32.00 0.01
2 1.40e+06 4376.07 | 2066.45 1369.6 401 264 | 0.33 0.23 33.17 0.01
2 1.40e+06 4376.07 | 1078.23 0.0 210 0 | 0.33 0.23 31.05 0.01
2 1.41e+06 4376.07 | 1217.95 0.0 256 0 | 0.33 0.23 32.79 0.01
2 1.41e+06 4376.07 | 1394.94 0.0 270 0 | 0.33 0.23 33.30 0.01
2 1.42e+06 4376.07 | 3662.75 0.0 688 0 | 0.33 0.23 34.01 0.01
2 1.42e+06 4376.07 | 3106.36 0.0 595 0 | 0.32 0.23 32.38 0.01
2 1.43e+06 4376.07 | 3703.49 0.0 705 0 | 0.33 0.23 33.98 0.01
2 1.43e+06 4376.07 | 1284.99 0.0 240 0 | 0.33 0.22 33.41 0.01
2 1.44e+06 4376.07 | 2499.82 0.0 479 0 | 0.33 0.23 31.52 0.01
2 1.44e+06 4376.07 | 4095.95 1608.4 780 308 | 0.33 0.22 31.57 0.01
2 1.45e+06 4376.07 | 1376.74 0.0 268 0 | 0.33 0.22 34.45 0.01
2 1.45e+06 4376.07 | 1529.86 0.0 293 0 | 0.33 0.23 33.78 0.01
2 1.46e+06 4376.07 | 2346.18 0.0 472 0 | 0.33 0.23 33.08 0.01
2 1.46e+06 4376.07 | 1454.02 0.0 278 0 | 0.33 0.22 31.71 0.01
2 1.47e+06 4376.07 | 4071.25 0.0 775 0 | 0.32 0.22 32.64 0.01
2 1.47e+06 4376.07 | 4041.26 1121.8 774 226 | 0.33 0.23 32.98 0.01
2 1.48e+06 4376.07 | 2339.81 0.0 470 0 | 0.33 0.23 34.03 0.01
2 1.48e+06 4376.07 | 3188.20 1323.7 610 249 | 0.33 0.22 31.73 0.01
2 1.49e+06 4376.07 | 1301.07 0.0 270 0 | 0.33 0.22 33.16 0.01
2 1.49e+06 4376.07 | 2600.90 1531.0 535 298 | 0.33 0.22 32.24 0.01
2 1.50e+06 4376.07 | 2169.64 0.0 433 0 | 0.32 0.22 32.96 0.01
2 1.51e+06 4376.07 | 1137.47 0.0 221 0 | 0.33 0.22 34.14 0.01
2 1.51e+06 4376.07 | 3703.59 1616.3 704 305 | 0.33 0.22 32.40 0.01
2 1.52e+06 4376.07 | 2139.60 0.0 406 0 | 0.33 0.21 32.47 0.01
2 1.52e+06 4376.07 | 4352.19 1187.4 811 229 | 0.34 0.22 33.02 0.01
2 1.53e+06 4376.07 | 2650.12 1653.3 486 297 | 0.33 0.22 33.92 0.01
2 1.53e+06 4376.07 | 1533.19 0.0 303 0 | 0.34 0.21 31.45 0.01
2 1.54e+06 4376.07 | 780.99 0.0 146 0 | 0.33 0.21 32.48 0.01
2 1.54e+06 4376.07 | 2626.05 0.0 509 0 | 0.33 0.21 33.91 0.01
2 1.55e+06 4376.07 | 4370.40 0.0 823 0 | 0.33 0.21 31.92 0.01
2 1.55e+06 4376.07 | 1506.31 0.0 297 0 | 0.33 0.22 33.49 0.01
2 1.56e+06 4376.07 | 2899.16 1496.5 554 282 | 0.33 0.21 32.71 0.01
2 1.56e+06 4376.07 | 1198.79 0.0 236 0 | 0.34 0.20 34.19 0.01
2 1.57e+06 4376.07 | 4314.28 1905.6 795 350 | 0.33 0.21 32.53 0.01
2 1.57e+06 4376.07 | 932.14 0.0 185 0 | 0.33 0.20 32.61 0.01
2 1.58e+06 4376.07 | 3710.02 0.0 680 0 | 0.33 0.21 33.56 0.01
2 1.58e+06 4376.07 | 1788.02 0.0 334 0 | 0.33 0.20 32.80 0.01
2 1.59e+06 4376.07 | 2178.98 0.0 405 0 | 0.33 0.20 35.01 0.01
2 1.59e+06 4661.43 |
2 1.59e+06 4661.43 | 4661.43 1205.4 870 225 | 0.33 0.21 34.16 0.01
2 1.60e+06 4661.43 | 4636.75 1363.6 856 249 | 0.34 0.20 32.75 0.01
2 1.60e+06 4661.43 | 3285.64 0.0 641 0 | 0.34 0.20 34.36 0.01
2 1.61e+06 4661.43 | 3996.92 0.0 746 0 | 0.33 0.20 32.96 0.01
2 1.61e+06 4808.85 |
2 1.61e+06 4808.85 | 4808.85 858.2 905 165 | 0.32 0.20 32.36 0.01
2 1.62e+06 4808.85 | 3711.65 1420.6 712 269 | 0.33 0.20 33.59 0.01
2 1.62e+06 4808.85 | 2343.89 0.0 433 0 | 0.32 0.20 33.83 0.01
2 1.63e+06 4808.85 | 3650.32 1767.0 675 326 | 0.33 0.19 33.05 0.01
2 1.64e+06 4808.85 | 1539.43 0.0 279 0 | 0.33 0.19 34.10 0.01
2 1.64e+06 4808.85 | 3677.19 1948.3 664 352 | 0.34 0.19 34.59 0.01
2 1.65e+06 4808.85 | 2687.31 0.0 496 0 | 0.33 0.20 33.47 0.01
2 1.65e+06 4808.85 | 1542.33 0.0 290 0 | 0.33 0.19 33.24 0.01
2 1.66e+06 4808.85 | 867.88 0.0 173 0 | 0.34 0.19 34.27 0.01
2 1.66e+06 4808.85 | 3085.34 1711.3 579 322 | 0.34 0.20 33.70 0.01
2 1.67e+06 4808.85 | 1687.58 0.0 323 0 | 0.33 0.20 34.93 0.01
2 1.67e+06 4808.85 | 4066.38 1268.1 742 228 | 0.34 0.19 32.41 0.01
2 1.68e+06 4808.85 | 452.65 0.0 91 0 | 0.33 0.20 33.70 0.01
2 1.68e+06 4808.85 | 3018.52 0.0 558 0 | 0.34 0.21 34.58 0.01
2 1.69e+06 4808.85 | 430.01 0.0 102 0 | 0.33 0.35 38.89 0.02
2 1.69e+06 4808.85 | 472.74 0.0 109 0 | 0.33 0.40 44.93 0.03
2 1.70e+06 4808.85 | 628.25 0.0 136 0 | 0.31 0.32 44.62 0.02
2 1.70e+06 4808.85 | 812.73 0.0 167 0 | 0.28 0.27 42.12 0.01
2 1.70e+06 4808.85 | 1707.97 0.0 327 0 | 0.31 0.24 39.53 0.01
2 1.71e+06 4808.85 | 1819.14 0.0 339 0 | 0.32 0.23 36.88 0.01
2 1.72e+06 4808.85 | 2053.70 0.0 388 0 | 0.33 0.21 35.72 0.01
2 1.72e+06 4808.85 | 2262.07 0.0 419 0 | 0.33 0.21 33.69 0.01
2 1.72e+06 4808.85 | 787.00 0.0 153 0 | 0.33 0.20 35.14 0.01
2 1.73e+06 4808.85 | 1620.02 0.0 309 0 | 0.34 0.20 33.92 0.01
2 1.74e+06 4808.85 | 2368.23 0.0 447 0 | 0.33 0.20 34.85 0.01
2 1.74e+06 4846.42 |
2 1.74e+06 4846.42 | 4846.42 581.3 906 110 | 0.33 0.19 34.40 0.01
2 1.75e+06 4846.42 | 752.17 0.0 150 0 | 0.34 0.19 33.20 0.01
2 1.75e+06 4846.42 | 3085.69 2158.1 576 395 | 0.34 0.19 34.28 0.01
2 1.76e+06 4846.42 | 381.14 0.0 71 0 | 0.34 0.20 33.92 0.01
2 1.76e+06 4846.42 | 3684.18 0.0 693 0 | 0.34 0.19 34.47 0.01
2 1.77e+06 5436.18 |
2 1.77e+06 5436.18 | 5436.18 35.3 1000 0 | 0.33 0.19 34.15 0.01
2 1.77e+06 5436.18 | 5327.19 0.0 1000 0 | 0.34 0.19 33.98 0.01
2 1.78e+06 5436.18 | 4729.78 0.0 857 0 | 0.34 0.20 34.32 0.01
2 1.78e+06 5578.46 |
2 1.78e+06 5578.46 | 5578.46 86.6 1000 0 | 0.34 0.19 34.41 0.01
2 1.79e+06 5578.46 | 2561.99 0.0 473 0 | 0.34 0.19 34.08 0.01
2 1.79e+06 5578.46 | 5432.93 0.0 1000 0 | 0.35 0.19 34.19 0.01
2 1.80e+06 5578.46 | 1247.43 0.0 232 0 | 0.34 0.19 34.27 0.01
2 1.80e+06 5578.46 | 3227.15 0.0 598 0 | 0.35 0.18 35.06 0.01
2 1.81e+06 5578.46 | 3294.27 0.0 610 0 | 0.35 0.18 34.52 0.01
2 1.81e+06 5578.46 | 5424.16 0.0 1000 0 | 0.33 0.18 34.81 0.01
2 1.82e+06 5578.46 | 5410.13 0.0 1000 0 | 0.34 0.18 34.04 0.01
2 1.82e+06 5578.46 | 2406.91 0.0 454 0 | 0.34 0.18 35.67 0.01
2 1.83e+06 5578.46 | 5494.68 0.0 1000 0 | 0.34 0.18 35.15 0.01
2 1.83e+06 5578.46 | 2468.08 0.0 535 0 | 0.34 0.19 34.65 0.01
2 1.84e+06 5578.46 | 3286.31 0.0 633 0 | 0.34 0.19 34.83 0.01
2 1.84e+06 5578.46 | 5295.30 0.0 1000 0 | 0.33 0.19 33.75 0.01
2 1.85e+06 5578.46 | 1098.72 0.0 216 0 | 0.34 0.18 35.00 0.01
2 1.85e+06 5578.46 | 2036.09 0.0 381 0 | 0.34 0.18 34.08 0.01
2 1.86e+06 5578.46 | 704.63 0.0 135 0 | 0.34 0.18 32.72 0.01
2 1.86e+06 5578.46 | 5437.36 0.0 1000 0 | 0.33 0.18 35.17 0.01
2 1.87e+06 5578.46 | 1882.41 0.0 352 0 | 0.34 0.18 33.29 0.01
2 1.87e+06 5578.46 | 2585.14 0.0 453 0 | 0.34 0.18 34.44 0.01
2 1.88e+06 5578.46 | 3676.13 0.0 674 0 | 0.34 0.18 33.99 0.01
2 1.88e+06 5578.46 | 2395.74 0.0 438 0 | 0.34 0.18 34.04 0.01
2 1.89e+06 5578.46 | 1226.04 0.0 241 0 | 0.34 0.17 34.84 0.01
2 1.89e+06 5578.46 | 5255.36 0.0 1000 0 | 0.34 0.18 33.56 0.01
2 1.90e+06 5578.46 | 5571.49 0.0 1000 0 | 0.35 0.17 34.05 0.01
2 1.90e+06 5578.46 | 3593.36 0.0 716 0 | 0.34 0.18 33.59 0.01
2 1.91e+06 5578.46 | 5293.41 0.0 1000 0 | 0.35 0.18 34.38 0.01
2 1.91e+06 5578.46 | 4169.86 0.0 795 0 | 0.33 0.18 34.22 0.01
2 1.92e+06 5578.46 | 3631.33 0.0 647 0 | 0.34 0.17 34.96 0.01
2 1.92e+06 5578.46 | 5460.01 0.0 1000 0 | 0.35 0.17 34.32 0.01
2 1.93e+06 5578.46 | 5410.56 0.0 1000 0 | 0.35 0.17 33.34 0.01
2 1.93e+06 5578.46 | 5460.13 0.0 1000 0 | 0.34 0.17 33.90 0.01
2 1.94e+06 5578.46 | 2817.41 0.0 537 0 | 0.34 0.18 34.36 0.01
2 1.94e+06 5578.46 | 1858.92 0.0 339 0 | 0.35 0.17 34.96 0.01
2 1.95e+06 5578.46 | 2207.20 0.0 418 0 | 0.34 0.17 35.02 0.01
2 1.95e+06 5578.46 | 2759.04 0.0 523 0 | 0.35 0.17 35.04 0.01
2 1.96e+06 5578.46 | 5266.78 0.0 940 0 | 0.35 0.17 33.96 0.01
2 1.96e+06 5578.46 | 1092.09 0.0 203 0 | 0.34 0.18 33.64 0.01
2 1.97e+06 5578.46 | 2487.55 0.0 446 0 | 0.34 0.26 37.81 0.02
2 1.97e+06 5578.46 | 2313.96 0.0 420 0 | 0.34 0.23 40.44 0.01
2 1.98e+06 5606.16 |
2 1.98e+06 5606.16 | 5606.16 51.8 1000 0 | 0.32 0.21 38.85 0.01
2 1.98e+06 5606.16 | 3925.41 0.0 696 0 | 0.34 0.19 37.93 0.01
2 1.99e+06 5606.16 | 5475.95 0.0 1000 0 | 0.35 0.18 35.79 0.01
2 1.99e+06 5606.16 | 2794.34 0.0 516 0 | 0.36 0.19 34.80 0.01
2 2.00e+06 5606.16 | 5602.57 0.0 1000 0 | 0.35 0.17 34.41 0.01
2 2.00e+06 5606.16 | 5382.77 326.0 968 56 | 0.35 0.18 35.26 0.01
| UsedTime: 45183 | SavedDir: ./Humanoid-v3_ReliableSAC_2
| Learner: Save in ./Humanoid-v3_ReliableSAC_2
"""
else:
raise ValueError('env_name:', env_name)
args.learner_gpus = gpu_id
args.random_seed += gpu_id
if_check = 0
if if_check:
train_and_evaluate(args)
else:
train_and_evaluate_mp(args)
def demo_ddpg_h_term(gpu_id, drl_id, env_id): # 2022.04.04
env_name = ['Pendulum-v1',
'BipedalWalker-v3',
'Hopper-v2',
'Swimmer-v3',
'HalfCheetah-v3',
'Walker2d-v3',
'Humanoid-v3', ][env_id]
agent_class = [AgentDDPG, AgentDDPGHterm, AgentTD3,
AgentSAC, AgentReSAC, AgentReSACHterm, AgentReSACHtermK][drl_id]
# from elegantrl.train.config import get_gym_env_args
# env = gym.make(env_name)
# get_gym_env_args(env=env, if_print=True)
# exit()
if env_name in {'Pendulum-v0', 'Pendulum-v1'}:
from elegantrl.envs.CustomGymEnv import PendulumEnv
env = PendulumEnv(env_name, target_return=-500)
args = Arguments(agent_class, env)
args.reward_scale = 2 ** -1 # RewardRange: -1800 < -200 < -50 < 0
args.gamma = 0.95
args.target_step = args.max_step * 4
args.eval_times = 2 ** 5
"""
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
2 1.60e+03-1147.49 |-1147.49 179.2 200 0 | -2.61 0.90 0.55 1.00
2 5.84e+04 -121.61 | -121.61 59.0 200 0 | -0.81 0.33 -40.64 0.79
| UsedTime: 132 |
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
1 1.60e+03-1267.96 |-1267.96 329.7 200 0 | -2.67 0.88 0.56 1.00
1 8.48e+04 -171.79 | -182.24 63.3 200 0 | -0.30 0.32 -30.75 0.64
1 1.19e+05 -171.79 | -178.25 116.8 200 0 | -0.31 0.16 -22.52 0.43
1 1.34e+05 -164.56 | -164.56 99.1 200 0 | -0.31 0.15 -18.09 0.35
1 1.47e+05 -135.20 | -135.20 92.1 200 0 | -0.31 0.14 -15.65 0.29
| UsedTime: 783 |
"""
elif env_name == 'BipedalWalker-v3':
env_func = gym.make
env_args = {'env_num': 1,
'env_name': 'BipedalWalker-v3',
'max_step': 1600,
'state_dim': 24,
'action_dim': 4,
'if_discrete': False,
'target_return': 300,
'id': 'BipedalWalker-v3', }
args = Arguments(agent_class, env_func=env_func, env_args=env_args)
args.num_layer = 3
args.net_dim = 2 ** 8
args.batch_size = int(args.net_dim * 2)
args.worker_num = 2
args.target_step = args.max_step
args.repeat_times = 2 ** 0
args.reward_scale = 2 ** -1
args.learning_rate = 2 ** -15
args.clip_grad_norm = 1.0
args.gamma = 0.98
args.if_act_target = False
args.explore_noise_std = 0.06 # for Deterministic Policy Gradient Algorithms
args.lambda_action = 2 ** -4
args.h_term_drop_rate = 2 ** -2
args.h_term_lambda = 0 # todo
args.h_term_k_step = 8
args.h_term_update_gap = 2
args.eval_times = 2 ** 2
args.eval_gap = 2 ** 8
args.if_allow_break = False
args.break_step = int(2e6)
"""
| Arguments Remove cwd: ./BipedalWalker-v3_ReliableSAC_5
################################################################################
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
5 1.78e+03 -111.40 |
5 1.78e+03 -111.40 | -111.40 0.2 102 4 | -0.18 0.75 1.25 0.25
5 6.72e+04 -102.81 |
5 6.72e+04 -102.81 | -102.81 0.6 56 2 | -0.40 0.13 4.46 0.03
5 1.02e+05 -57.47 |
5 1.02e+05 -57.47 | -57.47 9.6 1600 0 | -0.15 0.41 -4.42 0.03
5 1.24e+05 -45.19 |
5 1.24e+05 -45.19 | -45.19 8.3 1600 0 | -0.04 0.46 -4.50 0.04
5 1.44e+05 -33.45 |
5 1.44e+05 -33.45 | -33.45 3.0 1600 0 | -0.40 0.26 -3.91 0.03
5 1.61e+05 -33.45 | -40.02 11.3 1600 0 | -0.03 0.13 -2.09 0.02
5 1.78e+05 -33.45 | -47.55 10.9 1600 0 | -0.37 0.14 0.28 0.02
5 1.96e+05 -33.45 | -94.23 0.5 147 5 | -0.11 0.11 -2.00 0.03
5 2.13e+05 108.48 |
5 2.13e+05 108.48 | 108.48 118.5 1248 566 | 0.05 0.12 -2.35 0.03
5 2.28e+05 108.48 | 54.40 123.4 1057 553 | -0.45 0.14 0.47 0.03
5 2.41e+05 258.69 |
5 2.41e+05 258.69 | 258.69 91.5 1371 283 | 0.06 0.13 1.60 0.04
5 2.58e+05 299.87 |
5 2.58e+05 299.87 | 299.87 0.9 1443 19 | 0.09 0.15 0.31 0.04
5 2.74e+05 299.87 | 243.41 113.8 1119 295 | 0.16 0.13 3.68 0.04
5 2.86e+05 299.87 | 80.06 125.7 635 294 | -0.22 0.11 4.27 0.04
5 2.98e+05 312.25 |
5 2.98e+05 312.25 | 312.25 1.0 1186 16 | 0.22 0.13 5.49 0.04
| UsedTime: 1885 | SavedDir: ./BipedalWalker-v3_ReliableSAC_5
| Arguments Remove cwd: ./BipedalWalker-v3_ReliableSACHterm_6
################################################################################
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
6 1.60e+03 -92.22 |
6 1.60e+03 -92.22 | -92.22 0.1 110 1 | -0.06 0.74 1.15 0.25
6 6.50e+04 -31.14 |
6 6.50e+04 -31.14 | -31.14 1.7 1600 0 | -0.04 0.08 4.60 0.02
6 9.71e+04 -31.14 | -103.20 0.1 98 1 | -0.44 0.09 -0.19 0.02
6 1.24e+05 -31.14 | -62.62 29.0 1304 593 | -0.05 0.19 -3.96 0.03
6 1.45e+05 -31.14 | -39.96 12.3 1600 0 | -0.19 0.24 -6.13 0.02
6 1.65e+05 -31.14 | -45.63 15.5 1600 0 | -0.11 0.20 0.42 0.02
6 1.82e+05 -31.14 | -55.53 7.1 1600 0 | -0.04 0.12 -1.60 0.02
6 1.98e+05 -31.14 | -88.54 33.1 686 746 | 0.04 0.08 -1.20 0.02
6 2.14e+05 -31.14 | -45.76 29.0 759 267 | -0.11 0.11 0.02 0.03
6 2.29e+05 249.59 |
6 2.29e+05 249.59 | 249.59 105.0 1436 375 | -0.18 0.16 1.73 0.04
6 2.42e+05 249.59 | 12.51 82.6 559 379 | 0.13 0.20 1.16 0.04
6 2.60e+05 309.47 |
6 2.60e+05 309.47 | 309.47 1.6 1455 33 | 0.07 0.18 1.84 0.04
| UsedTime: 1476 | SavedDir: ./BipedalWalker-v3_ReliableSACHterm_6
| Arguments Remove cwd: ./BipedalWalker-v3_ReSAC_2
################################################################################
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
2 7.12e+03 -102.89 |
2 7.12e+03 -102.89 | -102.89 5.3 147 18 | -0.06 0.77 0.78 0.25
2 2.73e+05 -21.80 |
2 2.73e+05 -21.80 | -21.80 0.4 1600 0 | -0.02 0.06 17.16 0.13
2 3.98e+05 -7.83 |
2 3.98e+05 -7.83 | -7.83 2.1 1600 0 | -0.02 0.04 9.75 0.06
2 4.96e+05 -7.83 | -44.20 0.0 1600 0 | -0.04 0.04 3.87 0.03
2 5.86e+05 -7.83 | -74.46 0.0 1600 0 | -0.05 0.03 0.71 0.01
2 6.61e+05 -7.83 | -27.95 12.7 1600 0 | -0.02 0.04 0.06 0.01
2 7.25e+05 -7.83 | -34.49 0.0 1600 0 | -0.01 0.03 -0.59 0.01
2 7.87e+05 -7.83 | -42.36 0.0 1600 0 | -0.02 0.01 -0.45 0.01
2 8.47e+05 -7.83 | -26.66 0.0 1600 0 | -0.01 0.01 -0.37 0.01
2 9.00e+05 -7.83 | -36.84 0.0 1600 0 | -0.01 0.01 -0.08 0.01
2 9.51e+05 -7.83 | -48.88 0.0 1600 0 | -0.01 0.01 -0.18 0.01
2 9.99e+05 -7.83 | -52.01 0.0 1600 0 | -0.01 0.01 -0.29 0.01
2 1.04e+06 -7.83 | -54.41 0.0 1600 0 | -0.01 0.01 -0.31 0.01
2 1.09e+06 -7.83 | -32.74 0.0 1600 0 | -0.01 0.01 -0.24 0.01
2 1.14e+06 48.00 |
2 1.14e+06 48.00 | 48.00 76.8 1256 595 | -0.01 0.01 0.12 0.01
2 1.19e+06 48.00 | -16.25 0.0 912 0 | -0.04 0.01 0.12 0.01
2 1.24e+06 48.00 | -43.57 0.0 380 0 | 0.05 0.01 0.69 0.01
2 1.29e+06 280.92 |
2 1.29e+06 280.92 | 280.92 2.5 1506 49 | 0.08 0.01 1.06 0.01
2 1.34e+06 280.92 | -59.15 0.0 231 0 | 0.11 0.01 1.33 0.01
2 1.40e+06 299.49 |
2 1.40e+06 299.49 | 299.49 1.8 1156 25 | 0.12 0.01 1.91 0.02
2 1.44e+06 299.49 | 298.65 0.0 1325 0 | 0.12 0.01 2.28 0.02
2 1.49e+06 309.70 |
2 1.49e+06 309.70 | 309.70 1.6 1267 65 | 0.11 0.01 2.61 0.02
2 1.54e+06 309.70 | 270.84 72.9 1021 95 | 0.13 0.01 3.02 0.02
2 1.58e+06 309.70 | 245.03 124.4 878 242 | 0.11 0.02 3.45 0.02
2 1.62e+06 318.15 |
2 1.62e+06 318.15 | 318.15 0.5 1039 9 | 0.09 0.02 3.68 0.02
2 1.66e+06 320.87 |
2 1.66e+06 320.87 | 320.87 0.5 1003 12 | 0.15 0.02 3.89 0.02
2 1.69e+06 320.87 | 21.56 0.0 638 0 | -0.02 0.02 5.68 0.02
2 1.73e+06 322.08 |
2 1.73e+06 322.08 | 322.08 0.6 994 4 | 0.13 0.02 4.14 0.02
2 1.77e+06 322.80 |
2 1.77e+06 322.80 | 322.80 0.6 960 17 | 0.16 0.02 4.35 0.02
2 1.80e+06 322.80 | 321.69 0.0 924 0 | 0.15 0.02 4.35 0.02
2 1.83e+06 322.80 | 263.38 110.4 830 175 | 0.14 0.02 4.70 0.02
2 1.86e+06 325.13 |
2 1.86e+06 325.13 | 325.13 0.5 899 7 | 0.17 0.02 4.91 0.02
2 1.89e+06 325.13 | 317.20 0.0 1415 0 | -0.03 0.04 12.38 0.03
2 1.92e+06 325.13 | -129.30 0.0 109 0 | 0.04 0.06 8.54 0.03
2 1.95e+06 325.13 | 322.35 0.0 912 0 | 0.11 0.03 6.01 0.03
2 1.99e+06 325.13 | 321.18 0.0 928 0 | 0.16 0.03 4.87 0.03
| UsedTime: 9499 | SavedDir: ./BipedalWalker-v3_ReSAC_2
"""
elif env_name == 'Hopper-v2':
env_func = gym.make
env_args = {
'env_num': 1,
'env_name': 'Hopper-v2',
'max_step': 1000,
'state_dim': 11,
'action_dim': 3,
'if_discrete': False,
'target_return': 3800.,
}
args = Arguments(agent_class, env_func=env_func, env_args=env_args)
args.num_layer = 3
args.net_dim = 2 ** 8
args.batch_size = int(args.net_dim * 1)
args.worker_num = 2
args.target_step = args.max_step
args.repeat_times = 2 ** -1
args.reward_scale = 2 ** -4
args.learning_rate = 2 ** -15
args.clip_grad_norm = 1.0
args.gamma = 0.99
args.if_act_target = False
args.explore_noise_std = 0.1 # for DPG
args.lambda_action = 2 ** -4
args.h_term_drop_rate = 2 ** -2
args.h_term_lambda = 2 ** -16
args.act_update_gap = 1
args.h_term_k_step = 8
args.h_term_update_gap = 2
args.eval_times = 2 ** 1
args.eval_gap = 2 ** 8
args.if_allow_break = False
args.break_step = int(2e6)
"""
;;; repeat_times 0.5
;;; explore_noise_std 0.06
| Arguments Remove cwd: ./Hopper-v2_DDPG_5
################################################################################
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
5 4.05e+03 31.31 |
5 4.05e+03 31.31 | 31.31 0.6 33 0 | 0.06 0.00 -0.15
5 2.60e+05 125.04 |
5 2.60e+05 125.04 | 125.04 36.8 72 19 | 0.11 0.05 -4.96
5 4.52e+05 287.91 |
5 4.52e+05 287.91 | 287.91 9.1 150 7 | 0.10 0.10 -15.62
5 6.04e+05 287.91 | 33.76 0.0 23 0 | 0.11 0.33 -29.86
5 7.28e+05 943.68 |
5 7.28e+05 943.68 | 943.68 2.5 1000 0 | 0.05 0.20 -36.74
5 8.39e+05 943.68 | 223.96 0.0 276 0 | 0.10 0.39 -32.80
5 9.36e+05 943.68 | 18.41 0.0 17 0 | 0.11 0.28 -47.11
5 1.02e+06 943.68 | 112.46 0.0 79 0 | 0.10 0.43 -44.61
5 1.11e+06 943.68 | 271.21 0.0 139 0 | 0.11 0.15 -43.29
5 1.19e+06 943.68 | 339.68 0.0 173 0 | 0.12 0.26 -44.58
5 1.26e+06 943.68 | 344.69 0.0 151 0 | 0.12 0.80 -68.53
5 1.33e+06 943.68 | 246.59 0.0 150 0 | 0.18 0.47 -63.54
5 1.39e+06 943.68 | 520.48 0.0 379 0 | 0.09 1.04 -69.88
5 1.46e+06 1515.81 |
5 1.46e+06 1515.81 | 1515.81 561.6 538 271 | 0.14 0.54 -59.63
5 1.53e+06 1515.81 | 287.81 0.0 119 0 | 0.17 0.54 -55.94
5 1.59e+06 1515.81 | 317.89 0.0 124 0 | 0.18 0.48 -54.38
5 1.65e+06 1515.81 | 777.02 0.0 255 0 | 0.18 0.52 -53.06
5 1.70e+06 1515.81 | 260.43 0.0 135 0 | 0.13 0.37 -48.36
5 1.76e+06 1515.81 | 856.31 0.0 252 0 | 0.19 0.63 -47.88
5 1.82e+06 1515.81 | 1049.09 0.0 360 0 | 0.17 0.41 -48.26
5 1.87e+06 1515.81 | 1248.30 0.0 357 0 | 0.20 0.58 -53.84
5 1.92e+06 3040.54 |
5 1.92e+06 3040.54 | 3040.54 60.8 1000 0 | 0.19 0.25 -51.93
5 1.97e+06 3040.54 | 384.53 0.0 149 0 | 0.13 0.24 -47.11
| UsedTime: 2952 | SavedDir: ./Hopper-v2_DDPG_5
| Learner: Save in ./Hopper-v2_DDPG_5
;;; repeat_times 0.5
| Arguments Remove cwd: ./Hopper-v2_ReliableSAC_5
################################################################################
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
5 4.02e+03 22.57 |
5 4.02e+03 22.57 | 22.57 0.5 28 0 | 0.05 0.81 1.37 0.33
5 1.93e+05 264.67 |
5 1.93e+05 264.67 | 264.67 2.3 111 1 | 0.15 0.10 12.14 0.09
5 3.04e+05 419.28 |
5 3.04e+05 419.28 | 419.28 1.3 142 0 | 0.16 0.12 19.81 0.11
5 3.91e+05 679.15 |
5 3.91e+05 679.15 | 679.15 3.2 246 2 | 0.18 0.16 28.57 0.14
5 4.68e+05 2296.08 |
5 4.68e+05 2296.08 | 2296.08 23.0 1000 0 | 0.14 0.18 33.53 0.15
5 5.38e+05 2296.08 | 1975.77 0.0 1000 0 | 0.13 0.19 35.84 0.14
5 6.00e+05 2513.52 |
5 6.00e+05 2513.52 | 2513.52 2.8 1000 0 | 0.17 0.18 39.30 0.13
5 6.51e+05 2627.30 |
5 6.51e+05 2627.30 | 2627.30 0.6 1000 0 | 0.16 0.17 40.20 0.12
5 7.00e+05 2627.30 | 2565.19 0.0 1000 0 | 0.16 0.15 40.18 0.11
5 7.44e+05 2820.52 |
5 7.44e+05 2820.52 | 2820.52 1.8 1000 0 | 0.17 0.15 40.12 0.09
5 7.88e+05 2820.52 | 2597.41 0.0 1000 0 | 0.17 0.13 39.35 0.08
5 8.28e+05 2820.52 | 2795.26 0.0 1000 0 | 0.18 0.11 38.10 0.07
5 8.69e+05 2936.57 |
5 8.69e+05 2936.57 | 2936.57 2.1 1000 0 | 0.18 0.11 37.18 0.07
5 9.05e+05 3017.49 |
5 9.05e+05 3017.49 | 3017.49 1.2 1000 0 | 0.19 0.10 36.89 0.06
5 9.41e+05 3017.49 | 2869.90 0.0 1000 0 | 0.19 0.09 35.58 0.06
5 9.80e+05 3079.65 |
5 9.80e+05 3079.65 | 3079.65 2.1 1000 0 | 0.19 0.09 35.00 0.06
5 1.01e+06 3111.62 |
5 1.01e+06 3111.62 | 3111.62 1.2 1000 0 | 0.20 0.09 35.51 0.06
5 1.04e+06 3111.62 | 3102.43 0.0 1000 0 | 0.19 0.09 35.28 0.06
5 1.08e+06 3195.77 |
5 1.08e+06 3195.77 | 3195.77 0.8 1000 0 | 0.20 0.08 35.27 0.06
5 1.10e+06 3204.82 |
5 1.10e+06 3204.82 | 3204.82 1.3 1000 0 | 0.20 0.08 35.29 0.05
5 1.13e+06 3227.59 |
5 1.13e+06 3227.59 | 3227.59 0.3 1000 0 | 0.20 0.08 34.81 0.05
5 1.17e+06 3236.78 |
5 1.17e+06 3236.78 | 3236.78 1.1 1000 0 | 0.20 0.07 34.90 0.05
5 1.19e+06 3251.62 |
5 1.19e+06 3251.62 | 3251.62 0.6 1000 0 | 0.20 0.07 34.88 0.05
5 1.22e+06 3310.67 |
5 1.22e+06 3310.67 | 3310.67 1.2 1000 0 | 0.21 0.07 34.24 0.05
5 1.25e+06 3310.67 | 3303.20 0.0 1000 0 | 0.21 0.07 34.15 0.05
5 1.28e+06 3312.09 |
5 1.28e+06 3312.09 | 3312.09 1.3 1000 0 | 0.20 0.07 33.99 0.05
5 1.31e+06 3361.26 |
5 1.31e+06 3361.26 | 3361.26 1.3 1000 0 | 0.20 0.07 34.49 0.05
5 1.34e+06 3361.26 | 3264.82 0.0 1000 0 | 0.21 0.07 34.20 0.05
5 1.36e+06 3361.26 | 3218.51 0.0 1000 0 | 0.22 0.07 34.42 0.05
5 1.39e+06 3361.26 | 3308.47 0.0 1000 0 | 0.22 0.06 33.95 0.05
5 1.41e+06 3361.26 | 3347.62 0.0 1000 0 | 0.22 0.06 34.16 0.05
5 1.44e+06 3361.26 | 3285.74 0.0 1000 0 | 0.21 0.07 34.00 0.05
5 1.46e+06 3361.26 | 3280.85 0.0 1000 0 | 0.22 0.06 33.90 0.04
5 1.49e+06 3361.26 | 3311.28 0.0 1000 0 | 0.21 0.06 34.01 0.04
5 1.51e+06 3407.79 |
5 1.51e+06 3407.79 | 3407.79 1.7 1000 0 | 0.22 0.06 33.94 0.05
5 1.54e+06 3407.79 | 3381.80 0.0 1000 0 | 0.20 0.06 34.44 0.05
5 1.56e+06 3407.79 | 3356.46 0.0 1000 0 | 0.22 0.06 34.72 0.05
5 1.59e+06 3407.79 | 3395.07 0.0 1000 0 | 0.20 0.06 34.86 0.05
5 1.61e+06 3407.79 | 3313.27 0.0 1000 0 | 0.22 0.06 34.64 0.05
5 1.63e+06 3407.79 | 3401.76 0.0 1000 0 | 0.22 0.06 34.94 0.05
5 1.66e+06 3489.30 |
5 1.66e+06 3489.30 | 3489.30 4.1 1000 0 | 0.23 0.06 34.42 0.05
5 1.68e+06 3489.30 | 3393.20 0.0 1000 0 | 0.23 0.06 34.14 0.05
5 1.70e+06 3489.30 | 3458.37 0.0 1000 0 | 0.22 0.05 34.41 0.05
5 1.73e+06 3489.30 | 3352.92 0.0 1000 0 | 0.22 0.06 34.62 0.05
5 1.75e+06 3489.30 | 3333.69 0.0 1000 0 | 0.22 0.06 35.26 0.05
5 1.77e+06 3489.30 | 3456.53 0.0 1000 0 | 0.21 0.05 35.47 0.05
| UsedTime: 5997 | SavedDir: ./Hopper-v2_ReliableSAC_5
| Learner: Save in ./Hopper-v2_ReliableSAC_5
| Arguments Remove cwd: ./Hopper-v2_ReliableSACHterm_6
################################################################################
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
6 4.04e+03 78.95 |
6 4.04e+03 78.95 | 78.95 3.6 108 4 | 0.09 0.76 0.85 0.33
6 1.15e+05 198.10 |
6 1.15e+05 198.10 | 198.10 1.9 90 1 | 0.28 0.63 29.79 0.23
6 1.72e+05 889.93 |
6 1.72e+05 889.93 | 889.93 4.0 314 1 | 0.28 0.82 45.62 0.17
6 2.17e+05 889.93 | 274.09 0.0 110 0 | 0.31 0.94 58.49 0.21
6 2.55e+05 889.93 | 491.19 0.0 167 0 | 0.34 1.29 58.00 0.28
6 2.91e+05 889.93 | 261.90 0.0 119 0 | 0.30 2.26 58.54 0.49
6 3.25e+05 1031.75 |
6 3.25e+05 1031.75 | 1031.75 0.5 1000 0 | 0.15 1.82 85.02 0.71
6 3.54e+05 1031.75 | 1014.32 0.0 1000 0 | 0.13 1.47 101.81 0.50
6 3.81e+05 1034.31 |
6 3.81e+05 1034.31 | 1034.31 0.6 1000 0 | 0.14 1.17 95.27 0.42
6 4.06e+05 1034.31 | 122.12 0.0 151 0 | 0.14 0.91 81.74 0.36
6 4.29e+05 1034.31 | 277.10 0.0 221 0 | 0.14 0.78 73.37 0.34
6 4.51e+05 1034.31 | 565.33 0.0 384 0 | 0.16 0.75 68.32 0.31
6 4.71e+05 1378.52 |
6 4.71e+05 1378.52 | 1378.52 0.1 1000 0 | 0.22 0.60 66.21 0.26
6 4.89e+05 1378.52 | 448.34 0.0 315 0 | 0.21 0.49 60.09 0.20
6 5.06e+05 1378.52 | 419.95 0.0 168 0 | 0.29 0.44 53.30 0.17
6 5.24e+05 1378.52 | 1104.66 0.0 420 0 | 0.32 0.35 47.74 0.17
6 5.41e+05 1649.15 |
6 5.41e+05 1649.15 | 1649.15 879.9 704 300 | 0.29 0.31 45.29 0.15
6 5.60e+05 2190.47 |
6 5.60e+05 2190.47 | 2190.47 4.3 1000 0 | 0.25 0.33 44.60 0.14
6 5.77e+05 2190.47 | 2120.56 0.0 1000 0 | 0.33 0.32 42.70 0.12
6 5.95e+05 2686.57 |
6 5.95e+05 2686.57 | 2686.57 5.8 1000 0 | 0.38 0.27 41.22 0.11
6 6.08e+05 2686.57 | 956.68 0.0 292 0 | 0.39 0.25 40.32 0.11
6 6.21e+05 2686.57 | 273.05 0.0 132 0 | 0.34 0.23 39.83 0.11
6 6.34e+05 2686.57 | 308.15 0.0 137 0 | 0.30 0.24 40.72 0.11
6 6.47e+05 2686.57 | 458.55 0.0 200 0 | 0.29 0.27 40.67 0.11
6 6.60e+05 2686.57 | 760.84 0.0 286 0 | 0.34 0.27 41.64 0.11
6 6.75e+05 2686.57 | 1253.21 0.0 412 0 | 0.35 0.23 41.98 0.11
6 6.88e+05 2686.57 | 544.23 0.0 205 0 | 0.33 0.24 41.93 0.11
6 7.01e+05 2686.57 | 2637.08 0.0 1000 0 | 0.37 0.23 42.04 0.11
6 7.16e+05 2686.57 | 1063.86 0.0 369 0 | 0.35 0.23 42.23 0.12
6 7.27e+05 3082.43 |
6 7.27e+05 3082.43 | 3082.43 94.6 967 30 | 0.38 0.23 44.18 0.12
6 7.38e+05 3082.43 | 2714.58 0.0 1000 0 | 0.36 0.23 43.15 0.11
6 7.50e+05 3082.43 | 1576.83 0.0 530 0 | 0.36 0.22 42.79 0.11
6 7.62e+05 3082.43 | 2904.31 0.0 1000 0 | 0.37 0.22 42.24 0.12
6 7.74e+05 3082.43 | 2907.68 0.0 1000 0 | 0.39 0.22 43.42 0.12
6 7.87e+05 3082.43 | 3047.61 0.0 1000 0 | 0.38 0.23 43.15 0.12
6 8.01e+05 3082.43 | 2884.98 0.0 1000 0 | 0.39 0.23 44.60 0.12
6 8.15e+05 3082.43 | 3010.91 0.0 1000 0 | 0.40 0.23 45.58 0.12
6 8.27e+05 3082.43 | 2904.95 0.0 1000 0 | 0.36 0.23 43.33 0.13
6 8.39e+05 3082.43 | 2962.38 0.0 1000 0 | 0.38 0.20 45.61 0.13
6 8.53e+05 3082.43 | 2986.82 0.0 1000 0 | 0.37 0.22 46.55 0.13
6 8.65e+05 3082.43 | 3012.73 0.0 1000 0 | 0.39 0.22 46.56 0.12
6 8.77e+05 3082.43 | 3006.50 0.0 1000 0 | 0.38 0.20 45.55 0.12
6 8.89e+05 3082.43 | 2963.94 0.0 1000 0 | 0.39 0.20 46.11 0.12
6 9.00e+05 3082.43 | 2965.68 0.0 1000 0 | 0.38 0.20 45.67 0.12
6 9.10e+05 3082.43 | 2978.31 0.0 1000 0 | 0.39 0.19 47.14 0.12
6 9.20e+05 3082.43 | 3036.60 0.0 1000 0 | 0.39 0.18 46.73 0.12
6 9.32e+05 3082.43 | 3030.23 0.0 1000 0 | 0.37 0.20 46.14 0.12
6 9.41e+05 3082.43 | 2977.58 0.0 1000 0 | 0.38 0.19 46.32 0.12
6 9.53e+05 3082.43 | 2947.05 0.0 1000 0 | 0.39 0.19 45.68 0.12
6 9.62e+05 3082.43 | 3048.31 0.0 1000 0 | 0.38 0.18 46.31 0.12
6 9.71e+05 3082.43 | 3021.77 0.0 1000 0 | 0.39 0.18 45.73 0.12
| UsedTime: 6967 | SavedDir: ./Hopper-v2_ReliableSACHterm_6
"""
if env_name == 'Swimmer-v3':
from elegantrl.envs.CustomGymEnv import GymNormaEnv
env_func = GymNormaEnv # gym.make
# env_func = gym.make
env_args = {
'action_dim': 2,
'env_name': 'Swimmer-v3',
'env_num': 1,
'if_discrete': False,
'max_step': 1000,
'state_dim': 8,
'target_return': 360.0
}
args = Arguments(agent_class, env_func=env_func, env_args=env_args)
args.num_layer = 3
args.net_dim = 2 ** 8
args.batch_size = int(args.net_dim * 1)
args.worker_num = 4
args.target_step = args.max_step * 1
args.repeat_times = 2 ** -1
args.learning_rate = 2 ** -14
args.clip_grad_norm = 0.7
args.reward_scale = 2 ** -1.5
args.gamma = 0.9991
args.if_act_target = False
args.explore_noise_std = 0.1 # for DPG
'''H-term'''
args.h_term_drop_rate = 2 ** -2
args.h_term_lambda = 2 ** -3
args.h_term_k_step = 16
args.save_gap = 2 ** 6
args.eval_gap = 2 ** 8
args.eval_times = 2 ** 1
# args.break_step = int(2e6)
args.if_allow_break = False
"""
################################################################################
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
1 4.00e+03 -15.39 |
1 4.00e+03 -15.39 | -15.39 5.5 1000 0 | -0.00 0.09 0.88 0.50
1 1.86e+05 17.22 |
1 1.86e+05 17.22 | 17.22 14.5 1000 0 | 0.01 0.02 28.14 0.18
1 2.82e+05 17.22 | 2.89 0.0 1000 0 | 0.00 0.18 42.16 0.08
1 3.56e+05 35.75 |
1 3.56e+05 35.75 | 35.75 0.7 1000 0 | 0.01 0.22 49.82 0.06
1 4.18e+05 63.38 |
1 4.18e+05 63.38 | 63.38 0.3 1000 0 | 0.01 0.02 55.92 0.05
1 4.72e+05 63.38 | 34.66 0.0 1000 0 | 0.01 0.02 62.52 0.05
1 5.20e+05 63.38 | 30.08 0.0 1000 0 | 0.01 0.27 67.09 0.06
1 5.64e+05 63.38 | 20.98 0.0 1000 0 | 0.00 0.01 71.31 0.06
1 6.06e+05 63.38 | 42.71 0.0 1000 0 | 0.00 0.02 75.71 0.05
1 6.44e+05 63.38 | 50.71 0.0 1000 0 | 0.01 0.02 78.97 0.05
1 6.80e+05 63.38 | 23.84 0.0 1000 0 | 0.01 0.01 82.27 0.05
1 7.16e+05 63.38 | -3.54 0.0 1000 0 | 0.01 0.01 83.98 0.05
1 7.50e+05 63.38 | -3.58 0.0 1000 0 | -0.00 0.01 85.43 0.05
1 7.82e+05 63.38 | -10.58 0.0 1000 0 | 0.00 0.02 83.80 0.03
1 8.12e+05 63.38 | 17.53 0.0 1000 0 | -0.00 0.02 84.25 0.03
1 8.42e+05 63.38 | 44.41 0.0 1000 0 | 0.01 0.31 81.29 0.02
1 8.70e+05 63.38 | 14.47 0.0 1000 0 | 0.01 0.01 78.31 0.03
1 8.98e+05 63.38 | 10.96 0.0 1000 0 | 0.01 0.00 76.99 0.03
1 9.26e+05 63.38 | -5.34 0.0 1000 0 | 0.03 0.01 74.78 0.03
1 9.52e+05 63.38 | 47.65 0.0 1000 0 | 0.02 0.01 73.08 0.02
1 9.78e+05 226.58 |
1 9.78e+05 226.58 | 226.58 1.0 1000 0 | 0.04 0.01 70.76 0.03
1 1.00e+06 226.58 | 190.70 0.0 1000 0 | 0.04 0.28 70.07 0.03
1 1.03e+06 226.58 | 196.80 0.0 1000 0 | 0.04 0.29 70.04 0.03
1 1.05e+06 242.39 |
1 1.05e+06 242.39 | 242.39 1.3 1000 0 | 0.05 0.00 68.71 0.03
1 1.07e+06 242.39 | 240.50 0.0 1000 0 | 0.05 0.25 68.40 0.03
1 1.10e+06 242.39 | 235.77 0.0 1000 0 | 0.04 0.01 67.44 0.03
1 1.12e+06 242.39 | 222.76 0.0 1000 0 | 0.05 0.01 66.61 0.03
1 1.14e+06 242.39 | 217.65 0.0 1000 0 | 0.04 0.00 66.57 0.03
1 1.16e+06 242.39 | 231.89 0.0 1000 0 | 0.05 0.00 66.53 0.03
1 1.18e+06 242.39 | 227.81 0.0 1000 0 | 0.05 0.00 67.16 0.03
1 1.21e+06 242.39 | 231.86 0.0 1000 0 | 0.05 0.00 66.92 0.03
1 1.23e+06 242.39 | 231.35 0.0 1000 0 | 0.05 0.00 66.66 0.03
1 1.25e+06 242.39 | 227.46 0.0 1000 0 | 0.05 0.00 66.08 0.03
1 1.27e+06 242.39 | 234.13 0.0 1000 0 | 0.05 0.50 66.24 0.03
1 1.29e+06 242.39 | 229.63 0.0 1000 0 | 0.05 0.00 67.11 0.03
1 1.31e+06 242.39 | 219.31 0.0 1000 0 | 0.05 0.00 68.27 0.03
1 1.33e+06 242.39 | 228.09 0.0 1000 0 | 0.05 0.00 68.09 0.03
1 1.35e+06 242.39 | 239.31 0.0 1000 0 | 0.05 0.28 68.57 0.03
1 1.37e+06 242.39 | 234.14 0.0 1000 0 | 0.04 0.00 69.25 0.03
1 1.39e+06 250.70 |
1 1.39e+06 250.70 | 250.70 3.5 1000 0 | 0.05 0.00 70.63 0.04
1 1.41e+06 250.70 | -18.32 0.0 1000 0 | 0.02 0.25 73.42 0.04
1 1.42e+06 250.70 | 13.04 0.0 1000 0 | 0.00 0.01 78.04 0.07
1 1.44e+06 250.70 | 35.75 0.0 1000 0 | -0.00 0.00 83.02 0.05
1 1.46e+06 250.70 | 32.76 0.0 1000 0 | -0.00 0.00 83.72 0.04
1 1.48e+06 250.70 | -8.30 0.0 1000 0 | 0.00 0.01 85.77 0.05
1 1.50e+06 250.70 | 11.51 0.0 1000 0 | 0.00 0.01 87.79 0.04
1 1.51e+06 250.70 | 61.50 0.0 1000 0 | 0.01 0.01 87.46 0.03
1 1.53e+06 250.70 | 230.86 0.0 1000 0 | 0.02 0.00 86.47 0.03
1 1.55e+06 250.70 | 226.20 0.0 1000 0 | 0.05 0.01 85.31 0.03
1 1.56e+06 250.70 | 201.67 0.0 1000 0 | 0.05 0.00 84.28 0.03
1 1.58e+06 250.70 | 225.26 0.0 1000 0 | 0.05 0.00 83.63 0.03
1 1.60e+06 250.70 | 223.65 0.0 1000 0 | 0.05 0.00 82.61 0.03
1 1.61e+06 250.70 | 241.43 0.0 1000 0 | 0.05 0.00 81.17 0.03
1 1.63e+06 252.85 |
1 1.63e+06 252.85 | 252.85 2.8 1000 0 | 0.05 0.34 80.03 0.03
1 1.64e+06 252.85 | 244.46 0.0 1000 0 | 0.05 0.00 78.56 0.03
1 1.66e+06 252.85 | 240.58 0.0 1000 0 | 0.05 0.00 77.74 0.03
1 1.68e+06 252.85 | 244.16 0.0 1000 0 | 0.05 0.27 76.52 0.03
1 1.69e+06 252.85 | 250.06 0.0 1000 0 | 0.05 0.00 75.40 0.03
1 1.71e+06 252.85 | 244.16 0.0 1000 0 | 0.05 0.00 75.30 0.03
1 1.72e+06 252.85 | 248.74 0.0 1000 0 | 0.05 0.00 74.14 0.03
1 1.74e+06 252.85 | 246.38 0.0 1000 0 | 0.05 0.00 73.63 0.03
1 1.76e+06 252.85 | 234.41 0.0 1000 0 | 0.05 0.00 73.70 0.04
1 1.77e+06 252.85 | 241.64 0.0 1000 0 | 0.05 0.00 74.10 0.03
1 1.79e+06 252.85 | 244.59 0.0 1000 0 | 0.05 0.31 73.19 0.03
1 1.80e+06 252.85 | 240.60 0.0 1000 0 | 0.05 0.00 73.57 0.03
1 1.82e+06 252.85 | 251.79 0.0 1000 0 | 0.05 0.00 74.11 0.03
1 1.83e+06 252.85 | 251.90 0.0 1000 0 | 0.05 0.00 75.44 0.04
1 1.84e+06 252.85 | 242.48 0.0 1000 0 | 0.05 0.00 77.73 0.04
1 1.86e+06 252.85 | -2.39 0.0 1000 0 | 0.00 0.00 83.06 0.06
1 1.87e+06 252.85 | 13.67 0.0 1000 0 | 0.01 0.00 88.56 0.06
1 1.89e+06 252.85 | 22.90 0.0 1000 0 | 0.01 0.01 92.18 0.06
1 1.90e+06 252.85 | 17.74 0.0 1000 0 | 0.00 0.01 97.56 0.06
1 1.91e+06 252.85 | 1.23 0.0 1000 0 | 0.01 0.00 99.37 0.04
1 1.93e+06 252.85 | 22.84 0.0 1000 0 | 0.01 0.38 98.27 0.03
1 1.94e+06 252.85 | 24.15 0.0 1000 0 | 0.01 0.33 97.48 0.04
1 1.96e+06 252.85 | 36.10 0.0 1000 0 | 0.01 0.01 99.23 0.05
1 1.97e+06 252.85 | 11.95 0.0 1000 0 | 0.01 0.00 99.93 0.04
1 1.98e+06 252.85 | 78.70 0.0 1000 0 | 0.01 0.01 98.30 0.03
1 2.00e+06 252.85 | 26.42 0.0 1000 0 | 0.01 0.38 96.47 0.03
1 2.01e+06 252.85 | 244.36 0.0 1000 0 | 0.01 0.37 94.50 0.03
1 2.03e+06 252.85 | 59.06 0.0 1000 0 | 0.01 0.39 93.26 0.04
1 2.04e+06 252.85 | 252.84 0.0 1000 0 | 0.04 0.00 91.76 0.03
1 2.05e+06 273.50 |
1 2.05e+06 273.50 | 273.50 0.1 1000 0 | 0.05 0.00 89.40 0.03
1 2.06e+06 273.50 | 272.89 0.0 1000 0 | 0.05 0.00 86.87 0.03
1 2.08e+06 273.50 | 240.81 0.0 1000 0 | 0.05 0.35 85.54 0.04
1 2.09e+06 273.50 | 256.95 0.0 1000 0 | 0.05 0.00 84.85 0.03
1 2.10e+06 273.50 | 244.67 0.0 1000 0 | 0.05 0.00 83.98 0.03
1 2.11e+06 273.50 | 253.63 0.0 1000 0 | 0.05 0.34 82.46 0.03
1 2.12e+06 273.50 | 263.31 0.0 1000 0 | 0.05 0.01 81.16 0.03
1 2.14e+06 273.50 | 252.39 0.0 1000 0 | 0.05 0.34 79.95 0.03
1 2.15e+06 273.50 | 244.45 0.0 1000 0 | 0.05 0.30 79.09 0.03
1 2.16e+06 273.50 | 255.90 0.0 1000 0 | 0.05 0.00 78.00 0.03
1 2.17e+06 273.50 | 255.95 0.0 1000 0 | 0.05 0.00 78.21 0.03
1 2.18e+06 273.50 | 249.94 0.0 1000 0 | 0.05 0.00 78.31 0.03
1 2.20e+06 273.50 | 253.91 0.0 1000 0 | 0.05 0.00 78.00 0.03
1 2.21e+06 274.55 |
1 2.21e+06 274.55 | 274.55 0.3 1000 0 | 0.05 0.00 77.51 0.03
1 2.22e+06 274.55 | 267.84 0.0 1000 0 | 0.05 0.57 76.41 0.03
1 2.23e+06 279.16 |
1 2.23e+06 279.16 | 279.16 2.5 1000 0 | 0.06 0.00 75.55 0.03
1 2.24e+06 279.16 | 273.00 0.0 1000 0 | 0.05 0.26 74.95 0.03
1 2.26e+06 279.16 | 264.01 0.0 1000 0 | 0.05 0.30 73.58 0.03
1 2.27e+06 279.16 | 267.32 0.0 1000 0 | 0.05 0.00 73.75 0.03
1 2.28e+06 279.16 | 269.79 0.0 1000 0 | 0.05 0.00 72.23 0.03
1 2.29e+06 279.16 | 268.52 0.0 1000 0 | 0.05 0.00 72.87 0.03
1 2.30e+06 279.16 | 265.92 0.0 1000 0 | 0.05 0.25 72.11 0.03
1 2.32e+06 279.16 | 276.36 0.0 1000 0 | 0.05 0.00 71.94 0.03
1 2.33e+06 279.16 | 270.18 0.0 1000 0 | 0.05 0.00 71.86 0.03
1 2.34e+06 279.16 | 268.08 0.0 1000 0 | 0.05 0.00 72.68 0.03
1 2.35e+06 279.16 | 254.55 0.0 1000 0 | 0.05 0.00 71.80 0.03
1 2.36e+06 279.16 | 271.47 0.0 1000 0 | 0.05 0.30 71.55 0.03
1 2.38e+06 279.16 | 263.83 0.0 1000 0 | 0.05 0.00 72.41 0.03
1 2.39e+06 279.16 | 265.38 0.0 1000 0 | 0.05 0.00 72.12 0.03
1 2.40e+06 279.16 | 267.98 0.0 1000 0 | 0.05 0.00 71.99 0.03
1 2.41e+06 279.16 | 268.60 0.0 1000 0 | 0.05 0.00 71.62 0.03
1 2.43e+06 279.16 | 264.70 0.0 1000 0 | 0.05 0.00 72.49 0.03
1 2.44e+06 279.16 | 262.57 0.0 1000 0 | 0.05 0.00 72.16 0.03
1 2.46e+06 279.16 | 256.97 0.0 1000 0 | 0.05 0.00 72.79 0.03
1 2.47e+06 279.16 | 263.02 0.0 1000 0 | 0.05 0.00 72.96 0.03
1 2.48e+06 279.16 | 271.66 0.0 1000 0 | 0.05 0.00 73.30 0.03
1 2.50e+06 279.16 | 275.71 0.0 1000 0 | 0.05 0.00 72.58 0.03
1 3.00e+06 282.71 | 272.30 0.0 1000 0 | 0.06 0.00 75.52 0.03
1 3.01e+06 282.71 | 277.51 0.0 1000 0 | 0.05 0.00 75.08 0.03
1 3.03e+06 282.71 | 277.76 0.0 1000 0 | 0.06 0.00 75.68 0.03
1 3.04e+06 282.71 | 279.86 0.0 1000 0 | 0.06 0.00 74.71 0.03
1 3.05e+06 282.71 | 270.92 0.0 1000 0 | 0.06 0.00 75.04 0.03
1 3.07e+06 282.71 | 271.82 0.0 1000 0 | 0.06 0.00 75.17 0.03
1 3.08e+06 282.71 | 272.38 0.0 1000 0 | 0.06 0.00 74.64 0.03
1 3.09e+06 282.71 | 278.07 0.0 1000 0 | 0.06 0.00 74.59 0.03
1 3.11e+06 282.71 | 278.19 0.0 1000 0 | 0.06 0.00 74.55 0.03
1 3.12e+06 282.71 | 274.46 0.0 1000 0 | 0.06 0.00 74.46 0.03
1 3.13e+06 282.71 | 277.75 0.0 1000 0 | 0.06 0.00 74.46 0.03
1 3.15e+06 282.71 | 273.52 0.0 1000 0 | 0.06 0.30 74.14 0.03
1 3.16e+06 282.71 | 277.32 0.0 1000 0 | 0.06 0.00 73.91 0.03
1 3.17e+06 284.77 |
1 3.17e+06 284.77 | 284.77 0.6 1000 0 | 0.06 0.00 74.40 0.03
1 3.19e+06 284.77 | 282.03 0.0 1000 0 | 0.06 0.25 74.23 0.03
1 3.20e+06 284.77 | 34.92 0.0 1000 0 | 0.01 0.31 82.79 0.07
1 3.21e+06 284.77 | 189.63 0.0 1000 0 | 0.02 0.00 83.09 0.03
1 3.23e+06 284.77 | 265.40 0.0 1000 0 | 0.05 0.00 82.80 0.03
1 3.24e+06 284.77 | 280.59 0.0 1000 0 | 0.06 0.00 81.42 0.03
1 3.25e+06 286.19 |
1 3.25e+06 286.19 | 286.19 0.8 1000 0 | 0.06 0.00 81.49 0.03
1 3.26e+06 286.19 | 279.21 0.0 1000 0 | 0.06 0.27 79.98 0.03
1 3.28e+06 286.19 | 277.80 0.0 1000 0 | 0.06 0.00 80.00 0.03
1 3.29e+06 286.19 | 281.87 0.0 1000 0 | 0.05 0.00 79.75 0.03
1 3.30e+06 286.19 | 284.48 0.0 1000 0 | 0.06 0.32 79.12 0.03
1 3.31e+06 286.19 | 277.54 0.0 1000 0 | 0.06 0.63 78.93 0.03
1 3.33e+06 286.19 | 274.09 0.0 1000 0 | 0.05 0.00 78.19 0.03
1 3.34e+06 286.19 | 277.04 0.0 1000 0 | 0.01 0.00 77.78 0.03
1 3.35e+06 286.19 | 283.19 0.0 1000 0 | 0.06 0.00 77.21 0.03
1 3.36e+06 286.19 | 280.71 0.0 1000 0 | 0.06 0.00 77.49 0.03
1 3.38e+06 286.19 | 277.38 0.0 1000 0 | 0.06 0.00 76.72 0.03
1 3.39e+06 286.19 | 283.72 0.0 1000 0 | 0.06 0.00 76.55 0.03
1 3.40e+06 286.19 | 278.91 0.0 1000 0 | 0.06 0.00 76.37 0.03
1 3.41e+06 286.19 | 273.63 0.0 1000 0 | 0.06 0.00 75.69 0.03
1 3.43e+06 286.19 | 283.73 0.0 1000 0 | 0.06 0.00 76.27 0.03
1 3.44e+06 286.19 | 266.33 0.0 1000 0 | 0.05 0.00 76.06 0.03
1 3.45e+06 288.79 |
1 3.45e+06 288.79 | 288.79 1.5 1000 0 | 0.06 0.00 76.05 0.03
1 3.46e+06 288.79 | 279.64 0.0 1000 0 | 0.06 0.00 76.04 0.03
1 3.48e+06 288.79 | 288.71 1.8 1000 0 | 0.06 0.00 75.77 0.03
1 3.49e+06 288.79 | 282.01 0.0 1000 0 | 0.06 0.00 75.53 0.03
1 3.50e+06 288.79 | 277.28 0.0 1000 0 | 0.06 0.00 75.07 0.03
1 4.00e+06 288.79 | 273.84 0.0 1000 0 | 0.05 0.00 80.36 0.03
1 4.01e+06 288.79 | 279.71 0.0 1000 0 | 0.06 0.00 79.80 0.03
1 4.03e+06 288.79 | 279.59 0.0 1000 0 | 0.06 0.00 78.89 0.03
| UsedTime: 64403 | SavedDir: ./Swimmer-v3_SAC_1
| Learner: Save in ./Swimmer-v3_SAC_1
################################################################################
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
2 4.00e+03 -6.28 |
2 4.00e+03 -6.28 | -6.28 2.6 1000 0 | -0.00 0.79 0.93 0.50
2 2.10e+05 -6.28 | -11.70 0.0 1000 0 | -0.00 0.06 33.38 0.14
2 3.02e+05 23.82 |
2 3.02e+05 23.82 | 23.82 9.6 1000 0 | 0.00 0.09 53.78 0.11
2 3.74e+05 23.82 | 14.50 0.0 1000 0 | 0.00 0.10 68.90 0.09
2 4.34e+05 23.82 | -58.80 0.0 1000 0 | -0.00 0.09 75.72 0.07
2 4.88e+05 47.66 |
2 4.88e+05 47.66 | 47.66 5.9 1000 0 | 0.01 0.09 80.90 0.06
2 5.36e+05 47.66 | 33.35 0.0 1000 0 | 0.01 0.11 84.02 0.05
2 5.82e+05 47.66 | 30.58 0.0 1000 0 | 0.01 0.09 86.48 0.05
2 6.24e+05 47.66 | -7.63 0.0 1000 0 | -0.00 0.10 88.60 0.04
2 6.64e+05 47.66 | 18.22 0.0 1000 0 | 0.00 0.10 89.48 0.04
2 7.02e+05 47.66 | 34.68 0.0 1000 0 | 0.01 0.11 87.96 0.04
2 7.38e+05 59.89 |
2 7.38e+05 59.89 | 59.89 0.5 1000 0 | 0.01 0.08 87.32 0.04
2 7.72e+05 59.89 | 30.50 0.0 1000 0 | 0.01 0.09 84.90 0.03
2 8.04e+05 59.89 | 51.30 0.0 1000 0 | 0.01 0.08 81.95 0.03
2 8.36e+05 59.89 | 42.13 0.0 1000 0 | 0.01 0.10 78.65 0.02
2 8.66e+05 59.89 | 41.95 0.0 1000 0 | 0.01 0.10 76.30 0.03
2 8.96e+05 59.89 | 48.86 0.0 1000 0 | 0.01 0.08 74.73 0.03
2 9.24e+05 59.89 | 12.75 0.0 1000 0 | 0.01 0.08 71.93 0.02
2 9.52e+05 59.89 | 43.57 0.0 1000 0 | 0.01 0.08 69.69 0.02
2 9.78e+05 59.89 | 52.49 0.0 1000 0 | 0.01 0.08 67.37 0.02
2 1.00e+06 59.89 | 57.30 0.0 1000 0 | 0.01 0.06 65.46 0.02
2 1.03e+06 59.89 | 36.17 0.0 1000 0 | 0.01 0.07 63.51 0.02
2 1.05e+06 62.24 |
2 1.05e+06 62.24 | 62.24 4.4 1000 0 | 0.02 0.07 61.56 0.02
2 1.08e+06 99.75 |
2 1.08e+06 99.75 | 99.75 0.5 1000 0 | 0.02 0.07 59.61 0.02
2 1.10e+06 99.75 | 36.13 0.0 1000 0 | 0.03 0.06 57.29 0.02
2 1.12e+06 179.45 |
2 1.12e+06 179.45 | 179.45 1.3 1000 0 | 0.03 0.05 56.03 0.02
2 1.15e+06 179.45 | 58.21 0.0 1000 0 | 0.03 0.06 55.73 0.02
2 1.17e+06 179.45 | 110.22 0.0 1000 0 | 0.04 0.06 55.51 0.03
2 1.19e+06 207.64 |
2 1.19e+06 207.64 | 207.64 2.1 1000 0 | 0.04 0.06 55.21 0.03
2 1.21e+06 216.00 |
2 1.21e+06 216.00 | 216.00 0.4 1000 0 | 0.05 0.05 55.78 0.03
2 1.23e+06 216.00 | 215.36 0.0 1000 0 | 0.04 0.06 55.62 0.03
2 1.25e+06 220.60 |
2 1.25e+06 220.60 | 220.60 1.8 1000 0 | 0.05 0.06 55.78 0.03
2 1.27e+06 244.95 |
2 1.27e+06 244.95 | 244.95 2.8 1000 0 | 0.05 0.05 55.95 0.03
2 1.30e+06 257.70 |
2 1.30e+06 257.70 | 257.70 0.4 1000 0 | 0.05 0.06 56.90 0.03
2 1.32e+06 257.70 | 242.88 0.0 1000 0 | 0.05 0.05 57.62 0.03
2 1.34e+06 259.86 |
2 1.34e+06 259.86 | 259.86 0.6 1000 0 | 0.05 0.06 57.92 0.03
2 1.36e+06 259.86 | 230.05 0.0 1000 0 | 0.05 0.07 58.70 0.03
2 1.38e+06 259.86 | 256.39 0.0 1000 0 | 0.05 0.06 59.14 0.03
2 1.40e+06 261.23 |
2 1.40e+06 261.23 | 261.23 2.4 1000 0 | 0.05 0.05 60.07 0.03
2 1.42e+06 261.23 | 251.52 0.0 1000 0 | 0.05 0.06 60.80 0.03
2 1.44e+06 271.11 |
2 1.44e+06 271.11 | 271.11 1.7 1000 0 | 0.05 0.07 62.13 0.03
2 1.46e+06 271.11 | 247.82 0.0 1000 0 | 0.05 0.08 62.74 0.03
2 1.48e+06 271.11 | 233.00 0.0 1000 0 | 0.05 0.07 64.83 0.04
2 1.50e+06 271.11 | 252.08 0.0 1000 0 | 0.04 0.07 66.22 0.04
2 1.51e+06 271.11 | 3.42 0.0 1000 0 | 0.04 0.08 69.69 0.04
2 1.53e+06 271.11 | 17.14 0.0 1000 0 | 0.01 0.07 73.58 0.05
2 1.55e+06 271.11 | 12.62 0.0 1000 0 | 0.01 0.08 75.60 0.04
2 1.57e+06 271.11 | 46.57 0.0 1000 0 | 0.01 0.09 75.32 0.03
2 1.59e+06 271.11 | 238.78 0.0 1000 0 | 0.03 0.09 74.76 0.03
2 1.60e+06 271.11 | 267.25 0.0 1000 0 | 0.06 0.08 72.93 0.03
2 1.62e+06 271.11 | 266.43 0.0 1000 0 | 0.05 0.07 72.23 0.03
2 1.64e+06 278.36 |
2 1.64e+06 278.36 | 278.36 0.5 1000 0 | 0.05 0.07 71.94 0.03
2 1.66e+06 278.36 | 266.06 0.0 1000 0 | 0.05 0.08 72.14 0.03
2 1.67e+06 279.56 |
2 1.67e+06 279.56 | 279.56 0.4 1000 0 | 0.05 0.07 71.28 0.03
2 1.69e+06 279.56 | 270.07 0.0 1000 0 | 0.05 0.07 71.56 0.03
2 1.71e+06 279.56 | 264.37 0.0 1000 0 | 0.05 0.07 71.32 0.03
2 1.72e+06 279.56 | 273.81 0.0 1000 0 | 0.05 0.08 71.46 0.03
2 1.74e+06 279.56 | 262.90 0.0 1000 0 | 0.05 0.07 71.01 0.03
2 1.75e+06 279.56 | 275.06 0.0 1000 0 | 0.05 0.08 70.64 0.03
2 1.77e+06 279.56 | 273.48 0.0 1000 0 | 0.05 0.06 71.13 0.03
2 1.79e+06 279.56 | 264.31 0.0 1000 0 | 0.05 0.06 71.08 0.03
2 1.80e+06 279.56 | 257.98 0.0 1000 0 | 0.05 0.08 70.57 0.03
2 1.82e+06 279.56 | 263.28 0.0 1000 0 | 0.05 0.07 71.35 0.03
2 1.83e+06 279.56 | 260.41 0.0 1000 0 | 0.05 0.06 70.98 0.03
2 1.85e+06 279.56 | 265.36 0.0 1000 0 | 0.05 0.07 70.71 0.03
2 1.87e+06 279.56 | 270.74 0.0 1000 0 | 0.06 0.07 70.96 0.03
2 1.88e+06 279.56 | 268.11 0.0 1000 0 | 0.05 0.08 70.78 0.03
2 1.90e+06 279.56 | 275.53 0.0 1000 0 | 0.06 0.07 71.73 0.03
2 1.91e+06 281.30 |
2 1.91e+06 281.30 | 281.30 0.9 1000 0 | 0.06 0.07 71.17 0.03
2 1.93e+06 283.31 |
2 1.93e+06 283.31 | 283.31 1.1 1000 0 | 0.06 0.09 72.06 0.03
2 1.94e+06 283.31 | 276.43 0.0 1000 0 | 0.05 0.07 72.16 0.03
2 1.96e+06 283.31 | 275.59 0.0 1000 0 | 0.06 0.07 72.94 0.03
2 1.97e+06 283.31 | 271.83 0.0 1000 0 | 0.05 0.07 72.90 0.03
2 1.98e+06 283.31 | 272.16 0.0 1000 0 | 0.06 0.06 72.23 0.03
2 2.00e+06 283.31 | 268.55 0.0 1000 0 | 0.06 0.06 72.76 0.03
2 4.00e+06 287.57 | 286.08 0.0 1000 0 | 0.06 0.07 86.54 0.03
2 4.01e+06 287.57 | 27.04 0.0 1000 0 | 0.01 0.09 86.45 0.03
2 4.02e+06 287.57 | 276.14 0.0 1000 0 | 0.05 0.09 86.05 0.03
2 4.04e+06 289.87 |
2 4.04e+06 289.87 | 289.87 3.1 1000 0 | 0.06 0.10 84.75 0.03
2 4.05e+06 289.87 | 283.59 0.0 1000 0 | 0.06 0.08 83.82 0.03
2 4.07e+06 289.87 | 284.69 0.0 1000 0 | 0.06 0.08 83.22 0.03
2 4.08e+06 289.87 | 279.18 0.0 1000 0 | 0.06 0.08 82.78 0.03
2 4.09e+06 289.87 | 281.33 0.0 1000 0 | 0.06 0.07 82.22 0.03
2 4.11e+06 289.87 | 246.89 0.0 1000 0 | 0.01 0.08 81.90 0.03
2 4.12e+06 289.87 | 287.04 0.0 1000 0 | 0.06 0.08 81.40 0.03
2 4.14e+06 289.87 | 286.29 0.0 1000 0 | 0.06 0.07 81.13 0.03
2 4.15e+06 289.87 | 280.49 0.0 1000 0 | 0.06 0.08 80.96 0.03
2 4.16e+06 289.87 | 288.86 0.0 1000 0 | 0.05 0.09 80.75 0.03
2 4.18e+06 289.87 | 287.55 0.0 1000 0 | 0.06 0.09 80.62 0.03
2 4.19e+06 289.87 | 281.04 0.0 1000 0 | 0.06 0.08 79.82 0.03
2 4.21e+06 289.87 | 280.87 0.0 1000 0 | 0.06 0.09 80.20 0.03
| UsedTime: 64429 | SavedDir: ./Swimmer-v3_ReSAC_2
| Learner: Save in ./Swimmer-v3_ReSAC_2
################################################################################
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
3 4.00e+03 -8.57 |
3 4.00e+03 -8.57 | -8.57 1.5 1000 0 | 0.00 0.79 0.89 0.50
3 2.16e+05 31.39 |
3 2.16e+05 31.39 | 31.39 1.8 1000 0 | 0.02 0.10 38.48 0.14
3 3.12e+05 37.02 |
3 3.12e+05 37.02 | 37.02 3.1 1000 0 | 0.02 0.11 58.60 0.11
3 3.86e+05 37.02 | 14.92 0.0 1000 0 | 0.01 0.11 74.82 0.10
3 4.48e+05 37.02 | 18.02 0.0 1000 0 | 0.01 0.13 89.95 0.09
3 5.02e+05 37.02 | 7.93 0.0 1000 0 | 0.00 0.13 98.66 0.09
3 5.52e+05 37.02 | 7.09 0.0 1000 0 | 0.01 0.14 108.21 0.08
3 5.98e+05 37.02 | 27.86 0.0 1000 0 | 0.01 0.15 113.27 0.09
3 6.40e+05 37.02 | 20.95 0.0 1000 0 | 0.02 0.15 116.43 0.08
3 6.80e+05 37.02 | 24.06 0.0 1000 0 | 0.01 0.15 117.68 0.06
3 7.18e+05 37.02 | 7.78 0.0 1000 0 | -0.01 0.12 123.53 0.07
3 7.54e+05 40.66 |
3 7.54e+05 40.66 | 40.66 0.1 1000 0 | 0.01 0.17 126.84 0.08
3 7.88e+05 40.66 | 21.68 0.0 1000 0 | 0.01 0.16 134.54 0.09
3 8.22e+05 40.66 | 22.85 0.0 1000 0 | 0.01 0.17 135.28 0.07
3 8.54e+05 45.03 |
3 8.54e+05 45.03 | 45.03 0.5 1000 0 | 0.03 0.16 134.01 0.07
3 8.86e+05 45.03 | 43.95 0.0 1000 0 | 0.05 0.14 133.89 0.07
3 9.16e+05 45.03 | 34.65 0.0 1000 0 | 0.07 0.16 132.55 0.05
3 9.46e+05 112.01 |
3 9.46e+05 112.01 | 112.01 0.9 1000 0 | 0.05 0.16 129.19 0.06
3 9.74e+05 112.01 | 84.85 0.0 1000 0 | 0.04 0.13 130.59 0.06
3 1.00e+06 112.01 | 16.83 0.0 1000 0 | 0.01 0.13 133.01 0.07
3 1.03e+06 112.01 | 43.08 0.0 1000 0 | 0.00 0.14 135.57 0.08
3 1.05e+06 112.01 | 55.34 0.0 1000 0 | 0.02 0.17 139.34 0.07
3 1.08e+06 112.01 | 12.76 0.0 1000 0 | 0.01 0.17 138.87 0.06
3 1.11e+06 199.25 |
3 1.11e+06 199.25 | 199.25 3.7 1000 0 | 0.07 0.16 136.65 0.06
3 1.13e+06 215.78 |
3 1.13e+06 215.78 | 215.78 5.7 1000 0 | 0.07 0.14 138.30 0.06
3 1.15e+06 231.73 |
3 1.15e+06 231.73 | 231.73 0.1 1000 0 | 0.08 0.14 135.88 0.06
3 1.18e+06 231.73 | 96.06 0.0 1000 0 | 0.10 0.15 133.84 0.05
3 1.20e+06 252.84 |
3 1.20e+06 252.84 | 252.84 1.9 1000 0 | 0.10 0.13 130.86 0.05
3 1.22e+06 252.84 | 238.23 0.0 1000 0 | 0.10 0.14 128.67 0.06
3 1.25e+06 252.84 | 245.16 0.0 1000 0 | 0.10 0.13 128.37 0.05
3 1.27e+06 252.84 | 243.16 0.0 1000 0 | 0.10 0.14 127.71 0.06
3 1.29e+06 252.84 | 249.43 0.0 1000 0 | 0.10 0.13 127.30 0.06
3 1.31e+06 252.84 | 236.17 0.0 1000 0 | 0.10 0.13 128.10 0.07
3 1.33e+06 252.84 | 250.43 0.0 1000 0 | 0.10 0.13 127.73 0.06
3 1.35e+06 252.84 | 238.49 0.0 1000 0 | 0.10 0.11 126.85 0.06
3 1.37e+06 255.28 |
3 1.37e+06 255.28 | 255.28 0.4 1000 0 | 0.10 0.16 127.16 0.06
3 1.39e+06 255.28 | 233.57 0.0 1000 0 | 0.10 0.14 128.99 0.06
3 1.41e+06 255.28 | 244.09 0.0 1000 0 | 0.11 0.12 130.26 0.06
3 1.43e+06 255.28 | 235.71 0.0 1000 0 | 0.09 0.14 129.95 0.07
3 1.45e+06 255.28 | 246.59 0.0 1000 0 | 0.10 0.13 129.46 0.06
3 1.47e+06 255.28 | 247.30 0.0 1000 0 | 0.10 0.15 131.86 0.07
3 1.49e+06 255.28 | 246.46 0.0 1000 0 | 0.10 0.13 132.77 0.06
3 1.50e+06 255.28 | 235.29 0.0 1000 0 | 0.10 0.13 133.17 0.08
3 1.52e+06 255.28 | 92.90 0.0 1000 0 | 0.08 0.15 140.81 0.08
3 1.54e+06 255.28 | -8.49 0.0 1000 0 | 0.02 0.17 144.82 0.10
3 1.56e+06 255.28 | 18.62 0.0 1000 0 | 0.01 0.18 159.15 0.10
3 1.58e+06 255.28 | 12.88 0.0 1000 0 | 0.00 0.20 161.08 0.08
3 1.59e+06 255.28 | 249.60 0.0 1000 0 | 0.02 0.19 160.45 0.07
3 1.61e+06 255.28 | 245.90 0.0 1000 0 | 0.09 0.16 158.35 0.06
3 1.63e+06 255.28 | 253.69 0.0 1000 0 | 0.10 0.15 157.53 0.06
3 1.65e+06 256.24 |
3 1.65e+06 256.24 | 256.24 1.8 1000 0 | 0.10 0.17 154.70 0.06
3 1.66e+06 257.26 |
3 1.66e+06 257.26 | 257.26 1.0 1000 0 | 0.10 0.17 152.74 0.06
3 1.68e+06 261.95 |
3 1.68e+06 261.95 | 261.95 2.2 1000 0 | 0.10 0.16 149.32 0.06
3 1.70e+06 261.95 | 259.62 2.4 1000 0 | 0.10 0.17 150.72 0.06
3 1.71e+06 261.95 | 248.64 0.0 1000 0 | 0.10 0.15 148.57 0.06
3 1.73e+06 261.95 | 249.29 0.0 1000 0 | 0.10 0.13 146.17 0.07
3 1.74e+06 261.95 | 249.37 0.0 1000 0 | 0.09 0.15 147.29 0.06
3 1.76e+06 261.95 | 245.88 0.0 1000 0 | 0.10 0.16 145.84 0.07
3 1.78e+06 261.95 | 261.27 0.0 1000 0 | 0.10 0.16 146.70 0.07
3 1.79e+06 261.95 | 259.66 0.0 1000 0 | 0.05 0.16 150.79 0.06
3 1.81e+06 261.95 | 260.88 0.0 1000 0 | 0.10 0.15 146.73 0.06
3 1.82e+06 261.95 | 242.13 0.0 1000 0 | 0.11 0.17 145.80 0.07
3 1.84e+06 261.95 | 257.71 0.0 1000 0 | 0.10 0.18 147.04 0.06
3 1.86e+06 261.95 | 260.06 0.0 1000 0 | 0.10 0.14 146.52 0.07
3 1.87e+06 261.95 | 245.67 0.0 1000 0 | 0.11 0.14 146.18 0.07
3 1.89e+06 261.95 | 237.52 0.0 1000 0 | 0.10 0.14 148.21 0.08
3 1.90e+06 261.95 | 259.79 0.0 1000 0 | 0.10 0.14 149.33 0.06
3 1.92e+06 261.95 | 258.17 0.0 1000 0 | 0.11 0.14 148.37 0.06
3 1.93e+06 261.95 | 253.84 0.0 1000 0 | 0.11 0.14 146.93 0.06
3 1.94e+06 261.95 | 254.08 0.0 1000 0 | 0.10 0.18 146.73 0.06
3 1.96e+06 261.95 | 251.79 0.0 1000 0 | 0.11 0.15 143.88 0.06
3 1.97e+06 261.95 | 253.61 0.0 1000 0 | 0.11 0.15 144.74 0.06
3 1.99e+06 261.95 | 261.72 0.0 1000 0 | 0.11 0.14 143.76 0.07
3 2.00e+06 263.24 |
3 2.00e+06 263.24 | 263.24 0.5 1000 0 | 0.09 0.16 147.80 0.07
3 2.01e+06 263.24 | 249.24 0.0 1000 0 | 0.10 0.17 150.97 0.07
3 2.03e+06 270.97 |
3 2.03e+06 270.97 | 270.97 0.4 1000 0 | 0.11 0.14 149.13 0.06
3 2.04e+06 272.27 |
3 2.04e+06 272.27 | 272.27 0.4 1000 0 | 0.11 0.15 147.54 0.06
3 2.06e+06 279.06 |
3 2.06e+06 279.06 | 279.06 1.4 1000 0 | 0.11 0.15 146.70 0.06
3 2.07e+06 279.06 | 262.20 0.0 1000 0 | 0.11 0.15 146.47 0.06
3 2.08e+06 279.06 | 92.01 0.0 1000 0 | 0.10 0.16 145.97 0.08
3 2.10e+06 279.06 | 45.48 0.0 1000 0 | 0.04 0.16 150.03 0.08
3 2.11e+06 279.06 | 266.86 0.0 1000 0 | 0.05 0.15 149.27 0.06
3 2.12e+06 279.06 | 259.74 0.0 1000 0 | 0.10 0.17 148.94 0.06
3 2.14e+06 279.06 | 277.93 0.0 1000 0 | 0.11 0.17 148.45 0.06
3 2.15e+06 279.06 | 274.22 0.0 1000 0 | 0.11 0.17 147.41 0.06
3 2.17e+06 279.06 | 229.47 0.0 1000 0 | 0.11 0.13 149.58 0.08
3 2.18e+06 279.06 | 268.43 0.0 1000 0 | 0.11 0.15 148.77 0.06
3 2.19e+06 279.06 | 270.04 0.0 1000 0 | 0.11 0.15 147.16 0.06
3 2.21e+06 279.06 | 258.05 0.0 1000 0 | 0.10 0.14 147.61 0.07
3 2.22e+06 279.06 | 261.98 0.0 1000 0 | 0.11 0.17 150.39 0.07
3 2.24e+06 279.06 | 268.90 0.0 1000 0 | 0.11 0.19 149.27 0.07
3 2.25e+06 279.06 | 277.89 0.0 1000 0 | 0.11 0.17 150.75 0.06
3 2.26e+06 279.06 | 277.51 0.0 1000 0 | 0.11 0.15 149.34 0.06
3 2.28e+06 279.06 | 276.45 0.0 1000 0 | 0.11 0.16 148.45 0.06
3 2.29e+06 279.06 | 276.91 0.0 1000 0 | 0.11 0.16 146.36 0.06
3 2.31e+06 279.06 | 273.43 0.0 1000 0 | 0.11 0.15 147.01 0.06
3 2.32e+06 279.06 | 264.30 0.0 1000 0 | 0.10 0.17 147.23 0.06
3 2.33e+06 279.06 | 272.07 0.0 1000 0 | 0.10 0.15 148.60 0.06
3 2.35e+06 279.06 | 267.41 0.0 1000 0 | 0.11 0.15 148.22 0.06
3 2.36e+06 279.06 | 273.78 0.0 1000 0 | 0.11 0.19 148.15 0.06
3 2.38e+06 279.06 | 274.00 0.0 1000 0 | 0.10 0.15 148.18 0.06
3 2.39e+06 279.06 | 264.71 0.0 1000 0 | 0.11 0.16 149.14 0.07
3 2.40e+06 279.06 | 266.69 0.0 1000 0 | 0.06 0.16 151.73 0.07
3 2.42e+06 279.51 |
3 2.42e+06 279.51 | 279.51 1.6 1000 0 | 0.09 0.16 154.09 0.06
3 2.43e+06 280.29 |
3 2.43e+06 280.29 | 280.29 0.8 1000 0 | 0.11 0.17 153.12 0.06
3 2.45e+06 280.29 | 262.86 0.0 1000 0 | 0.11 0.17 153.20 0.06
3 2.46e+06 280.29 | 273.96 0.0 1000 0 | 0.10 0.18 152.18 0.06
3 2.47e+06 281.82 |
3 2.47e+06 281.82 | 281.82 0.2 1000 0 | 0.11 0.17 153.48 0.06
3 2.49e+06 281.82 | 263.43 0.0 1000 0 | 0.12 0.16 151.74 0.06
3 2.50e+06 281.82 | 260.68 0.0 1000 0 | 0.10 0.15 154.54 0.07
3 2.52e+06 281.82 | 268.88 0.0 1000 0 | 0.10 0.16 154.29 0.06
3 2.53e+06 281.82 | 267.59 0.0 1000 0 | 0.11 0.15 153.52 0.06
3 2.54e+06 281.82 | 278.41 0.0 1000 0 | 0.11 0.13 153.54 0.06
3 2.56e+06 281.82 | 272.29 0.0 1000 0 | 0.11 0.16 152.92 0.06
3 2.57e+06 281.82 | 267.83 0.0 1000 0 | 0.11 0.17 152.42 0.06
3 2.59e+06 281.82 | 263.96 0.0 1000 0 | 0.11 0.17 154.01 0.06
3 2.60e+06 281.82 | 280.84 0.0 1000 0 | 0.11 0.16 153.49 0.06
3 2.61e+06 287.28 |
3 2.61e+06 287.28 | 287.28 0.2 1000 0 | 0.11 0.15 152.73 0.06
3 3.50e+06 287.28 | 38.06 0.0 1000 0 | -0.01 0.27 230.10 0.10
3 3.51e+06 287.28 | 13.15 0.0 1000 0 | -0.00 0.23 230.06 0.08
3 3.52e+06 287.28 | 43.99 0.0 1000 0 | 0.02 0.23 231.44 0.10
3 3.54e+06 287.28 | -0.56 0.0 1000 0 | 0.01 0.25 238.56 0.13
3 3.55e+06 287.28 | 46.62 0.0 1000 0 | 0.04 0.22 234.65 0.07
3 3.57e+06 287.28 | 31.43 0.0 1000 0 | 0.01 0.26 236.88 0.10
3 3.58e+06 287.28 | 105.30 0.0 1000 0 | 0.04 0.23 231.16 0.06
3 3.59e+06 287.28 | 258.81 0.0 1000 0 | 0.00 0.23 224.03 0.06
3 3.61e+06 287.28 | 256.95 0.0 1000 0 | 0.10 0.25 215.33 0.06
3 3.62e+06 287.28 | 253.97 0.0 1000 0 | 0.10 0.21 209.44 0.06
3 3.64e+06 287.28 | 265.32 0.0 1000 0 | 0.11 0.22 204.07 0.06
3 3.65e+06 287.28 | 269.82 0.0 1000 0 | 0.10 0.20 197.73 0.06
3 3.66e+06 287.28 | 265.63 0.0 1000 0 | 0.11 0.22 192.48 0.06
3 3.68e+06 287.28 | 270.77 0.0 1000 0 | 0.11 0.25 189.75 0.06
3 3.69e+06 287.28 | 256.46 0.0 1000 0 | 0.10 0.19 187.02 0.06
3 3.71e+06 287.28 | 273.00 0.0 1000 0 | 0.10 0.19 182.82 0.06
| UsedTime: 52955 | SavedDir: ./Swimmer-v3_ReSAC_3
| Learner: Save in ./Swimmer-v3_ReSAC_3
"""
elif env_name == 'Ant-v3':
from elegantrl.envs.CustomGymEnv import AntEnv
env_func = AntEnv
env_args = {
'env_num': 1,
'env_name': 'Ant-v3',
'max_step': 1000,
'state_dim': 27, # original MuJoCo Ant state_dim is 111
'action_dim': 8,
'if_discrete': False,
'target_return': 6000.0,
}
args = Arguments(agent_class, env_func=env_func, env_args=env_args)
args.reward_scale = 2 ** -4
args.num_layer = 3
args.net_dim = 2 ** 8
args.batch_size = int(args.net_dim * 2)
args.worker_num = 2
args.target_step = args.max_step
if gpu_id == 1:
args.repeat_times = 2 ** -1
if gpu_id == 2:
args.repeat_times = 2 ** -0
args.reward_scale = 2 ** -4
args.learning_rate = 2 ** -15
args.clip_grad_norm = 1.0
args.gamma = 0.985
args.if_act_target = False
args.explore_noise_std = 0.1 # for DPG
'''H-term'''
args.h_term_drop_rate = 2 ** -2
args.h_term_lambda = 2 ** -3
args.h_term_update_gap = 1
args.h_term_k_step = 8
args.eval_gap = 2 ** 8
args.eval_times = 2 ** 1
args.break_step = int(4e6)
args.if_allow_break = False
elif env_name == 'HalfCheetah-v3':
env_func = gym.make
env_args = {
'env_num': 1,
'env_name': 'HalfCheetah-v3',
'max_step': 1000,
'state_dim': 17,
'action_dim': 6,
'if_discrete': False,
'target_return': 4800.0,
}
args = Arguments(agent_class, env_func=env_func, env_args=env_args)
args.num_layer = 3
args.net_dim = 2 ** 8
args.batch_size = int(args.net_dim * 2)
args.worker_num = 2
args.target_step = args.max_step
args.repeat_times = 2 ** 0
args.reward_scale = 2 ** -2
args.learning_rate = 2 ** -15
args.clip_grad_norm = 1.0
args.gamma = 0.99
args.if_act_target = False
args.explore_noise_std = 0.06 # for Deterministic Policy Gradient Algorithms
args.h_term_sample_rate = 2 ** -2
args.h_term_drop_rate = 2 ** -4
args.h_term_lambda = 2 ** -3
args.h_term_k_step = 8
args.h_term_update_gap = 1
args.eval_times = 2 ** 2
args.eval_gap = 2 ** 8
args.if_allow_break = False
args.break_step = int(2e6)
"""
| Arguments Remove cwd: ./HalfCheetah-v3_ReSACHtermK_3
################################################################################
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
3 4.00e+03 -1.39 |
3 4.00e+03 -1.39 | -1.39 0.5 1000 0 | -0.10 0.79 0.90 0.17
3 2.18e+05 -1.39 | -76.11 0.0 1000 0 | -0.05 0.08 22.69 0.08
3 3.18e+05 43.30 |
3 3.18e+05 43.30 | 43.30 1.2 1000 0 | -0.05 0.07 18.25 0.04
3 3.94e+05 125.56 |
3 3.94e+05 125.56 | 125.56 7.4 1000 0 | 0.02 0.06 10.85 0.02
3 4.58e+05 125.56 | 92.03 0.0 1000 0 | 0.03 0.07 8.03 0.02
3 5.14e+05 1987.69 |
3 5.14e+05 1987.69 | 1987.69 127.4 1000 0 | 0.37 0.09 11.54 0.03
3 5.66e+05 3067.60 |
3 5.66e+05 3067.60 | 3067.60 111.1 1000 0 | 0.56 0.12 20.94 0.05
3 6.14e+05 3067.60 | 3047.10 0.0 1000 0 | 0.63 0.14 31.82 0.06
3 6.58e+05 3419.64 |
3 6.58e+05 3419.64 | 3419.64 196.4 1000 0 | 0.63 0.16 38.22 0.07
3 7.00e+05 4479.39 |
3 7.00e+05 4479.39 | 4479.39 128.4 1000 0 | 0.73 0.19 44.35 0.08
3 7.40e+05 4479.39 | 4374.80 0.0 1000 0 | 0.42 0.20 52.62 0.09
3 7.78e+05 4735.05 |
3 7.78e+05 4735.05 | 4735.05 52.2 1000 0 | 0.47 0.22 58.21 0.10
3 8.14e+05 4982.37 |
3 8.14e+05 4982.37 | 4982.37 95.9 1000 0 | 0.57 0.25 64.77 0.11
3 8.48e+05 4982.37 | 4972.69 78.8 1000 0 | 1.04 0.26 71.71 0.12
3 8.82e+05 5138.24 |
3 8.82e+05 5138.24 | 5138.24 59.6 1000 0 | 1.05 0.27 76.37 0.13
3 9.14e+05 5358.65 |
3 9.14e+05 5358.65 | 5358.65 39.9 1000 0 | 0.90 0.28 79.15 0.14
3 9.44e+05 5513.26 |
3 9.44e+05 5513.26 | 5513.26 49.8 1000 0 | 1.12 0.30 86.21 0.14
3 9.74e+05 5792.31 |
3 9.74e+05 5792.31 | 5792.31 14.8 1000 0 | 1.13 0.30 88.94 0.15
3 1.00e+06 6201.82 |
3 1.00e+06 6201.82 | 6201.82 99.0 1000 0 | 1.14 0.29 91.15 0.15
3 1.03e+06 6231.47 |
3 1.03e+06 6231.47 | 6231.47 18.0 1000 0 | 1.15 0.29 94.13 0.15
3 1.06e+06 6351.26 |
3 1.06e+06 6351.26 | 6351.26 18.0 1000 0 | 1.18 0.31 98.83 0.16
3 1.09e+06 6351.26 | 6310.33 0.0 1000 0 | 1.19 0.30 99.90 0.16
3 1.11e+06 6448.37 |
3 1.11e+06 6448.37 | 6448.37 40.0 1000 0 | 1.28 0.31 104.14 0.17
3 1.14e+06 6503.69 |
3 1.14e+06 6503.69 | 6503.69 55.2 1000 0 | 1.20 0.31 106.30 0.17
3 1.16e+06 6634.65 |
3 1.16e+06 6634.65 | 6634.65 32.4 1000 0 | 1.26 0.33 110.47 0.18
3 1.19e+06 6806.41 |
3 1.19e+06 6806.41 | 6806.41 28.9 1000 0 | 0.76 0.33 112.88 0.18
3 1.21e+06 6806.41 | 6636.09 0.0 1000 0 | 1.33 0.33 113.24 0.19
3 1.23e+06 6806.41 | 6796.92 0.0 1000 0 | 1.31 0.34 117.10 0.19
3 1.26e+06 7397.30 |
3 1.26e+06 7397.30 | 7397.30 20.6 1000 0 | 1.37 0.33 119.25 0.19
3 1.28e+06 7397.30 | 6963.20 0.0 1000 0 | 1.37 0.34 122.57 0.20
3 1.30e+06 7397.30 | 6780.81 0.0 1000 0 | 1.37 0.34 123.37 0.20
3 1.32e+06 7397.30 | 7288.38 104.9 1000 0 | 1.33 0.37 126.17 0.20
3 1.35e+06 7397.30 | 7395.82 73.6 1000 0 | 0.98 0.37 129.24 0.21
3 1.37e+06 7397.30 | 7259.02 0.0 1000 0 | 1.01 0.35 130.45 0.21
3 1.39e+06 7473.38 |
3 1.39e+06 7473.38 | 7473.38 23.7 1000 0 | 1.34 0.35 133.29 0.21
3 1.41e+06 7473.38 | 7296.84 0.0 1000 0 | 0.74 0.34 132.32 0.21
3 1.43e+06 7690.11 |
3 1.43e+06 7690.11 | 7690.11 49.4 1000 0 | 1.39 0.35 135.86 0.22
3 1.45e+06 7690.11 | 7085.11 0.0 1000 0 | 1.42 0.34 134.77 0.22
3 1.47e+06 7836.31 |
3 1.47e+06 7836.31 | 7836.31 30.4 1000 0 | 1.40 0.37 135.36 0.22
3 1.49e+06 7836.31 | 7811.68 0.0 1000 0 | 1.44 0.36 136.65 0.22
3 1.51e+06 7852.93 |
3 1.51e+06 7852.93 | 7852.93 64.6 1000 0 | 1.42 0.38 139.22 0.23
3 1.53e+06 8111.26 |
3 1.53e+06 8111.26 | 8111.26 67.1 1000 0 | 1.44 0.35 141.00 0.23
3 1.55e+06 8111.26 | 7783.44 0.0 1000 0 | 1.41 0.37 143.12 0.23
3 1.57e+06 8111.26 | 7912.26 0.0 1000 0 | 1.39 0.37 143.35 0.23
3 1.59e+06 8186.29 |
3 1.59e+06 8186.29 | 8186.29 52.2 1000 0 | 1.44 0.36 143.15 0.23
3 1.60e+06 8186.29 | 7831.40 0.0 1000 0 | 1.47 0.37 143.97 0.24
3 1.62e+06 8186.29 | 7956.68 0.0 1000 0 | 1.41 0.37 145.58 0.24
3 1.64e+06 8186.29 | 7874.28 0.0 1000 0 | 1.43 0.39 144.94 0.24
3 1.66e+06 8186.29 | 7865.58 0.0 1000 0 | 1.42 0.37 147.75 0.24
3 1.68e+06 8186.29 | 8087.30 0.0 1000 0 | 1.49 0.37 148.83 0.24
3 1.69e+06 8186.29 | 7859.09 0.0 1000 0 | 1.15 0.39 149.60 0.24
3 1.71e+06 8186.29 | 7835.63 0.0 1000 0 | 1.44 0.38 148.29 0.25
3 1.73e+06 8186.29 | 7835.96 0.0 1000 0 | 1.16 0.36 151.08 0.25
3 1.75e+06 8186.29 | 7943.81 0.0 1000 0 | 1.46 0.37 150.49 0.25
3 1.77e+06 8186.29 | 8072.43 0.0 1000 0 | 1.49 0.39 148.46 0.25
3 1.78e+06 8186.29 | 8047.15 0.0 1000 0 | 1.49 0.40 151.46 0.25
3 1.80e+06 8186.29 | 7942.05 0.0 1000 0 | 1.53 0.39 154.80 0.25
3 1.81e+06 8186.29 | 7713.88 0.0 1000 0 | 1.53 0.39 157.22 0.25
3 1.83e+06 8269.92 |
3 1.83e+06 8269.92 | 8269.92 59.8 1000 0 | 1.48 0.38 154.06 0.25
3 1.85e+06 8269.92 | 7970.17 0.0 1000 0 | 1.49 0.38 154.84 0.26
3 1.86e+06 8269.92 | 8086.07 0.0 1000 0 | 1.57 0.39 155.70 0.26
3 1.88e+06 8269.92 | 7939.10 0.0 1000 0 | 1.49 0.39 157.72 0.26
3 1.89e+06 8269.92 | 8066.95 0.0 1000 0 | 1.55 0.39 157.19 0.26
3 1.91e+06 8269.92 | 7880.30 0.0 1000 0 | 1.54 0.38 153.95 0.26
3 1.93e+06 8269.92 | 8089.08 0.0 1000 0 | 1.52 0.38 156.71 0.26
3 1.94e+06 8269.92 | 8005.33 0.0 1000 0 | 1.43 0.40 157.78 0.26
3 1.96e+06 8269.92 | 7754.25 0.0 1000 0 | 1.47 0.39 159.52 0.26
3 1.97e+06 8269.92 | 7965.01 0.0 1000 0 | 1.54 0.37 159.52 0.26
3 1.99e+06 8269.92 | 8036.11 0.0 1000 0 | 1.52 0.38 158.75 0.26
| UsedTime: 18404 | SavedDir: ./HalfCheetah-v3_ReSACHtermK_3
| Learner: Save in ./HalfCheetah-v3_ReSACHtermK_3
| Arguments Remove cwd: ./HalfCheetah-v3_ReSACHtermK_3
################################################################################
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
3 4.00e+03 -1.59 |
3 4.00e+03 -1.59 | -1.59 0.8 1000 0 | -0.05 0.81 0.60 0.17
3 3.00e+05 -1.59 | -22.48 0.0 1000 0 | -0.04 0.04 24.31 0.08
3 4.44e+05 -1.59 | -53.33 0.0 1000 0 | -0.02 0.03 19.95 0.04
3 5.52e+05 -1.59 | -54.09 0.0 1000 0 | -0.02 0.03 11.66 0.02
3 6.44e+05 458.66 |
3 6.44e+05 458.66 | 458.66 454.0 1000 0 | 0.09 0.02 6.50 0.01
3 7.26e+05 2062.43 |
3 7.26e+05 2062.43 | 2062.43 55.8 1000 0 | 0.16 0.02 7.72 0.02
3 7.98e+05 2894.43 |
3 7.98e+05 2894.43 | 2894.43 14.3 1000 0 | 0.26 0.03 11.53 0.03
3 8.66e+05 3239.60 |
3 8.66e+05 3239.60 | 3239.60 30.8 1000 0 | 0.30 0.04 16.22 0.03
3 9.28e+05 3697.25 |
3 9.28e+05 3697.25 | 3697.25 18.6 1000 0 | 0.34 0.05 20.30 0.04
3 9.86e+05 3886.51 |
3 9.86e+05 3886.51 | 3886.51 36.6 1000 0 | 0.39 0.05 24.11 0.04
3 1.04e+06 3886.51 | 3705.75 0.0 1000 0 | 0.40 0.06 27.60 0.05
3 1.09e+06 4110.12 |
3 1.09e+06 4110.12 | 4110.12 43.2 1000 0 | 0.41 0.06 30.00 0.05
3 1.14e+06 4318.32 |
3 1.14e+06 4318.32 | 4318.32 88.1 1000 0 | 0.41 0.06 31.86 0.05
3 1.19e+06 4583.49 |
3 1.19e+06 4583.49 | 4583.49 84.5 1000 0 | 0.46 0.07 34.75 0.06
3 1.24e+06 4726.18 |
3 1.24e+06 4726.18 | 4726.18 76.1 1000 0 | 0.43 0.07 36.14 0.06
3 1.28e+06 4835.77 |
3 1.28e+06 4835.77 | 4835.77 33.8 1000 0 | 0.47 0.08 37.57 0.06
3 1.33e+06 4835.77 | 4825.60 0.0 1000 0 | 0.48 0.08 38.79 0.06
3 1.37e+06 4886.98 |
3 1.37e+06 4886.98 | 4886.98 43.7 1000 0 | 0.50 0.08 40.97 0.07
3 1.41e+06 4976.26 |
3 1.41e+06 4976.26 | 4976.26 50.9 1000 0 | 0.52 0.08 42.97 0.07
3 1.45e+06 5183.43 |
3 1.45e+06 5183.43 | 5183.43 78.2 1000 0 | 0.51 0.08 44.10 0.07
3 1.49e+06 5183.43 | 5126.47 0.0 1000 0 | 0.54 0.08 45.80 0.07
3 1.52e+06 5392.37 |
3 1.52e+06 5392.37 | 5392.37 31.7 1000 0 | 0.54 0.08 46.50 0.07
3 1.56e+06 5410.05 |
3 1.56e+06 5410.05 | 5410.05 74.0 1000 0 | 0.53 0.09 48.12 0.07
3 1.60e+06 5433.43 |
3 1.60e+06 5433.43 | 5433.43 70.3 1000 0 | 0.55 0.09 49.46 0.07
3 1.63e+06 5482.66 |
3 1.63e+06 5482.66 | 5482.66 37.9 1000 0 | 0.55 0.09 50.44 0.08
3 1.67e+06 5809.18 |
3 1.67e+06 5809.18 | 5809.18 88.6 1000 0 | 0.56 0.09 50.76 0.08
3 1.70e+06 5885.33 |
3 1.70e+06 5885.33 | 5885.33 83.3 1000 0 | 0.57 0.09 53.28 0.08
3 1.73e+06 6121.30 |
3 1.73e+06 6121.30 | 6121.30 92.0 1000 0 | 0.56 0.09 53.72 0.08
3 1.77e+06 6148.32 |
3 1.77e+06 6148.32 | 6148.32 79.8 1000 0 | 0.57 0.09 54.65 0.08
3 1.80e+06 6286.05 |
3 1.80e+06 6286.05 | 6286.05 43.6 1000 0 | 0.56 0.09 54.01 0.08
3 1.83e+06 6286.05 | 6168.53 0.0 1000 0 | 0.58 0.10 55.48 0.08
3 1.86e+06 6391.52 |
3 1.86e+06 6391.52 | 6391.52 143.5 1000 0 | 0.58 0.10 55.64 0.09
3 1.89e+06 6391.52 | 6011.79 0.0 1000 0 | 0.62 0.10 56.33 0.09
3 1.92e+06 6391.52 | 6380.08 0.0 1000 0 | 0.61 0.10 58.13 0.09
3 1.95e+06 6391.52 | 6293.05 0.0 1000 0 | 0.63 0.10 58.87 0.09
3 1.98e+06 6649.40 |
3 1.98e+06 6649.40 | 6649.40 51.1 1000 0 | 0.64 0.10 58.47 0.09
3 2.01e+06 6673.04 |
3 2.01e+06 6673.04 | 6673.04 162.5 1000 0 | 0.62 0.11 59.82 0.09
3 2.04e+06 6673.04 | 6567.13 130.6 1000 0 | 0.62 0.10 60.65 0.09
3 2.07e+06 6771.23 |
3 2.07e+06 6771.23 | 6771.23 57.5 1000 0 | 0.61 0.11 61.43 0.09
3 2.09e+06 6771.23 | 6630.75 0.0 1000 0 | 0.65 0.11 61.60 0.10
3 2.12e+06 7089.85 |
3 2.12e+06 7089.85 | 7089.85 153.4 1000 0 | 0.62 0.11 62.43 0.10
3 2.15e+06 7089.85 | 7023.48 0.0 1000 0 | 0.65 0.11 62.73 0.10
3 2.18e+06 7262.38 |
3 2.18e+06 7262.38 | 7262.38 50.8 1000 0 | 0.65 0.10 64.29 0.10
3 2.21e+06 7262.38 | 6621.28 0.0 1000 0 | 0.66 0.12 64.88 0.10
3 2.23e+06 7262.38 | 6963.32 0.0 1000 0 | 0.66 0.12 65.58 0.10
3 2.26e+06 7262.38 | 6949.54 0.0 1000 0 | 0.63 0.12 66.40 0.11
3 2.29e+06 7415.90 |
3 2.29e+06 7415.90 | 7415.90 105.5 1000 0 | 0.62 0.13 68.20 0.11
3 2.32e+06 7415.90 | 7153.06 0.0 1000 0 | 0.66 0.12 68.73 0.11
3 2.35e+06 7415.90 | 6740.54 0.0 1000 0 | 0.65 0.12 68.12 0.11
3 2.37e+06 7504.40 |
3 2.37e+06 7504.40 | 7504.40 93.0 1000 0 | 0.67 0.12 69.94 0.11
3 2.40e+06 7908.85 |
3 2.40e+06 7908.85 | 7908.85 50.4 1000 0 | 0.67 0.12 72.17 0.11
3 2.43e+06 7908.85 | 6768.78 0.0 1000 0 | 0.70 0.12 72.29 0.12
3 2.46e+06 7908.85 | 7135.70 0.0 1000 0 | 0.67 0.12 74.01 0.12
3 2.48e+06 7908.85 | 7432.72 0.0 1000 0 | 0.65 0.12 74.60 0.12
3 2.51e+06 7908.85 | 7701.17 0.0 1000 0 | 0.67 0.13 74.62 0.12
3 2.54e+06 7908.85 | 6711.08 0.0 1000 0 | 0.68 0.12 75.56 0.12
3 2.56e+06 7908.85 | 7167.67 0.0 1000 0 | 0.63 0.14 77.24 0.13
3 2.59e+06 7908.85 | 7480.21 0.0 1000 0 | 0.65 0.13 77.33 0.13
3 2.62e+06 7908.85 | 7905.37 0.0 1000 0 | 0.65 0.14 78.92 0.13
3 2.65e+06 7908.85 | 7560.49 0.0 1000 0 | 0.69 0.14 79.79 0.13
3 2.67e+06 7908.85 | 7702.42 0.0 1000 0 | 0.66 0.14 80.53 0.13
3 2.70e+06 7908.85 | 7087.36 0.0 1000 0 | 0.66 0.15 81.42 0.14
3 2.73e+06 7908.85 | 7073.33 0.0 1000 0 | 0.65 0.14 81.94 0.14
3 2.75e+06 7908.85 | 7699.47 0.0 1000 0 | 0.67 0.14 82.77 0.14
3 2.78e+06 7908.85 | 7136.34 0.0 1000 0 | 0.69 0.15 83.29 0.14
3 2.81e+06 7908.85 | 7903.92 0.0 1000 0 | 0.67 0.15 84.25 0.14
3 2.84e+06 7946.62 |
3 2.84e+06 7946.62 | 7946.62 40.0 1000 0 | 0.68 0.15 84.60 0.14
3 2.86e+06 7946.62 | 7626.92 0.0 1000 0 | 0.65 0.14 85.36 0.14
3 2.89e+06 7946.62 | 7656.19 0.0 1000 0 | 0.67 0.15 85.57 0.14
3 2.92e+06 7946.62 | 7612.22 0.0 1000 0 | 0.70 0.14 85.91 0.15
3 2.94e+06 7946.62 | 7401.85 0.0 1000 0 | 0.69 0.15 86.82 0.15
3 2.97e+06 7946.62 | 7897.47 46.2 1000 0 | 0.67 0.14 87.28 0.15
3 3.00e+06 7946.62 | 7569.65 0.0 1000 0 | 0.71 0.15 87.75 0.15
3 3.03e+06 7946.62 | 7644.16 0.0 1000 0 | 0.73 0.16 87.99 0.15
3 3.05e+06 7946.62 | 7899.59 0.0 1000 0 | 0.71 0.15 88.75 0.15
3 3.08e+06 7946.62 | 7681.38 0.0 1000 0 | 0.68 0.15 88.90 0.15
3 3.11e+06 8214.06 |
3 3.11e+06 8214.06 | 8214.06 44.2 1000 0 | 0.72 0.16 89.58 0.15
3 3.13e+06 8214.06 | 7998.91 0.0 1000 0 | 0.70 0.17 90.12 0.15
3 3.16e+06 8214.06 | 7925.53 0.0 1000 0 | 0.71 0.15 90.31 0.15
3 3.19e+06 8214.06 | 7330.83 0.0 1000 0 | 0.72 0.15 90.85 0.15
3 3.21e+06 8214.06 | 7831.95 0.0 1000 0 | 0.69 0.16 91.06 0.16
3 3.24e+06 8214.06 | 7984.59 0.0 1000 0 | 0.71 0.16 91.57 0.16
3 3.27e+06 8214.06 | 7877.17 0.0 1000 0 | 0.71 0.15 92.16 0.16
3 3.30e+06 8214.06 | 7979.83 0.0 1000 0 | 0.74 0.15 91.92 0.16
3 3.33e+06 8214.06 | 7833.25 0.0 1000 0 | 0.72 0.16 93.06 0.16
3 3.35e+06 8214.06 | 7989.30 0.0 1000 0 | 0.71 0.15 93.22 0.16
3 3.38e+06 8214.06 | 8147.75 0.0 1000 0 | 0.71 0.17 93.71 0.16
3 3.41e+06 8214.06 | 7597.72 0.0 1000 0 | 0.69 0.16 94.09 0.16
3 3.44e+06 8214.06 | 7799.73 0.0 1000 0 | 0.72 0.16 94.25 0.16
3 3.47e+06 8214.06 | 7686.12 0.0 1000 0 | 0.75 0.16 94.54 0.16
3 3.49e+06 8214.06 | 8207.71 0.0 1000 0 | 0.69 0.16 94.91 0.16
3 3.52e+06 8214.06 | 7572.98 0.0 1000 0 | 0.72 0.16 95.43 0.16
3 3.55e+06 8214.06 | 7490.13 0.0 1000 0 | 0.74 0.15 95.67 0.17
3 3.58e+06 8214.06 | 7857.88 0.0 1000 0 | 0.72 0.17 95.86 0.17
3 3.61e+06 8401.02 |
3 3.61e+06 8401.02 | 8401.02 59.7 1000 0 | 0.72 0.16 96.31 0.17
3 3.63e+06 8401.02 | 7848.02 0.0 1000 0 | 0.73 0.16 96.76 0.17
3 3.66e+06 8525.91 |
3 3.66e+06 8525.91 | 8525.91 52.7 1000 0 | 0.70 0.17 96.96 0.17
3 3.69e+06 8525.91 | 8151.91 0.0 1000 0 | 0.73 0.15 97.27 0.17
3 3.72e+06 8651.93 |
3 3.72e+06 8651.93 | 8651.93 36.3 1000 0 | 0.74 0.16 97.55 0.17
3 3.75e+06 8651.93 | 8316.41 0.0 1000 0 | 0.71 0.17 97.94 0.17
3 3.77e+06 8651.93 | 8189.64 0.0 1000 0 | 0.71 0.17 97.83 0.17
3 3.80e+06 8651.93 | 8245.38 0.0 1000 0 | 0.75 0.17 97.98 0.17
3 3.83e+06 8651.93 | 8312.11 0.0 1000 0 | 0.78 0.16 98.74 0.17
3 3.86e+06 8651.93 | 8534.29 0.0 1000 0 | 0.71 0.16 98.82 0.17
3 3.89e+06 8651.93 | 8051.65 0.0 1000 0 | 0.75 0.17 99.06 0.17
3 3.91e+06 8651.93 | 8338.40 0.0 1000 0 | 0.76 0.17 99.46 0.17
3 3.94e+06 8651.93 | 8099.43 0.0 1000 0 | 0.72 0.17 99.91 0.17
3 3.97e+06 8651.93 | 8496.03 0.0 1000 0 | 0.70 0.17 100.25 0.17
3 4.00e+06 8651.93 | 8291.02 0.0 1000 0 | 0.76 0.17 100.17 0.18
| UsedTime: 28659 | SavedDir: ./HalfCheetah-v3_ReSACHtermK_3
"""
elif env_name == 'Walker2d-v3':
env_func = gym.make
env_args = {
'env_num': 1,
'env_name': 'Walker2d-v3',
'if_discrete': False,
'max_step': 1000,
'state_dim': 17,
'action_dim': 6,
'target_return': 65536
}
args = Arguments(agent_class, env_func=env_func, env_args=env_args)
args.num_layer = 3
args.net_dim = 2 ** 7
args.batch_size = int(args.net_dim * 2)
args.worker_num = 2
args.target_step = args.max_step
args.repeat_times = 2 ** -1
args.reward_scale = 2 ** -4
args.learning_rate = 2 ** -15
args.clip_grad_norm = 1.0
args.gamma = 0.99
args.if_act_target = False
args.explore_noise_std = 0.1 # for DPG
args.h_term_sample_rate = 2 ** -2
args.h_term_drop_rate = 2 ** -3
args.h_term_lambda = 2 ** -6
args.h_term_k_step = 4
args.h_term_update_gap = 2
args.eval_times = 2 ** 1
args.eval_gap = 2 ** 8
args.if_allow_break = False
args.break_step = int(2e6)
"""
| Arguments Remove cwd: ./Walker2d-v3_ReSAC_2
################################################################################
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
2 4.02e+03 -18.04 |
2 4.02e+03 -18.04 | -18.04 0.1 86 0 | -0.01 0.79 0.82 0.17
2 2.41e+05 88.29 |
2 2.41e+05 88.29 | 88.29 12.8 164 22 | 0.08 0.71 22.65 0.08
2 3.54e+05 228.02 |
2 3.54e+05 228.02 | 228.02 112.3 340 126 | 0.07 0.59 21.77 0.06
2 4.43e+05 228.02 | 109.31 0.0 160 0 | 0.07 0.67 24.23 0.06
2 5.19e+05 228.02 | 178.04 0.0 104 0 | 0.08 1.18 43.40 0.11
2 5.87e+05 228.02 | 71.07 0.0 207 0 | 0.07 1.56 61.99 0.15
2 6.51e+05 321.31 |
2 6.51e+05 321.31 | 321.31 29.7 226 7 | 0.08 1.08 57.19 0.11
2 7.05e+05 388.19 |
2 7.05e+05 388.19 | 388.19 20.8 244 16 | 0.05 0.53 33.81 0.07
2 7.54e+05 512.89 |
2 7.54e+05 512.89 | 512.89 24.3 486 20 | 0.10 0.32 20.92 0.04
2 8.02e+05 512.89 | 469.10 0.0 373 0 | 0.08 0.20 16.18 0.03
2 8.46e+05 512.89 | 411.87 0.0 256 0 | 0.10 0.14 13.30 0.03
2 8.85e+05 512.89 | 452.51 0.0 188 0 | 0.11 0.10 11.45 0.02
2 9.21e+05 1381.34 |
2 9.21e+05 1381.34 | 1381.34 530.7 608 226 | 0.13 0.08 11.06 0.02
2 9.58e+05 1381.34 | 475.98 0.0 226 0 | 0.12 0.07 11.06 0.02
2 9.92e+05 1381.34 | 1270.17 680.6 570 330 | 0.13 0.07 11.37 0.02
2 1.03e+06 1908.40 |
2 1.03e+06 1908.40 | 1908.40 8.6 1000 0 | 0.13 0.07 11.50 0.02
2 1.06e+06 1908.40 | 1761.35 254.2 908 92 | 0.14 0.07 12.03 0.02
2 1.10e+06 1908.40 | 938.58 0.0 449 0 | 0.13 0.07 12.54 0.02
2 1.13e+06 1908.40 | 716.68 0.0 359 0 | 0.14 0.07 12.93 0.02
2 1.16e+06 1908.40 | 1674.89 0.0 584 0 | 0.14 0.08 13.18 0.02
2 1.19e+06 2332.65 |
2 1.19e+06 2332.65 | 2332.65 66.9 887 113 | 0.16 0.08 13.55 0.02
2 1.22e+06 2332.65 | 1775.35 0.0 644 0 | 0.15 0.08 13.35 0.02
2 1.25e+06 2534.59 |
2 1.25e+06 2534.59 | 2534.59 10.1 1000 0 | 0.19 0.08 13.48 0.02
2 1.28e+06 3074.55 |
2 1.28e+06 3074.55 | 3074.55 276.9 902 98 | 0.18 0.08 14.28 0.03
2 1.31e+06 3134.52 |
2 1.31e+06 3134.52 | 3134.52 110.4 1000 0 | 0.16 0.09 14.33 0.03
2 1.33e+06 3134.52 | 1103.63 0.0 422 0 | 0.18 0.09 15.92 0.03
2 1.36e+06 3134.52 | 3106.59 58.3 1000 0 | 0.17 0.10 17.18 0.03
2 1.39e+06 3218.23 |
2 1.39e+06 3218.23 | 3218.23 148.1 1000 0 | 0.19 0.10 17.36 0.03
2 1.42e+06 3218.23 | 1566.81 0.0 491 0 | 0.18 0.10 17.50 0.03
2 1.45e+06 3218.23 | 2916.22 552.7 884 116 | 0.17 0.10 18.53 0.03
2 1.47e+06 3218.23 | 1098.57 0.0 371 0 | 0.19 0.10 18.71 0.03
2 1.50e+06 3218.23 | 3145.03 144.2 1000 0 | 0.19 0.10 18.69 0.03
2 1.52e+06 3278.94 |
2 1.52e+06 3278.94 | 3278.94 39.9 1000 0 | 0.20 0.10 19.04 0.03
2 1.55e+06 3278.94 | 3230.16 0.0 1000 0 | 0.20 0.11 19.33 0.03
2 1.57e+06 3278.94 | 3173.60 0.0 1000 0 | 0.19 0.10 19.20 0.03
2 1.59e+06 3278.94 | 3014.22 0.0 1000 0 | 0.19 0.10 20.24 0.03
2 1.61e+06 3278.94 | 3029.58 0.0 1000 0 | 0.20 0.10 19.66 0.03
2 1.64e+06 3278.94 | 3097.23 0.0 1000 0 | 0.21 0.10 20.53 0.03
2 1.66e+06 3339.45 |
2 1.66e+06 3339.45 | 3339.45 150.7 1000 0 | 0.19 0.11 20.27 0.03
2 1.68e+06 3602.28 |
2 1.68e+06 3602.28 | 3602.28 74.2 1000 0 | 0.20 0.11 20.61 0.03
2 1.70e+06 3921.36 |
2 1.70e+06 3921.36 | 3921.36 14.4 1000 0 | 0.20 0.11 20.76 0.03
2 1.72e+06 3921.36 | 3685.55 0.0 1000 0 | 0.20 0.11 20.81 0.03
2 1.74e+06 3921.36 | 3656.15 0.0 1000 0 | 0.20 0.11 20.80 0.03
2 1.76e+06 3921.36 | 1968.12 0.0 558 0 | 0.20 0.11 22.02 0.03
2 1.78e+06 3921.36 | 3768.89 0.0 1000 0 | 0.22 0.11 21.58 0.03
2 1.80e+06 3921.36 | 3855.74 0.0 1000 0 | 0.20 0.11 21.79 0.03
2 1.82e+06 3921.36 | 3623.61 0.0 1000 0 | 0.20 0.11 22.17 0.03
2 1.83e+06 3921.36 | 3441.80 810.2 819 169 | 0.21 0.11 22.05 0.03
2 1.85e+06 3921.36 | 173.80 0.0 99 0 | 0.21 0.11 22.30 0.03
2 1.87e+06 3921.36 | 185.29 0.0 105 0 | 0.21 0.11 22.83 0.03
2 1.89e+06 3921.36 | 3368.81 0.0 866 0 | 0.21 0.11 21.37 0.03
2 1.91e+06 3921.36 | 3681.30 0.0 1000 0 | 0.21 0.11 22.37 0.03
2 1.93e+06 3921.36 | 1009.22 0.0 312 0 | 0.21 0.11 22.56 0.03
2 1.95e+06 3921.36 | 3765.83 0.0 1000 0 | 0.21 0.12 22.10 0.03
2 1.97e+06 3921.36 | 260.32 0.0 118 0 | 0.23 0.11 22.96 0.03
2 1.99e+06 4099.22 |
2 1.99e+06 4099.22 | 4099.22 93.3 1000 0 | 0.22 0.12 22.81 0.03
| UsedTime: 14981 | SavedDir: ./Walker2d-v3_ReSAC_2
| Learner: Save in ./Walker2d-v3_ReSAC_2
| Arguments Remove cwd: ./Walker2d-v3_ReSACHtermK_5
################################################################################
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
5 4.11e+03 322.61 |
5 4.11e+03 322.61 | 322.61 0.2 210 0 | 0.01 0.78 0.68 0.17
5 2.38e+05 322.61 | 160.26 0.0 274 0 | 0.10 0.72 24.15 0.08
5 3.54e+05 322.61 | 236.19 149.1 218 40 | 0.09 0.77 25.16 0.06
5 4.43e+05 322.61 | 246.58 0.0 136 0 | 0.10 0.85 27.90 0.06
5 5.18e+05 322.61 | 277.61 0.0 152 0 | 0.08 0.69 29.26 0.06
5 5.81e+05 322.61 | 11.49 0.0 30 0 | 0.07 0.61 30.52 0.06
5 6.36e+05 322.61 | 166.38 0.0 88 0 | 0.09 0.66 36.18 0.06
5 6.88e+05 322.61 | 218.94 0.0 111 0 | 0.11 0.59 36.22 0.06
5 7.36e+05 322.61 | 9.33 0.0 26 0 | 0.09 0.38 31.12 0.05
5 7.81e+05 401.07 |
5 7.81e+05 401.07 | 401.07 54.4 177 15 | 0.10 0.25 22.31 0.04
5 8.24e+05 1200.05 |
5 8.24e+05 1200.05 | 1200.05 126.0 496 84 | 0.10 0.18 16.64 0.04
5 8.64e+05 1200.05 | 798.68 479.4 444 276 | 0.11 0.15 15.25 0.03
5 9.01e+05 1200.05 | 211.15 0.0 143 0 | 0.13 0.11 14.54 0.03
5 9.38e+05 1200.05 | 1178.97 629.1 533 241 | 0.13 0.08 12.28 0.02
5 9.75e+05 1200.05 | 518.32 0.0 209 0 | 0.15 0.07 12.11 0.02
5 1.01e+06 1973.11 |
5 1.01e+06 1973.11 | 1973.11 50.9 910 90 | 0.14 0.07 11.95 0.02
5 1.05e+06 1973.11 | 966.91 0.0 400 0 | 0.15 0.07 12.90 0.02
5 1.08e+06 1973.11 | 496.69 0.0 219 0 | 0.12 0.08 13.90 0.02
5 1.11e+06 2382.95 |
5 1.11e+06 2382.95 | 2382.95 21.7 1000 0 | 0.14 0.08 14.13 0.02
5 1.15e+06 2694.36 |
5 1.15e+06 2694.36 | 2694.36 31.9 1000 0 | 0.16 0.08 14.56 0.02
5 1.17e+06 2694.36 | 2109.05 774.1 736 264 | 0.17 0.09 15.10 0.03
5 1.20e+06 2694.36 | 2630.14 0.0 1000 0 | 0.16 0.09 16.15 0.03
5 1.22e+06 2823.11 |
5 1.22e+06 2823.11 | 2823.11 59.1 1000 0 | 0.17 0.09 16.54 0.03
5 1.24e+06 2823.11 | 2646.45 0.0 1000 0 | 0.16 0.09 17.18 0.03
5 1.26e+06 2823.11 | 2574.78 0.0 1000 0 | 0.16 0.09 17.60 0.03
5 1.29e+06 2880.16 |
5 1.29e+06 2880.16 | 2880.16 29.0 1000 0 | 0.16 0.09 17.81 0.03
5 1.31e+06 2880.16 | 2799.66 0.0 1000 0 | 0.16 0.09 17.94 0.03
5 1.34e+06 2880.16 | 2812.48 96.3 1000 0 | 0.17 0.09 18.53 0.03
5 1.37e+06 2923.55 |
5 1.37e+06 2923.55 | 2923.55 143.8 1000 0 | 0.18 0.09 18.45 0.03
5 1.39e+06 3720.88 |
5 1.39e+06 3720.88 | 3720.88 107.5 1000 0 | 0.19 0.09 18.90 0.03
5 1.42e+06 3720.88 | 3571.06 0.0 1000 0 | 0.21 0.09 19.19 0.03
5 1.44e+06 3720.88 | 3650.66 0.0 1000 0 | 0.20 0.09 19.57 0.03
5 1.47e+06 3720.88 | 3354.98 0.0 1000 0 | 0.19 0.09 20.57 0.03
5 1.49e+06 3720.88 | 3122.89 0.0 1000 0 | 0.18 0.10 20.51 0.03
5 1.52e+06 3720.88 | 2972.32 0.0 1000 0 | 0.19 0.10 21.11 0.03
5 1.55e+06 3720.88 | 3216.23 0.0 1000 0 | 0.20 0.10 20.71 0.03
5 1.57e+06 3720.88 | 3007.49 0.0 1000 0 | 0.18 0.10 20.97 0.03
5 1.59e+06 3720.88 | 3021.76 0.0 1000 0 | 0.19 0.09 21.37 0.03
5 1.61e+06 3720.88 | 3088.03 0.0 1000 0 | 0.19 0.10 20.91 0.03
5 1.63e+06 3720.88 | 3284.19 0.0 1000 0 | 0.19 0.10 21.03 0.03
5 1.65e+06 3720.88 | 2888.49 0.0 1000 0 | 0.19 0.10 21.61 0.03
5 1.67e+06 3720.88 | 3465.00 0.0 1000 0 | 0.19 0.10 21.17 0.03
5 1.69e+06 3720.88 | 3375.66 0.0 1000 0 | 0.20 0.10 21.43 0.03
5 1.71e+06 3720.88 | 3549.70 0.0 1000 0 | 0.21 0.10 21.91 0.03
5 1.73e+06 3720.88 | 3500.22 0.0 1000 0 | 0.22 0.09 21.50 0.03
5 1.75e+06 3720.88 | 3378.39 0.0 1000 0 | 0.21 0.09 21.49 0.03
5 1.77e+06 3720.88 | 3428.88 0.0 1000 0 | 0.20 0.09 22.21 0.03
5 1.79e+06 3720.88 | 1256.50 0.0 402 0 | 0.23 0.09 21.81 0.03
5 1.82e+06 3773.58 |
5 1.82e+06 3773.58 | 3773.58 17.7 1000 0 | 0.21 0.09 22.29 0.03
5 1.84e+06 3773.58 | 3366.69 0.0 1000 0 | 0.22 0.09 22.02 0.03
5 1.86e+06 3773.58 | 3703.04 0.0 1000 0 | 0.20 0.09 22.12 0.03
5 1.88e+06 3840.59 |
5 1.88e+06 3840.59 | 3840.59 64.2 1000 0 | 0.22 0.09 22.86 0.03
5 1.90e+06 3840.59 | 490.55 0.0 211 0 | 0.21 0.09 22.91 0.03
5 1.92e+06 3840.59 | 3621.07 0.0 1000 0 | 0.22 0.09 22.91 0.03
5 1.94e+06 3911.90 |
5 1.94e+06 3911.90 | 3911.90 5.3 1000 0 | 0.23 0.10 23.03 0.03
5 1.95e+06 3911.90 | 3776.58 0.0 1000 0 | 0.22 0.09 23.12 0.03
5 1.97e+06 3911.90 | 3771.44 0.0 1000 0 | 0.21 0.09 23.78 0.03
5 1.99e+06 3911.90 | 303.73 0.0 131 0 | 0.21 0.09 23.11 0.03
| UsedTime: 15361 | SavedDir: ./Walker2d-v3_ReSACHtermK_5
| Learner: Save in ./Walker2d-v3_ReSACHtermK_5
"""
elif env_name == 'Humanoid-v3':
from elegantrl.envs.CustomGymEnv import HumanoidEnv
env_func = HumanoidEnv
env_args = {
'env_num': 1,
'env_name': 'Humanoid-v3',
'max_step': 1000,
'state_dim': 376,
'action_dim': 17,
'if_discrete': False,
'target_return': 3000.,
}
args = Arguments(agent_class, env_func=env_func, env_args=env_args)
args.eval_times = 2 ** 2
args.reward_scale = 2 ** -2
args.max_memo = 2 ** 21
args.learning_rate = 2 ** -14
args.lambda_a_log_std = 2 ** -6
args.target_step = args.max_step
args.worker_num = 4
args.net_dim = 2 ** 9
args.batch_size = args.net_dim // 2
args.num_layer = 3
args.repeat_times = 2 ** 0
args.gamma = 0.96
args.if_act_target = False
import numpy as np
args.target_entropy = np.log(env_args['action_dim'])
args.if_allow_break = False
args.break_step = int(4e6)
"""
| Arguments Remove cwd: ./Humanoid-v3_ReliableSAC_3
################################################################################
ID Step maxR | avgR stdR avgS stdS | expR objC etc.
3 8.09e+03 176.45 |
3 8.09e+03 176.45 | 176.45 29.6 34 6 | 1.19 0.69 2.81 0.06
3 1.47e+05 216.06 |
3 1.47e+05 216.06 | 216.06 12.1 41 2 | 1.27 0.79 32.29 0.03
3 2.25e+05 289.98 |
3 2.25e+05 289.98 | 289.98 13.7 56 2 | 1.34 0.68 31.95 0.01
3 2.83e+05 316.69 |
3 2.83e+05 316.69 | 316.69 17.4 58 3 | 1.34 0.45 27.33 0.01
3 3.28e+05 316.69 | 287.80 0.0 57 0 | 1.28 0.33 24.88 0.01
3 3.70e+05 379.81 |
3 3.70e+05 379.81 | 379.81 36.3 71 7 | 1.31 0.29 24.75 0.01
3 4.07e+05 379.81 | 209.17 0.0 41 0 | 1.35 0.26 25.31 0.01
3 4.40e+05 379.81 | 356.76 0.0 67 0 | 1.36 0.24 25.37 0.01
3 4.74e+05 379.81 | 374.84 36.5 67 6 | 1.34 0.22 25.21 0.01
3 5.03e+05 525.94 |
3 5.03e+05 525.94 | 525.94 41.6 100 11 | 1.36 0.21 25.63 0.01
3 5.32e+05 525.94 | 497.22 0.0 89 0 | 1.36 0.20 25.51 0.01
3 5.62e+05 525.94 | 334.79 0.0 59 0 | 1.37 0.20 26.24 0.01
3 5.87e+05 525.94 | 428.25 0.0 76 0 | 1.39 0.19 25.51 0.01
3 6.12e+05 525.94 | 423.34 0.0 74 0 | 1.37 0.18 26.50 0.01
3 6.37e+05 525.94 | 479.20 0.0 84 0 | 1.40 0.18 26.26 0.01
3 6.62e+05 551.04 |
3 6.62e+05 551.04 | 551.04 83.8 98 16 | 1.39 0.18 26.49 0.01
3 6.83e+05 551.04 | 397.43 0.0 70 0 | 1.36 0.18 27.22 0.01
3 7.04e+05 745.68 |
3 7.04e+05 745.68 | 745.68 106.0 134 15 | 1.35 0.17 26.33 0.01
3 7.25e+05 745.68 | 509.76 0.0 89 0 | 1.42 0.17 26.93 0.01
3 7.47e+05 745.68 | 376.85 0.0 70 0 | 1.41 0.18 28.16 0.01
3 7.69e+05 745.68 | 580.24 127.2 104 23 | 1.38 0.18 27.97 0.01
3 7.91e+05 745.68 | 491.18 0.0 85 0 | 1.40 0.18 27.98 0.01
3 8.12e+05 745.68 | 492.97 0.0 87 0 | 1.41 0.18 29.00 0.01
3 8.34e+05 801.10 |
3 8.34e+05 801.10 | 801.10 244.9 146 39 | 1.43 0.18 28.95 0.01
3 8.51e+05 801.10 | 522.10 0.0 93 0 | 1.42 0.18 28.90 0.01
3 8.69e+05 801.10 | 620.43 0.0 105 0 | 1.44 0.18 29.90 0.01
3 8.85e+05 829.16 |
3 8.85e+05 829.16 | 829.16 109.8 152 30 | 1.42 0.17 29.57 0.01
3 9.03e+05 829.16 | 733.06 127.1 135 32 | 1.47 0.17 30.11 0.01
3 9.20e+05 1018.17 |
3 9.20e+05 1018.17 | 1018.17 329.5 174 53 | 1.43 0.17 30.46 0.01
3 9.37e+05 1018.17 | 739.87 0.0 135 0 | 1.45 0.18 28.93 0.01
3 9.55e+05 1018.17 | 744.00 0.0 129 0 | 1.46 0.18 31.50 0.01
3 9.73e+05 1208.41 |
3 9.73e+05 1208.41 | 1208.41 378.3 204 57 | 1.48 0.17 29.71 0.01
3 9.90e+05 1208.41 | 647.54 0.0 117 0 | 1.45 0.18 30.89 0.01
3 1.01e+06 1208.41 | 929.52 0.0 163 0 | 1.47 0.18 30.55 0.01
3 1.02e+06 2111.40 |
3 1.02e+06 2111.40 | 2111.40 513.4 344 77 | 1.50 0.18 30.26 0.01
3 1.04e+06 2961.21 |
3 1.04e+06 2961.21 | 2961.21 1907.8 467 300 | 1.49 0.17 31.73 0.01
3 1.06e+06 2961.21 | 1923.17 0.0 307 0 | 1.51 0.18 31.26 0.01
3 1.08e+06 2961.21 | 665.96 0.0 115 0 | 1.51 0.17 32.32 0.01
3 1.10e+06 2961.21 | 2009.69 0.0 308 0 | 1.56 0.17 32.11 0.01
3 1.11e+06 2961.21 | 1253.18 0.0 193 0 | 1.54 0.17 31.96 0.02
3 1.13e+06 2961.21 | 822.65 0.0 125 0 | 1.56 0.17 32.47 0.02
3 1.15e+06 2961.21 | 808.09 0.0 126 0 | 1.58 0.18 32.09 0.02
3 1.16e+06 2961.21 | 1995.99 0.0 317 0 | 1.58 0.17 32.54 0.02
3 1.17e+06 2961.21 | 804.38 0.0 128 0 | 1.59 0.18 33.59 0.02
3 1.19e+06 2961.21 | 1058.70 0.0 169 0 | 1.58 0.18 32.22 0.02
3 1.20e+06 2961.21 | 954.06 0.0 155 0 | 1.61 0.18 33.44 0.02
3 1.21e+06 2961.21 | 1245.58 0.0 195 0 | 1.62 0.18 32.46 0.02
3 1.23e+06 2961.21 | 2780.23 0.0 415 0 | 1.62 0.18 33.10 0.02
3 1.24e+06 4273.43 |
3 1.24e+06 4273.43 | 4273.43 1977.1 643 289 | 1.63 0.17 33.10 0.02
3 1.26e+06 4273.43 | 304.42 0.0 53 0 | 1.63 0.18 33.53 0.02
3 1.27e+06 4273.43 | 4017.09 2192.0 596 319 | 1.65 0.18 33.96 0.02
3 1.29e+06 4273.43 | 4190.22 2639.0 604 374 | 1.65 0.18 34.71 0.02
3 1.30e+06 4273.43 | 1137.88 0.0 185 0 | 1.68 0.18 33.78 0.02
3 1.31e+06 4273.43 | 977.47 0.0 143 0 | 1.65 0.18 34.35 0.02
3 1.33e+06 4969.29 |
3 1.33e+06 4969.29 | 4969.29 2784.2 712 393 | 1.72 0.18 34.51 0.02
3 1.34e+06 4969.29 | 4573.45 0.0 634 0 | 1.71 0.18 35.18 0.02
3 1.36e+06 4969.29 | 4896.34 0.0 663 0 | 1.76 0.18 35.41 0.02
3 1.37e+06 4969.29 | 1326.51 0.0 194 0 | 1.67 0.18 34.70 0.02
3 1.39e+06 4969.29 | 1680.32 0.0 238 0 | 1.80 0.18 35.17 0.02
3 1.40e+06 4969.29 | 3260.77 0.0 451 0 | 1.74 0.18 34.56 0.02
3 1.42e+06 4969.29 | 1140.55 0.0 162 0 | 1.80 0.18 34.71 0.02
3 1.43e+06 4969.29 | 2484.06 2403.7 340 320 | 1.79 0.18 35.37 0.02
3 1.45e+06 4969.29 | 2997.63 0.0 422 0 | 1.81 0.19 35.35 0.02
3 1.46e+06 4969.29 | 4737.24 1827.3 641 242 | 1.85 0.18 35.85 0.02
3 1.48e+06 4969.29 | 1047.71 0.0 148 0 | 1.83 0.19 35.50 0.02
3 1.49e+06 4969.29 | 173.17 0.0 33 0 | 1.84 0.19 36.82 0.02
3 1.51e+06 4969.29 | 3679.41 0.0 497 0 | 1.86 0.19 36.89 0.02
3 1.52e+06 4969.29 | 4962.11 2734.9 652 348 | 1.88 0.19 37.78 0.02
3 1.53e+06 4969.29 | 2338.43 0.0 305 0 | 1.86 0.19 36.17 0.02
3 1.55e+06 4969.29 | 2442.01 0.0 309 0 | 1.81 0.19 36.69 0.02
3 1.56e+06 4969.29 | 4154.86 2039.7 522 250 | 1.85 0.19 37.91 0.02
3 1.58e+06 4969.29 | 4003.55 0.0 502 0 | 1.84 0.18 37.31 0.02
3 1.59e+06 4969.29 | 3509.02 0.0 445 0 | 1.88 0.19 37.35 0.02
3 1.61e+06 4969.29 | 3969.27 2935.2 520 379 | 1.86 0.19 36.67 0.02
3 1.62e+06 4969.29 | 2483.33 0.0 323 0 | 1.86 0.19 37.52 0.02
3 1.64e+06 4969.29 | 2687.55 0.0 354 0 | 1.93 0.19 38.44 0.02
3 1.65e+06 4969.29 | 4662.24 0.0 574 0 | 1.90 0.18 38.91 0.02
3 1.66e+06 4969.29 | 2818.31 0.0 363 0 | 1.98 0.19 38.51 0.02
3 1.68e+06 4969.29 | 1649.55 0.0 219 0 | 1.84 0.20 37.76 0.02
3 1.69e+06 4969.29 | 4783.08 0.0 580 0 | 1.92 0.19 39.04 0.02
3 1.70e+06 4969.29 | 406.79 0.0 65 0 | 1.89 0.19 37.27 0.02
3 1.71e+06 4969.29 | 2765.69 0.0 338 0 | 1.92 0.20 38.05 0.02
3 1.72e+06 4969.29 | 1396.78 0.0 179 0 | 1.92 0.19 37.59 0.02
3 1.73e+06 4969.29 | 1609.04 0.0 209 0 | 1.92 0.20 37.77 0.02
3 1.74e+06 4969.29 | 4467.71 0.0 560 0 | 1.96 0.19 38.12 0.02
3 1.75e+06 5073.69 |
3 1.75e+06 5073.69 | 5073.69 3289.1 624 396 | 1.97 0.19 38.57 0.02
3 1.76e+06 5073.69 | 2309.20 0.0 281 0 | 1.96 0.19 39.72 0.02
3 1.77e+06 7728.06 |
3 1.77e+06 7728.06 | 7728.06 851.9 914 95 | 1.93 0.19 38.74 0.02
3 1.78e+06 7728.06 | 1083.30 0.0 144 0 | 2.01 0.19 39.00 0.02
3 1.79e+06 7728.06 | 4592.06 0.0 551 0 | 1.94 0.19 39.21 0.02
3 1.80e+06 7728.06 | 1914.95 0.0 254 0 | 2.03 0.19 39.01 0.02
3 1.81e+06 7728.06 | 708.27 0.0 99 0 | 1.99 0.19 38.98 0.02
3 1.82e+06 7728.06 | 7678.90 1510.8 896 179 | 2.00 0.19 38.46 0.02
3 1.83e+06 7728.06 | 4612.89 0.0 554 0 | 2.05 0.20 40.58 0.02
3 1.84e+06 7728.06 | 5765.75 3283.5 670 370 | 2.01 0.19 39.72 0.02
3 1.85e+06 7728.06 | 5138.14 0.0 609 0 | 2.03 0.20 41.17 0.02
3 1.86e+06 7728.06 | 2317.73 0.0 282 0 | 2.04 0.19 39.38 0.02
3 1.87e+06 7728.06 | 4502.98 0.0 518 0 | 1.92 0.20 39.25 0.02
3 1.88e+06 7728.06 | 434.40 0.0 66 0 | 2.05 0.19 39.97 0.02
3 1.89e+06 7728.06 | 2278.33 0.0 304 0 | 1.99 0.19 40.53 0.02
3 1.90e+06 7728.06 | 1075.64 0.0 139 0 | 1.99 0.21 40.48 0.02
3 1.91e+06 7728.06 | 5303.26 1961.5 643 238 | 2.03 0.19 40.77 0.02
3 1.92e+06 7728.06 | 7610.01 1916.9 876 215 | 1.96 0.19 39.49 0.02
3 1.93e+06 7728.06 | 7504.85 1400.1 897 159 | 1.94 0.19 41.41 0.02
3 1.94e+06 7728.06 | 7434.55 1282.9 860 141 | 2.00 0.19 40.33 0.02
3 1.95e+06 7728.06 | 1779.93 0.0 215 0 | 2.07 0.19 40.77 0.02
3 1.96e+06 7728.06 | 525.02 0.0 76 0 | 2.04 0.20 41.53 0.02
3 1.97e+06 7728.06 | 459.73 0.0 71 0 | 2.06 0.19 39.72 0.02
3 1.98e+06 7728.06 | 4457.85 4074.2 524 466 | 2.05 0.19 42.10 0.02
3 1.99e+06 7728.06 | 6060.01 2013.8 717 224 | 2.02 0.19 41.74 0.02
3 2.00e+06 7728.06 | 3763.48 0.0 434 0 | 1.99 0.19 42.00 0.02
3 2.01e+06 7728.06 | 2920.24 3370.0 346 379 | 2.00 0.20 40.89 0.02
3 2.03e+06 7728.06 | 5806.59 0.0 662 0 | 2.05 0.19 42.19 0.02
3 2.03e+06 7728.06 | 6983.07 3317.2 789 365 | 2.07 0.20 41.56 0.02
3 2.05e+06 7728.06 | 2810.41 0.0 331 0 | 2.06 0.20 41.36 0.02
3 2.06e+06 7728.06 | 7325.62 1785.0 814 193 | 2.04 0.19 42.16 0.02
3 2.07e+06 7728.06 | 5472.22 0.0 624 0 | 2.08 0.19 41.91 0.02
3 2.08e+06 7728.06 | 5224.22 2573.9 596 285 | 2.06 0.20 42.81 0.02
3 2.08e+06 7728.06 | 3663.78 0.0 424 0 | 2.04 0.20 41.13 0.02
3 2.09e+06 7788.26 |
3 2.09e+06 7788.26 | 7788.26 1759.1 876 189 | 2.00 0.19 41.34 0.02
3 2.10e+06 7830.41 |
3 2.10e+06 7830.41 | 7830.41 1640.3 890 190 | 2.11 0.19 43.17 0.02
3 2.11e+06 7830.41 | 2744.79 0.0 334 0 | 2.07 0.20 41.95 0.02
3 2.12e+06 7830.41 | 338.01 0.0 52 0 | 2.08 0.19 43.14 0.02
3 2.13e+06 7830.41 | 378.62 0.0 57 0 | 1.95 0.19 41.59 0.02
3 2.14e+06 7830.41 | 193.63 0.0 34 0 | 1.88 0.19 42.16 0.02
3 2.15e+06 8726.12 |
3 2.15e+06 8726.12 | 8726.12 592.7 966 58 | 2.12 0.19 43.00 0.02
3 2.16e+06 8726.12 | 180.76 0.0 31 0 | 2.09 0.18 41.18 0.02
3 2.17e+06 8726.12 | 5604.62 3839.7 616 407 | 2.10 0.19 43.04 0.02
3 2.18e+06 8726.12 | 8339.71 0.0 932 0 | 2.09 0.19 42.43 0.02
3 2.20e+06 8726.12 | 2646.60 0.0 300 0 | 2.11 0.18 44.49 0.02
3 2.20e+06 8726.12 | 5454.00 2853.0 618 313 | 1.92 0.19 43.55 0.02
3 2.21e+06 8726.12 | 4760.50 0.0 523 0 | 1.93 0.19 42.93 0.02
3 2.22e+06 9094.07 |
3 2.22e+06 9094.07 | 9094.07 80.9 1000 0 | 2.10 0.18 43.27 0.02
3 2.23e+06 9094.07 | 6217.18 0.0 674 0 | 2.03 0.19 44.04 0.02
3 2.24e+06 9094.07 | 8890.46 0.0 1000 0 | 2.19 0.18 44.23 0.02
3 2.25e+06 9400.97 |
3 2.25e+06 9400.97 | 9400.97 79.1 1000 0 | 2.12 0.18 44.17 0.02
3 2.26e+06 9400.97 | 9185.07 0.0 1000 0 | 2.20 0.18 43.76 0.02
3 2.27e+06 9400.97 | 9208.88 0.0 1000 0 | 2.01 0.18 44.20 0.02
3 2.28e+06 9400.97 | 8215.99 1686.5 900 173 | 2.21 0.18 43.55 0.02
3 2.29e+06 9400.97 | 7827.44 0.0 840 0 | 2.21 0.19 43.74 0.02
3 2.30e+06 9400.97 | 567.31 0.0 78 0 | 2.18 0.18 44.26 0.02
3 2.31e+06 9400.97 | 4230.70 0.0 468 0 | 2.07 0.18 44.48 0.02
3 2.32e+06 9400.97 | 336.20 0.0 52 0 | 2.03 0.19 44.77 0.02
3 2.33e+06 9400.97 | 9327.56 0.0 1000 0 | 1.94 0.19 44.30 0.02
3 2.34e+06 9400.97 | 2688.67 3918.1 296 409 | 2.09 0.18 45.14 0.02
3 2.35e+06 9400.97 | 270.88 0.0 43 0 | 2.09 0.18 44.38 0.02
3 2.36e+06 9400.97 | 4219.46 0.0 457 0 | 2.10 0.18 46.13 0.02
3 2.37e+06 9400.97 | 934.99 0.0 118 0 | 2.09 0.19 45.69 0.02
3 2.38e+06 9400.97 | 9338.99 0.0 1000 0 | 2.06 0.18 45.48 0.02
3 2.39e+06 9400.97 | 5507.83 0.0 584 0 | 1.92 0.18 46.07 0.02
3 2.40e+06 9400.97 | 3810.83 0.0 412 0 | 1.90 0.19 44.47 0.02
3 2.41e+06 9400.97 | 4665.77 0.0 506 0 | 1.99 0.18 45.91 0.02
3 2.42e+06 9400.97 | 1511.40 0.0 174 0 | 1.95 0.18 46.20 0.02
3 2.42e+06 9400.97 | 2301.35 0.0 255 0 | 1.97 0.18 46.06 0.02
3 2.43e+06 9400.97 | 1289.04 0.0 157 0 | 2.14 0.18 46.75 0.02
3 2.44e+06 9400.97 | 3766.25 0.0 425 0 | 2.09 0.18 46.02 0.02
3 2.45e+06 9400.97 | 1576.04 0.0 188 0 | 2.18 0.18 46.27 0.02
3 2.46e+06 9400.97 | 338.50 0.0 51 0 | 2.21 0.19 46.15 0.02
3 2.47e+06 9400.97 | 1363.64 0.0 162 0 | 2.02 0.19 46.61 0.02
3 2.48e+06 9400.97 | 2311.31 0.0 260 0 | 2.12 0.20 47.16 0.02
3 2.49e+06 9400.97 | 1103.78 0.0 138 0 | 2.30 0.19 46.52 0.02
3 2.50e+06 9400.97 | 1327.52 0.0 156 0 | 2.16 0.19 45.45 0.02
3 2.51e+06 9400.97 | 6124.39 2098.5 640 210 | 2.23 0.19 47.28 0.02
3 2.52e+06 9400.97 | 3947.05 0.0 427 0 | 2.23 0.20 47.51 0.02
3 2.53e+06 9400.97 | 365.90 0.0 55 0 | 2.26 0.18 47.74 0.02
3 2.54e+06 9400.97 | 3208.60 0.0 341 0 | 1.93 0.19 48.40 0.02
3 2.55e+06 9400.97 | 7360.38 2959.7 748 289 | 2.12 0.18 47.52 0.02
3 2.56e+06 9400.97 | 6598.35 2526.5 693 255 | 2.25 0.20 47.14 0.02
3 2.57e+06 9400.97 | 4869.49 4685.1 516 484 | 2.32 0.20 47.71 0.02
3 2.58e+06 9400.97 | 8345.87 2688.1 847 265 | 2.25 0.20 48.28 0.02
3 2.59e+06 9400.97 | 2920.38 0.0 314 0 | 2.28 0.19 47.91 0.02
3 2.60e+06 9400.97 | 5261.52 0.0 550 0 | 2.27 0.19 48.32 0.02
3 2.60e+06 9400.97 | 2043.06 0.0 223 0 | 2.21 0.20 48.21 0.02
3 2.61e+06 9400.97 | 4010.91 0.0 433 0 | 2.10 0.20 48.61 0.02
3 2.62e+06 9400.97 | 3848.38 0.0 408 0 | 2.30 0.20 48.81 0.02
3 2.63e+06 9400.97 | 389.13 0.0 58 0 | 2.29 0.19 47.63 0.02
3 2.64e+06 9400.97 | 365.81 0.0 54 0 | 2.16 0.20 48.71 0.02
3 2.65e+06 9400.97 | 3056.22 0.0 328 0 | 2.31 0.20 48.48 0.02
3 2.66e+06 9400.97 | 889.49 0.0 111 0 | 2.08 0.19 48.70 0.02
3 2.67e+06 9400.97 | 165.39 0.0 29 0 | 2.20 0.19 48.89 0.02
3 2.68e+06 9400.97 | 3100.69 0.0 360 0 | 2.08 0.21 49.12 0.02
3 2.68e+06 9400.97 | 498.45 0.0 69 0 | 2.28 0.20 49.01 0.02
3 2.69e+06 9400.97 | 1110.05 0.0 131 0 | 1.95 0.20 48.85 0.02
3 2.70e+06 9400.97 | 3564.61 0.0 367 0 | 2.09 0.20 49.62 0.02
3 2.71e+06 9400.97 | 3891.63 0.0 418 0 | 2.23 0.20 49.66 0.02
3 2.72e+06 9400.97 | 3446.70 0.0 368 0 | 2.19 0.20 50.11 0.02
3 2.73e+06 9400.97 | 2262.99 0.0 240 0 | 2.12 0.21 50.37 0.02
3 2.74e+06 9400.97 | 316.87 0.0 48 0 | 2.09 0.21 49.94 0.02
3 2.75e+06 9400.97 | 8746.19 0.0 877 0 | 2.02 0.21 49.60 0.02
3 2.76e+06 9400.97 | 2905.47 0.0 312 0 | 2.29 0.22 49.86 0.02
3 2.76e+06 9400.97 | 3270.80 0.0 336 0 | 2.07 0.20 50.74 0.02
3 2.77e+06 9400.97 | 2539.63 0.0 265 0 | 2.19 0.22 48.64 0.02
3 2.78e+06 9400.97 | 5086.21 0.0 524 0 | 2.23 0.21 50.41 0.02
3 2.79e+06 9400.97 | 6139.51 0.0 612 0 | 2.38 0.22 51.37 0.02
3 2.80e+06 9400.97 | 1076.67 0.0 128 0 | 2.20 0.22 49.96 0.02
3 2.81e+06 9400.97 | 7106.03 0.0 682 0 | 2.12 0.20 50.93 0.02
3 2.82e+06 9400.97 | 828.86 0.0 103 0 | 2.27 0.21 50.35 0.02
3 2.83e+06 9400.97 | 2867.47 0.0 300 0 | 2.06 0.21 50.02 0.02
3 2.84e+06 9400.97 | 439.11 0.0 62 0 | 2.29 0.21 51.19 0.02
3 2.85e+06 9400.97 | 4167.51 0.0 421 0 | 2.19 0.20 50.30 0.02
3 2.85e+06 9400.97 | 2720.88 0.0 279 0 | 2.19 0.21 51.17 0.02
3 2.86e+06 9400.97 | 3175.01 0.0 323 0 | 2.24 0.22 50.80 0.02
3 2.87e+06 9400.97 | 1955.77 0.0 211 0 | 2.06 0.22 50.54 0.02
3 2.88e+06 9400.97 | 3316.37 0.0 341 0 | 2.13 0.21 50.84 0.02
3 2.89e+06 9400.97 | 722.73 0.0 108 0 | 2.22 0.26 52.52 0.02
3 2.90e+06 9400.97 | 189.10 0.0 37 0 | 1.33 0.23 51.74 0.02
3 2.91e+06 9400.97 | 2395.07 0.0 252 0 | 1.88 0.22 51.33 0.02
3 2.92e+06 9400.97 | 2206.58 0.0 238 0 | 2.04 0.21 52.45 0.02
3 2.93e+06 9400.97 | 260.01 0.0 42 0 | 2.14 0.21 50.83 0.02
3 2.93e+06 9400.97 | 9167.51 0.0 892 0 | 2.11 0.22 52.46 0.02
3 2.94e+06 9400.97 | 2142.60 0.0 235 0 | 2.14 0.21 51.50 0.02
3 2.95e+06 9400.97 | 663.20 0.0 85 0 | 2.32 0.22 51.99 0.02
3 2.96e+06 9400.97 | 6153.73 0.0 614 0 | 2.20 0.21 52.28 0.02
3 2.97e+06 9400.97 | 1746.93 0.0 184 0 | 2.33 0.22 52.50 0.02
3 2.98e+06 9400.97 | 4008.55 0.0 411 0 | 2.14 0.22 51.22 0.02
3 2.99e+06 9400.97 | 323.49 0.0 49 0 | 2.23 0.23 52.69 0.02
3 3.00e+06 9400.97 | 6496.10 0.0 629 0 | 2.28 0.24 52.76 0.02
3 3.01e+06 9400.97 | 839.82 0.0 103 0 | 2.35 0.23 52.15 0.02
3 3.02e+06 9400.97 | 6746.13 3928.6 648 359 | 2.22 0.23 52.27 0.02
3 3.02e+06 9400.97 | 2614.53 0.0 273 0 | 2.40 0.21 51.97 0.02
3 3.03e+06 9400.97 | 6482.44 2960.4 632 274 | 2.29 0.22 52.42 0.02
3 3.04e+06 9400.97 | 2710.71 0.0 272 0 | 2.38 0.23 53.30 0.02
3 3.05e+06 9400.97 | 2630.47 0.0 279 0 | 2.26 0.22 52.33 0.02
3 3.06e+06 9400.97 | 6490.97 0.0 627 0 | 2.41 0.22 53.16 0.02
3 3.07e+06 9400.97 | 5756.57 3020.6 558 278 | 2.20 0.21 53.43 0.02
3 3.08e+06 9400.97 | 2955.34 0.0 301 0 | 2.42 0.22 53.79 0.02
3 3.09e+06 9400.97 | 545.33 0.0 74 0 | 2.27 0.23 52.33 0.02
3 3.10e+06 9400.97 | 2198.62 0.0 229 0 | 2.35 0.22 53.38 0.02
3 3.11e+06 9400.97 | 3655.70 0.0 362 0 | 2.25 0.22 53.73 0.02
3 3.12e+06 9400.97 | 7572.88 0.0 688 0 | 2.40 0.23 53.36 0.02
3 3.13e+06 9400.97 | 686.92 0.0 88 0 | 2.31 0.25 53.30 0.02
3 3.14e+06 9400.97 | 4784.15 0.0 470 0 | 2.34 0.22 53.50 0.02
3 3.15e+06 9400.97 | 6257.92 0.0 597 0 | 2.40 0.23 54.19 0.02
3 3.16e+06 9400.97 | 381.11 0.0 56 0 | 2.55 0.22 54.06 0.02
3 3.17e+06 9400.97 | 4226.98 0.0 408 0 | 2.36 0.23 53.91 0.02
3 3.18e+06 9400.97 | 4583.93 0.0 446 0 | 2.33 0.23 54.37 0.02
3 3.19e+06 9400.97 | 6077.15 3476.0 576 311 | 2.27 0.24 54.81 0.02
3 3.20e+06 9400.97 | 5583.01 3175.2 534 278 | 2.34 0.22 54.06 0.02
3 3.21e+06 9400.97 | 6684.09 2633.0 644 234 | 2.33 0.25 54.21 0.02
3 3.22e+06 9400.97 | 2594.13 0.0 277 0 | 2.45 0.24 54.45 0.02
3 3.23e+06 9400.97 | 3951.93 0.0 381 0 | 2.39 0.23 54.81 0.02
3 3.24e+06 9400.97 | 6620.14 0.0 618 0 | 2.37 0.23 54.77 0.02
3 3.24e+06 9400.97 | 3264.37 0.0 323 0 | 2.38 0.25 55.88 0.02
3 3.25e+06 9400.97 | 3717.48 0.0 369 0 | 2.28 0.23 54.36 0.02
3 3.26e+06 9400.97 | 6228.22 3159.0 590 283 | 2.39 0.24 55.27 0.02
3 3.27e+06 9400.97 | 3191.35 0.0 313 0 | 2.42 0.25 53.25 0.02
3 3.28e+06 9400.97 | 6677.04 0.0 652 0 | 2.38 0.24 56.30 0.02
3 3.29e+06 9400.97 | 1202.97 0.0 135 0 | 2.34 0.23 55.98 0.02
3 3.30e+06 9400.97 | 3834.14 0.0 378 0 | 2.26 0.23 55.60 0.02
3 3.31e+06 9400.97 | 7547.63 0.0 715 0 | 2.28 0.25 56.10 0.02
3 3.32e+06 9400.97 | 3160.17 0.0 305 0 | 2.39 0.25 55.70 0.02
3 3.33e+06 9400.97 | 3366.77 0.0 330 0 | 2.20 0.26 56.55 0.02
3 3.34e+06 9400.97 | 2180.08 0.0 226 0 | 2.51 0.25 55.42 0.02
3 3.35e+06 9400.97 | 4012.17 3974.3 392 356 | 2.43 0.26 55.38 0.02
3 3.35e+06 9400.97 | 2136.97 0.0 221 0 | 2.27 0.25 56.35 0.02
3 3.36e+06 9400.97 | 2565.83 0.0 254 0 | 2.27 0.24 56.11 0.02
3 3.38e+06 9400.97 | 1909.27 0.0 205 0 | 2.47 0.25 56.66 0.02
3 3.38e+06 9400.97 | 4336.54 0.0 418 0 | 2.46 0.26 56.28 0.02
3 3.39e+06 9400.97 | 5321.48 3593.4 494 307 | 2.40 0.25 56.29 0.02
3 3.40e+06 9400.97 | 2623.19 0.0 280 0 | 2.33 0.24 56.03 0.02
3 3.41e+06 9400.97 | 4583.58 0.0 446 0 | 2.37 0.26 56.75 0.02
3 3.42e+06 9400.97 | 2202.31 0.0 234 0 | 2.39 0.25 56.72 0.02
3 3.43e+06 9400.97 | 4711.35 0.0 450 0 | 2.34 0.25 57.02 0.02
3 3.44e+06 9400.97 | 222.00 0.0 36 0 | 2.40 0.26 57.51 0.02
3 3.45e+06 9400.97 | 583.82 0.0 95 0 | 2.51 0.32 60.83 0.03
3 3.46e+06 9400.97 | 1659.08 0.0 180 0 | 1.55 0.24 57.01 0.02
3 3.47e+06 9400.97 | 4795.89 0.0 475 0 | 2.46 0.25 56.82 0.02
3 3.48e+06 9400.97 | 3277.17 0.0 314 0 | 2.45 0.26 56.12 0.02
3 3.49e+06 9400.97 | 6135.82 2896.6 584 257 | 2.48 0.26 57.23 0.02
3 3.50e+06 9400.97 | 2316.13 0.0 239 0 | 2.48 0.24 56.64 0.02
3 3.51e+06 9400.97 | 2459.48 0.0 243 0 | 2.46 0.26 57.63 0.02
3 3.52e+06 9400.97 | 545.49 0.0 72 0 | 2.42 0.27 57.16 0.02
3 3.53e+06 9400.97 | 3056.77 0.0 315 0 | 2.49 0.26 56.49 0.02
3 3.54e+06 9400.97 | 3525.36 0.0 334 0 | 2.51 0.26 56.60 0.02
3 3.55e+06 9400.97 | 448.69 0.0 62 0 | 2.40 0.25 57.04 0.02
3 3.56e+06 9400.97 | 4425.29 0.0 417 0 | 2.46 0.25 58.06 0.02
3 3.57e+06 9400.97 | 7055.81 0.0 647 0 | 2.42 0.25 56.89 0.02
3 3.58e+06 9400.97 | 3547.77 0.0 343 0 | 2.40 0.24 57.90 0.02
3 3.59e+06 9400.97 | 1214.78 0.0 140 0 | 2.51 0.27 57.81 0.02
3 3.60e+06 9400.97 | 1943.99 0.0 203 0 | 2.43 0.26 57.63 0.02
3 3.60e+06 9400.97 | 2539.23 0.0 255 0 | 2.46 0.24 57.93 0.02
3 3.61e+06 9400.97 | 5755.68 0.0 533 0 | 2.44 0.27 57.88 0.02
3 3.62e+06 9400.97 | 521.56 0.0 69 0 | 2.38 0.25 57.91 0.02
3 3.63e+06 9400.97 | 2260.82 0.0 224 0 | 2.49 0.26 57.59 0.02
3 3.64e+06 9400.97 | 8032.42 3036.8 733 268 | 2.35 0.26 57.60 0.02
3 3.65e+06 9400.97 | 5434.70 0.0 494 0 | 2.45 0.27 58.28 0.02
3 3.66e+06 9400.97 | 3497.88 0.0 334 0 | 2.29 0.26 57.95 0.02
3 3.67e+06 9400.97 | 5385.06 0.0 530 0 | 2.36 0.27 58.82 0.02
3 3.68e+06 9400.97 | 7716.17 0.0 712 0 | 2.38 0.24 58.36 0.02
3 3.69e+06 9400.97 | 7525.99 0.0 678 0 | 2.33 0.27 57.81 0.02
3 3.70e+06 9400.97 | 970.74 0.0 115 0 | 2.51 0.26 58.44 0.02
3 3.71e+06 9400.97 | 3055.52 0.0 303 0 | 2.47 0.27 59.08 0.02
3 3.72e+06 9400.97 | 6156.14 0.0 593 0 | 2.51 0.27 58.46 0.02
3 3.73e+06 9400.97 | 757.89 0.0 93 0 | 2.50 0.25 58.00 0.02
3 3.74e+06 9400.97 | 2969.20 0.0 291 0 | 2.45 0.26 59.13 0.02
3 3.75e+06 9400.97 | 6579.89 3733.9 612 332 | 2.49 0.26 59.74 0.02
3 3.76e+06 9400.97 | 4382.62 4036.6 412 359 | 2.47 0.27 58.02 0.02
3 3.77e+06 9400.97 | 6604.70 0.0 627 0 | 2.61 0.25 58.69 0.02
3 3.78e+06 9400.97 | 4470.17 3493.4 428 324 | 2.51 0.25 58.66 0.02
3 3.79e+06 9400.97 | 873.06 0.0 108 0 | 2.45 0.26 58.98 0.02
3 3.80e+06 9400.97 | 3919.33 0.0 369 0 | 2.54 0.28 58.55 0.02
3 3.81e+06 9400.97 | 8246.80 4263.3 739 365 | 2.47 0.28 59.17 0.02
3 3.82e+06 9400.97 | 5343.21 0.0 497 0 | 2.50 0.27 59.11 0.02
3 3.83e+06 9400.97 | 3814.69 0.0 364 0 | 2.57 0.27 59.73 0.02
3 3.84e+06 9400.97 | 206.73 0.0 41 0 | 2.46 0.28 59.52 0.02
3 3.85e+06 9400.97 | 1580.95 0.0 165 0 | 1.89 0.26 58.67 0.02
3 3.86e+06 9400.97 | 8301.75 0.0 744 0 | 2.23 0.27 58.73 0.02
3 3.87e+06 9400.97 | 5613.82 4133.1 514 350 | 2.58 0.26 59.09 0.02
3 3.88e+06 9400.97 | 2753.20 0.0 268 0 | 2.60 0.27 59.82 0.02
3 3.89e+06 9400.97 | 3457.35 0.0 327 0 | 2.55 0.28 59.33 0.02
3 3.90e+06 9400.97 | 174.46 0.0 30 0 | 2.48 0.27 59.32 0.02
3 3.91e+06 9400.97 | 428.61 0.0 60 0 | 2.57 0.28 58.55 0.02
3 3.92e+06 9400.97 | 6091.70 0.0 554 0 | 2.56 0.26 60.11 0.02
3 3.93e+06 9400.97 | 7670.87 0.0 710 0 | 2.66 0.28 60.68 0.02
3 3.94e+06 9400.97 | 2778.81 0.0 276 0 | 2.15 0.27 60.50 0.02
3 3.95e+06 9400.97 | 6145.78 0.0 570 0 | 2.58 0.27 59.34 0.02
3 3.96e+06 9400.97 | 6133.93 0.0 551 0 | 2.53 0.27 59.78 0.02
3 3.97e+06 9400.97 | 4161.56 0.0 388 0 | 2.58 0.27 60.53 0.02
3 3.98e+06 9400.97 | 3202.24 0.0 306 0 | 2.47 0.28 59.90 0.02
3 3.99e+06 9400.97 | 5751.28 3699.0 526 318 | 2.62 0.28 60.64 0.02
3 4.00e+06 9400.97 | 9008.62 0.0 876 0 | 2.64 0.27 60.58 0.02
| UsedTime: 49475 | SavedDir: ./Humanoid-v3_ReliableSAC_3
| Learner: Save in ./Humanoid-v3_ReliableSAC_3
"""
else:
raise ValueError('env_name:', env_name)
args.learner_gpus = gpu_id
args.random_seed += gpu_id + 194355
if_check = 0
if if_check:
train_and_evaluate(args)
else:
train_and_evaluate_mp(args)
if __name__ == '__main__':
GPU_ID = int(sys.argv[1]) if len(sys.argv) > 1 else 0 # >=0 means GPU ID, -1 means CPU
DRL_ID = int(sys.argv[2]) if len(sys.argv) > 2 else 1
ENV_ID = int(sys.argv[3]) if len(sys.argv) > 3 else 0
demo_ddpg_h_term(GPU_ID, DRL_ID, ENV_ID)
>>>>>>> dev2
|
alipay/aop/api/domain/AlipayEcoTextDetectModel.py
|
antopen/alipay-sdk-python-all
| 213 |
50897
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
from alipay.aop.api.constant.ParamConstants import *
from alipay.aop.api.domain.SpiDetectionTask import SpiDetectionTask
class AlipayEcoTextDetectModel(object):
def __init__(self):
self._task = None
@property
def task(self):
return self._task
@task.setter
def task(self, value):
if isinstance(value, list):
self._task = list()
for i in value:
if isinstance(i, SpiDetectionTask):
self._task.append(i)
else:
self._task.append(SpiDetectionTask.from_alipay_dict(i))
def to_alipay_dict(self):
params = dict()
if self.task:
if isinstance(self.task, list):
for i in range(0, len(self.task)):
element = self.task[i]
if hasattr(element, 'to_alipay_dict'):
self.task[i] = element.to_alipay_dict()
if hasattr(self.task, 'to_alipay_dict'):
params['task'] = self.task.to_alipay_dict()
else:
params['task'] = self.task
return params
@staticmethod
def from_alipay_dict(d):
if not d:
return None
o = AlipayEcoTextDetectModel()
if 'task' in d:
o.task = d['task']
return o
|
src/python/fsqio/pants/wiki/subsystems/confluence_subsystem.py
|
jglesner/fsqio
| 252 |
50907
|
<gh_stars>100-1000
# coding=utf-8
# Copyright 2019 Foursquare Labs Inc. All Rights Reserved.
from __future__ import absolute_import, division, print_function, unicode_literals
import urllib
from pants.subsystem.subsystem import Subsystem
from pants.util.memo import memoized_property
class ConfluenceSubsystem(Subsystem):
options_scope = 'confluence-wiki'
@staticmethod
def confluence_url_builder(page):
config = page.provides[0].config
title = config['title']
full_url = '{}/wiki/spaces/{}/{}'.format(
ConfluenceSubsystem.wiki_url,
config['space'],
urllib.quote_plus(title),
)
return title, full_url
@classmethod
def register_options(cls, register):
super(ConfluenceSubsystem, cls).register_options(register)
# TODO(mateo): This only supports a single wiki url, should a map of wiki_name:url.
# This is not trivial to unwind, the base plugin assumed self-hosted wiki and url builders.
register(
'--wiki-url',
default=None,
advanced=True,
help='Wiki hostname.',
)
register(
'--email-domain',
advanced=True,
help='Options default domain. For <EMAIL>, use @foo.com. Note: Overrides the email-domain option.',
)
@memoized_property
def wiki_url(self):
wiki_url = self.get_options().wiki_url
if wiki_url is None:
raise ValueError("No wiki URL set! Please set option --{}-wiki-url.".format(self.options_scope))
return wiki_url
@memoized_property
def email_domain(self):
email_domain = self.get_options().email_domain
if email_domain is None:
raise ValueError("No email domain is set! Please set option --{}-email-domain.".format(self.options_scope))
return email_domain
|
lightnion/http/ntor.py
|
pthevenet/lightnion
| 120 |
50915
|
import lightnion as lnn
import nacl.public
import base64
def hand(guard, encode=True):
identity = base64.b64decode(guard['router']['identity'] + '====')
onion_key = base64.b64decode(guard['ntor-onion-key'] + '====')
ephemeral_key, payload = lnn.crypto.ntor.hand(identity, onion_key)
if encode:
payload = str(base64.b64encode(payload), 'utf8')
return payload, (onion_key, ephemeral_key, identity)
def shake(payload, material):
payload = base64.b64decode(payload)
onion_key, ephemeral_key, identity = material
material = lnn.crypto.ntor.shake(ephemeral_key, payload,
identity, onion_key, length=92)
return lnn.crypto.ntor.kdf(material)
|
core/wsgi.py
|
vlafranca/stream_framework_example
| 102 |
50928
|
"""
WSGI config for pinterest_example project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/
"""
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
try:
from dj_static import Cling
except ImportError:
pass
else:
application = Cling(application)
|
train.py
|
thinkreed/ECBSR
| 162 |
50941
|
import torch
import torch.nn as nn
import torch.nn.functional as F
from datas.benchmark import Benchmark
from datas.div2k import DIV2K
from models.ecbsr import ECBSR
from torch.utils.data import DataLoader
import math
import argparse, yaml
import utils
import os
from tqdm import tqdm
import logging
import sys
import time
parser = argparse.ArgumentParser(description='ECBSR')
## yaml configuration files
parser.add_argument('--config', type=str, default=None, help = 'pre-config file for training')
## paramters for ecbsr
parser.add_argument('--scale', type=int, default=2, help = 'scale for sr network')
parser.add_argument('--colors', type=int, default=1, help = '1(Y channls of YCbCr)')
parser.add_argument('--m_ecbsr', type=int, default=4, help = 'number of ecb')
parser.add_argument('--c_ecbsr', type=int, default=8, help = 'channels of ecb')
parser.add_argument('--idt_ecbsr', type=int, default=0, help = 'incorporate identity mapping in ecb or not')
parser.add_argument('--act_type', type=str, default='prelu', help = 'prelu, relu, splus, rrelu')
parser.add_argument('--pretrain', type=str, default=None, help = 'path of pretrained model')
## parameters for model training
parser.add_argument('--patch_size', type=int, default=64, help = 'patch size of HR image')
parser.add_argument('--batch_size', type=int, default=32, help = 'batch size of training data')
parser.add_argument('--data_repeat', type=int, default=1, help = 'times of repetition for training data')
parser.add_argument('--data_augment', type=int, default=1, help = 'data augmentation for training')
parser.add_argument('--epochs', type=int, default=600, help = 'number of epochs')
parser.add_argument('--test_every', type=int, default=1, help = 'test the model every N epochs')
parser.add_argument('--log_every', type=int, default=1, help = 'print log of loss, every N steps')
parser.add_argument('--log_path', type=str, default="./experiments/")
parser.add_argument('--lr', type=float, default=5e-4, help = 'learning rate of optimizer')
parser.add_argument('--store_in_ram', type=int, default=0, help = 'store the whole training data in RAM or not')
## hardware specification
parser.add_argument('--gpu_id', type=int, default=0, help = 'gpu id for training')
parser.add_argument('--threads', type=int, default=1, help = 'number of threads for training')
## dataset specification
parser.add_argument('--div2k_hr_path', type=str, default='/Users/xindongzhang/Documents/SRData/DIV2K/DIV2K_train_HR', help = '')
parser.add_argument('--div2k_lr_path', type=str, default='/Users/xindongzhang/Documents/SRData/DIV2K/DIV2K_train_LR_bicubic', help = '')
parser.add_argument('--set5_hr_path', type=str, default='/Users/xindongzhang/Documents/SRData/benchmark/Set5/HR', help = '')
parser.add_argument('--set5_lr_path', type=str, default='/Users/xindongzhang/Documents/SRData/benchmark/Set5/LR_bicubic', help = '')
parser.add_argument('--set14_hr_path', type=str, default='/Users/xindongzhang/Documents/SRData/benchmark/Set14/HR', help = '')
parser.add_argument('--set14_lr_path', type=str, default='/Users/xindongzhang/Documents/SRData/benchmark/Set14/LR_bicubic', help = '')
parser.add_argument('--b100_hr_path', type=str, default='/Users/xindongzhang/Documents/SRData/benchmark/B100/HR', help = '')
parser.add_argument('--b100_lr_path', type=str, default='/Users/xindongzhang/Documents/SRData/benchmark/B100/LR_bicubic', help = '')
parser.add_argument('--u100_hr_path', type=str, default='/Users/xindongzhang/Documents/SRData/benchmark/Urban100/HR', help = '')
parser.add_argument('--u100_lr_path', type=str, default='/Users/xindongzhang/Documents/SRData/benchmark/Urban100/LR_bicubic', help = '')
if __name__ == '__main__':
args = parser.parse_args()
if args.config:
opt = vars(args)
yaml_args = yaml.load(open(args.config), Loader=yaml.FullLoader)
opt.update(yaml_args)
if args.colors == 3:
raise ValueError("ECBSR is trained and tested with colors=1.")
device = None
if args.gpu_id >= 0 and torch.cuda.is_available():
print("use cuda & cudnn for acceleration!")
print("the gpu id is: {}".format(args.gpu_id))
device = torch.device('cuda:{}'.format(args.gpu_id))
torch.backends.cudnn.benchmark = True
else:
print("use cpu for training!")
device = torch.device('cpu')
torch.set_num_threads(args.threads)
div2k = DIV2K(
args.div2k_hr_path,
args.div2k_lr_path,
train=True,
augment=args.data_augment,
scale=args.scale,
colors=args.colors,
patch_size=args.patch_size,
repeat=args.data_repeat,
store_in_ram=args.store_in_ram
)
set5 = Benchmark(args.set5_hr_path, args.set5_lr_path, scale=args.scale, colors=args.colors, store_in_ram=args.store_in_ram)
set14 = Benchmark(args.set14_hr_path, args.set14_lr_path, scale=args.scale, colors=args.colors, store_in_ram=args.store_in_ram)
b100 = Benchmark(args.b100_hr_path, args.b100_lr_path, scale=args.scale, colors=args.colors, store_in_ram=args.store_in_ram)
u100 = Benchmark(args.u100_hr_path, args.u100_lr_path, scale=args.scale, colors=args.colors, store_in_ram=args.store_in_ram)
train_dataloader = DataLoader(dataset=div2k, num_workers=args.threads, batch_size=args.batch_size, shuffle=True, pin_memory=True, drop_last=True)
valid_dataloaders = []
valid_dataloaders += [{'name': 'set5', 'dataloader': DataLoader(dataset=set5, batch_size=1, shuffle=False)}]
valid_dataloaders += [{'name': 'set14', 'dataloader': DataLoader(dataset=set14, batch_size=1, shuffle=False)}]
valid_dataloaders += [{'name': 'b100', 'dataloader': DataLoader(dataset=b100, batch_size=1, shuffle=False)}]
valid_dataloaders += [{'name': 'u100', 'dataloader': DataLoader(dataset=u100, batch_size=1, shuffle=False)}]
## definitions of model, loss, and optimizer
model = ECBSR(module_nums=args.m_ecbsr, channel_nums=args.c_ecbsr, with_idt=args.idt_ecbsr, act_type=args.act_type, scale=args.scale, colors=args.colors).to(device)
loss_func = nn.L1Loss()
optimizer = torch.optim.Adam(model.parameters(), lr=args.lr)
if args.pretrain is not None:
print("load pretrained model: {}!".format(args.pretrain))
model.load_state_dict(torch.load(args.pretrain))
else:
print("train the model from scratch!")
## auto-generate the output logname
timestamp = utils.cur_timestamp_str()
experiment_name = "ecbsr-x{}-m{}c{}-{}-{}".format(args.scale, args.m_ecbsr, args.c_ecbsr, args.act_type, timestamp)
experiment_path = os.path.join(args.log_path, experiment_name)
if not os.path.exists(experiment_path):
os.makedirs(experiment_path)
experiment_model_path = os.path.join(experiment_path, 'models')
if not os.path.exists(experiment_model_path):
os.makedirs(experiment_model_path)
log_name = os.path.join(experiment_path, "log.txt")
sys.stdout = utils.ExperimentLogger(log_name, sys.stdout)
stat_dict = utils.get_stat_dict()
## save training paramters
exp_params = vars(args)
exp_params_name = os.path.join(experiment_path, 'config.yml')
with open(exp_params_name, 'w') as exp_params_file:
yaml.dump(exp_params, exp_params_file, default_flow_style=False)
timer_start = time.time()
for epoch in range(args.epochs):
epoch_loss = 0.0
stat_dict['epochs'] = epoch
model = model.train()
print("##===========Epoch: {}=============##".format(epoch))
for iter, batch in enumerate(train_dataloader):
optimizer.zero_grad()
lr, hr = batch
lr, hr = lr.to(device), hr.to(device)
sr = model(lr)
loss = loss_func(sr, hr)
loss.backward()
optimizer.step()
epoch_loss += float(loss)
if (iter + 1) % args.log_every == 0:
cur_steps = (iter+1)*args.batch_size
total_steps = len(train_dataloader.dataset)
fill_width = math.ceil(math.log10(total_steps))
cur_steps = str(cur_steps).zfill(fill_width)
epoch_width = math.ceil(math.log10(args.epochs))
cur_epoch = str(epoch).zfill(epoch_width)
avg_loss = epoch_loss / (iter + 1)
stat_dict['losses'].append(avg_loss)
timer_end = time.time()
duration = timer_end - timer_start
timer_start = timer_end
print("Epoch:{}, {}/{}, loss: {:.4f}, time: {:.3f}".format(cur_epoch, cur_steps, total_steps, avg_loss, duration))
if (epoch + 1) % args.test_every == 0:
torch.set_grad_enabled(False)
test_log = ""
model = model.eval()
for valid_dataloader in valid_dataloaders:
avg_psnr = 0.0
avg_ssim = 0.0
name = valid_dataloader['name']
loader = valid_dataloader['dataloader']
for lr, hr in tqdm(loader, ncols=80):
lr, hr = lr.to(device), hr.to(device)
sr = model(lr)
# crop
hr = hr[:, :, args.scale:-args.scale, args.scale:-args.scale]
sr = sr[:, :, args.scale:-args.scale, args.scale:-args.scale]
# quantize
hr = hr.clamp(0, 255)
sr = sr.clamp(0, 255)
# calculate psnr
psnr = utils.calc_psnr(sr, hr)
ssim = utils.calc_ssim(sr, hr)
avg_psnr += psnr
avg_ssim += ssim
avg_psnr = round(avg_psnr/len(loader), 2)
avg_ssim = round(avg_ssim/len(loader), 4)
stat_dict[name]['psnrs'].append(avg_psnr)
stat_dict[name]['ssims'].append(avg_ssim)
if stat_dict[name]['best_psnr']['value'] < avg_psnr:
stat_dict[name]['best_psnr']['value'] = avg_psnr
stat_dict[name]['best_psnr']['epoch'] = epoch
if stat_dict[name]['best_ssim']['value'] < avg_ssim:
stat_dict[name]['best_ssim']['value'] = avg_ssim
stat_dict[name]['best_ssim']['epoch'] = epoch
test_log += "[{}-X{}], PSNR/SSIM: {:.2f}/{:.4f} (Best: {:.2f}/{:.4f}, Epoch: {}/{})\n".format(
name, args.scale, float(avg_psnr), float(avg_ssim),
stat_dict[name]['best_psnr']['value'], stat_dict[name]['best_ssim']['value'],
stat_dict[name]['best_psnr']['epoch'], stat_dict[name]['best_ssim']['epoch'])
# print log & flush out
print(test_log)
sys.stdout.flush()
# save model
saved_model_path = os.path.join(experiment_model_path, 'model_x{}_{}.pt'.format(args.scale, epoch))
torch.save(model.state_dict(), saved_model_path)
torch.set_grad_enabled(True)
# save stat dict
## save training paramters
stat_dict_name = os.path.join(experiment_path, 'stat_dict.yml')
with open(stat_dict_name, 'w') as stat_dict_file:
yaml.dump(stat_dict, stat_dict_file, default_flow_style=False)
|
research/cgroups.py
|
chuongmep/rhino.inside-revit
| 166 |
50953
|
"""Group Revit built-in categories logically and output the data in json
The built-in categories are provided in text files under DATA_DIR
Usage:
python3 ./cgroups.py group and output categories
python3 ./cgroups.py <catname> group and output <catname> category only
"""
# pylint: disable=bad-continuation
import sys
import os
import os.path as op
from typing import Set, List, TypeVar
import json
import re
DATA_DIR = "./bic_data"
CGROUP_T = TypeVar("CGROUP") # pylint: disable=invalid-name
class CGROUP:
"""Represents a category grouping"""
def __init__(
self,
name: str,
exclusives: List[str],
includes: List[str],
excludes: List[str],
cgroups: List[CGROUP_T],
hidden: bool = False,
):
self.name: str = name
self.exclusives: List[str] = exclusives
self.includes: List[str] = includes
self.excludes: List[str] = excludes
self.cgroups: List[CGROUP_T] = cgroups
self.hidden: bool = hidden
class CategoryComp:
"""Represents data for a category selector component"""
def __init__(self, name: str, categories: List[str]):
self.name = name
self.categories = categories
class CategoryCompCollection:
"""Represents data for a collection of category selector components"""
def __init__(
self,
version: str,
bics: List[str],
components: List[CategoryComp],
used_bics: Set[str],
):
self.meta = {
"version": version,
"total": len(bics),
"included": len(used_bics),
"excluded": list(bics.difference(used_bics)),
}
self.components = components
# =============================================================================
# this is a hand-crafted tree of CGroups that represents the grouping logic
# -----------------------------------------------------------------------------
CGROUPS = [
CGROUP(
name="Skip",
exclusives=[
r".+Obsolete.*",
r".+OBSOLETE.*",
r".+Deprecated.*",
r"OST_GbXML.*",
r"OST_gbXML.*",
r"OST_DSR_.*",
],
includes=[],
excludes=[],
cgroups=[],
hidden=True,
),
CGROUP(
name="Site",
exclusives=[],
includes=[
r"OST_Site.*",
r"OST_Sewer.*",
r"OST_Road.*",
r"OST_Building.*",
r"OST_Contour.*",
r"OST_Parking.*",
],
excludes=[],
cgroups=[
CGROUP(
name="Topography",
exclusives=[],
includes=[r"OST_.*Topo.*"],
excludes=[],
cgroups=[],
),
],
),
CGROUP(
name="References",
exclusives=[],
includes=[
r"OST_Grid.*",
r"OST_Level.*",
r"OST_Level.*",
r"OST_Constraint.*",
r"OST_Reference.*",
],
excludes=[
r"OST_GridChains.*",
r"OST_ReferencePoints.*",
r"OST_ReferenceViewer.*",
],
cgroups=[],
),
CGROUP(
name="Modeling",
exclusives=[],
includes=[r"OST_Generic.*",],
excludes=["OST_GenericLines",],
cgroups=[
CGROUP(
name="Mass",
exclusives=[],
includes=[r"OST_Mass.*"],
excludes=[
r"OST_.+Cutter",
r"OST_.+Splitter",
r"OST_.+All",
r"OST_.+Outlines",
],
cgroups=[],
),
CGROUP(
name="Ceilings",
exclusives=[],
includes=[r"OST_Ceiling.*"],
excludes=[
r"OST_.+Cut.*",
r"OST_.+Projection.*",
r"OST_.+Default.*",
],
cgroups=[],
),
CGROUP(
name="Columns",
exclusives=[],
includes=[r"OST_Column.*"],
excludes=[r"OST_.+LocalCoordSys"],
cgroups=[],
),
CGROUP(
name="Curtain Systems",
exclusives=[],
includes=[r"OST_Curta.*"],
excludes=[
r"OST_.+FaceManager.*",
r"OST_CurtainGrids.+",
r"OST_Curtain.+Cut",
],
cgroups=[],
),
CGROUP(
name="Floors",
exclusives=[],
includes=[r"OST_Floor.*"],
excludes=[
r"OST_.+LocalCoordSys",
r"OST_.+Cut.*",
r"OST_.+Projection.*",
r"OST_.+Default.*",
],
cgroups=[],
),
CGROUP(
name="Doors",
exclusives=[],
includes=[r"OST_Door.*"],
excludes=[r"OST_.+Cut.*", r"OST_.+Projection.*",],
cgroups=[],
),
CGROUP(
name="Casework",
exclusives=[],
includes=[r"OST_Casework.*"],
excludes=[],
cgroups=[],
),
CGROUP(
name="Windows",
exclusives=[],
includes=[r"OST_Window.*"],
excludes=[r"OST_.+Cut.*", r"OST_.+Projection.*",],
cgroups=[],
),
CGROUP(
name="Furniture",
exclusives=[],
includes=[r"OST_Furniture.*"],
excludes=[],
cgroups=[],
),
CGROUP(
name="Adaptive",
exclusives=[],
includes=[r"OST_Adaptive.*"],
excludes=[],
cgroups=[],
),
CGROUP(
name="Speciality",
exclusives=[],
includes=[r"OST_Speciality.*"],
excludes=[],
cgroups=[],
),
CGROUP(
name="Openings",
exclusives=[r"OST_.+Opening", r"OST_Arc.*", r"OST_Shaft.*",],
includes=[],
excludes=[r"OST_.+Cut.*", r"OST_.+Projection.*",],
cgroups=[],
),
CGROUP(
name="Railing",
exclusives=[],
includes=[r"OST_Railing.*"],
excludes=[r"OST_.+Cut.*", r"OST_.+Projection.*",],
cgroups=[],
),
CGROUP(
name="Stairs",
exclusives=[],
includes=[r"OST_Stair.*", r"OST_.+Stairs"],
excludes=[r"OST_.+Cut.*", r"OST_.+Projection.*",],
cgroups=[],
),
CGROUP(
name="Ramps",
exclusives=[],
includes=[r"OST_Ramp.*"],
excludes=[r"OST_.+Cut.*", r"OST_.+Projection.*",],
cgroups=[],
),
CGROUP(
name="Walls",
exclusives=[],
includes=[r"OST_Wall.*", r"OST_Reveals", r"OST_Stacked.*"],
excludes=[
r"OST_.+LocalCoordSys",
r"OST_.+RefPlanes",
r"OST_.+Default",
r"OST_.+Cut.*",
r"OST_.+Projection.*",
],
cgroups=[],
),
CGROUP(
name="Roofs",
exclusives=[],
includes=[
r"OST_Roof.*",
r"OST_Fascia.*",
r"OST_Purlin.*",
r"OST_Gutter.*",
r"OST_Cornices.*",
r"OST_Dormer.*",
],
excludes=[
r"OST_.+Opening.*",
r"OST_.+Cut.*",
r"OST_.+Projection.*",
],
cgroups=[],
),
CGROUP(
name="Spatial",
exclusives=[],
includes=[
r"OST_Area.*",
r"OST_Zone.*",
r"OST_MEPSpace.*",
r"OST_Zoning.*",
r"OST_Room.*",
],
excludes=[
r"OST_.+Fill",
r"OST_.+Visibility",
r"OST_AreaRein.*",
r"OST_AreaReport.*",
],
cgroups=[],
),
CGROUP(
name="Structural",
exclusives=[],
includes=[
r"OST_Struct.+",
r"OST_.+Bracing",
r"OST_Truss.*",
r"OST_Joist.*",
r"OST_FabricArea.*",
r"OST_Rebar.*",
r"OST_Girder.*",
r"OST_Edge.*",
r"OST_Load.*",
r"OST_Internal.*Load.*",
r"OST_Isolated.*",
r"OST_Framing.*",
r"OST_Footing.*",
r"OST_Foundation.*",
r"OST_Fnd.*",
r"OST_Span.*",
r"OST_Steel.*",
r"OST_SWall.*",
r"OST_Brace.*",
r"OST_Bridge.*",
r"OST_.*PointLoad.*",
r"OST_Beam.*",
],
excludes=[
r"OST_.+LocalCoordSys",
r"OST_.+Other",
r"OST_.+LocationLine",
r"OST_.+PlanReps",
r"OST_.+NobleWarning",
r"OST_.+Failed",
],
cgroups=[],
),
CGROUP(
name="Mechanical",
exclusives=[],
includes=[
r"OST_Mechanical.*",
r"OST_.+Ducts",
r"OST_Duct.*",
r"OST_MEPAnalytical.*",
r"OST_Flex.*",
r"OST_MEPSystem.*",
r"OST_HVAC.*",
r"OST_Fabrication.+",
],
excludes=[
r"OST_.+Reference.*",
r"OST_.+TmpGraphic.*",
r"OST_.+Visibility",
],
cgroups=[],
),
CGROUP(
name="Electrical",
exclusives=[],
includes=[
r"OST_.+Pipes",
r"OST_Conduit.*",
r"OST_Cable.*",
r"OST_Wire.*",
r"OST_Light.*",
r"OST_Device.*",
r"OST_Panel.*",
r"OST_Elec.*",
r"OST_Routing.*",
r"OST_Switch.*",
r"OST_Connector.*",
r"OST_Route.*",
r"OST_.+Devices|OST_.+Device(Tags)|OST_.+Templates?",
],
excludes=[
r"OST_.+Axis",
r"OST_.+Template.*",
r"OST_.+Definition.*",
r"OST_.+Material",
],
cgroups=[],
),
CGROUP(
name="Plumbing",
exclusives=[],
includes=[
r"OST_Pipe.*",
r"OST_Fluid.*",
r"OST_Fixture.*",
r"OST_PlumbingFixture.*",
r"OST_Piping.*",
r"OST_Sprinkler.*",
],
excludes=[r"OST_.+Reference.*", r"OST_.+Material",],
cgroups=[],
),
],
),
CGROUP(
name="Drafting",
exclusives=[],
includes=[],
excludes=[],
cgroups=[
CGROUP(
name="Views",
exclusives=[],
includes=[
r"OST_.*Annotation.*",
"OST_Views",
"OST_PlanRegion",
r"OST_Schedule.*",
r"OST_Camera.*",
r"OST_Crop.*",
r"OST_Compass.*",
r"OST_Section.*",
r"OST_Sun.*",
r"OST_RenderRegions",
],
excludes=[r"OST_.+ViewParamGroup",],
cgroups=[],
),
CGROUP(
name="Sheets",
exclusives=[],
includes=[
r"OST_Sheet.*",
r"OST_Viewport.*",
r"OST_Title.*",
r"OST_Guide.*",
r"OST_Revisions.*",
],
excludes=[],
cgroups=[],
),
CGROUP(
name="Tags",
exclusives=[r"OST_Tag.*", r"OST_.+Tags", r"OST_.+Labels"],
includes=[],
excludes=[],
cgroups=[],
),
CGROUP(
name="Annotation",
exclusives=[
r"OST_.+DownArrow.*",
r"OST_.+DownText.*",
r"OST_.+UpArrow.*",
r"OST_.+UpText.*",
r"OST_.+Annotation.*",
r"OST_Callout.*",
r"OST_Spot.*",
r"OST_Cloud.*",
r"OST_Elev.*",
r"OST_Repeating.*",
"OST_BrokenSectionLine",
r"OST_Legend.*",
r"OST_Detail.*",
"OST_InvisibleLines",
"OST_DemolishedLines",
"OST_InsulationLines",
"OST_FillPatterns",
"OST_FilledRegion",
"OST_HiddenLines",
r"OST_Center.*",
r"OST_Keynote.*",
r"OST_Matchline.*",
r"OST_Model.*",
r"OST_.+Text.*",
r"OST_.+Overhead.*",
r"OST_Curve.*",
r"OST_Dim.*",
r"OST_Dimension.*",
r"OST_Masking.*",
r"OST_.+Tag.*",
r"OST_.+Label.*",
r"OST_.+Symbol.*",
r"OST_.+TickMark.*",
"OST_RevisionClouds",
],
includes=[],
excludes=[r"OST_DimLock.+", r"OST_IOS.+", r"OST_.+Symbology",],
cgroups=[],
),
],
),
CGROUP(
name="Containers",
exclusives=[],
includes=[
r"OST_Part.*",
r"OST_Assemblies.*",
r"OST_Group.*",
r"OST_.+Groups",
],
excludes=[],
cgroups=[],
),
CGROUP(
name="Links",
exclusives=[
"OST_RvtLinks",
"OST_TopographyLink",
r"OST_Coordination.*",
r"OST_PointCloud.*",
r"OST_Raster.*",
],
includes=[],
excludes=[],
cgroups=[],
),
CGROUP(
name="Analysis",
exclusives=[r"OST_.*Analy.*"],
includes=[],
excludes=[r"OST_AnalysisResults"],
cgroups=[
CGROUP(
name="Paths",
exclusives=[r"OST_Path.*"],
includes=[],
excludes=[],
cgroups=[],
),
],
),
CGROUP(
name="Rendering",
exclusives=[],
includes=[r"OST_Entourage.*",],
excludes=[],
cgroups=[
CGROUP(
name="Materials",
exclusives=[
r"OST_Material.*",
r"OST_Appearance.*",
r"OST_Decal.*",
r"OST_Planting.*",
],
includes=[],
excludes=[],
cgroups=[],
)
],
),
]
# =============================================================================
def expand_exclusives(
cgroup: CGROUP, used_bics: Set[str], remaining_bics: Set[str]
):
"""Apply the exclusive filters and expand to builtin category names"""
exclusives = set()
excludes = set()
local_bics = remaining_bics.copy()
for bic in local_bics:
for excluspat in cgroup.exclusives:
if re.match(excluspat, bic):
if bic in used_bics:
raise Exception(
f'Exclusive conflict in "{cgroup.name}" @ "{excluspat}"'
)
exclusives.add(bic)
filtered_exclusives = exclusives.copy()
for exclusitem in exclusives:
for excpat in cgroup.excludes:
if re.match(excpat, exclusitem):
excludes.add(exclusitem)
filtered_exclusives.difference_update(excludes)
used_bics.update(filtered_exclusives)
remaining_bics.difference_update(used_bics)
sub_components = []
for sub_cgroup in cgroup.cgroups:
sub_components.append(
expand_exclusives(sub_cgroup, used_bics, remaining_bics)
)
cgroup.exclusives = filtered_exclusives
def expand_includes(
cgroup: CGROUP, used_bics: Set[str], remaining_bics: Set[str]
):
"""Apply the include filters and expand to builtin category names"""
includes = set()
excludes = set()
local_bics = remaining_bics.copy()
for bic in local_bics:
for incpat in cgroup.includes:
if re.match(incpat, bic):
includes.add(bic)
filtered_includes = includes.copy()
for incitem in includes:
for excpat in cgroup.excludes:
if re.match(excpat, incitem):
excludes.add(incitem)
filtered_includes.difference_update(excludes)
used_bics.update(filtered_includes)
sub_components = []
for sub_cgroup in cgroup.cgroups:
sub_components.append(
expand_includes(sub_cgroup, used_bics, remaining_bics)
)
cgroup.includes = filtered_includes
def filter_cgroup(cgroup: CGROUP, name: str):
"""Find a cgroup in tree by name"""
if cgroup.name == name:
return cgroup
for scgroup in cgroup.cgroups:
if mcg := filter_cgroup(scgroup, name):
return mcg
def create_ccomp(cgroup: CGROUP) -> CategoryComp:
"""Create component data from expanded cgroup"""
root_categories = cgroup.exclusives
root_categories.update(cgroup.includes)
sub_components = []
for sub_cgroup in cgroup.cgroups:
sub_components.append(create_ccomp(sub_cgroup))
sub_categories = {}
for sub_comp in sub_components:
sub_categories[sub_comp.name] = sub_comp.categories
all_sub_bips = []
for sub_bips in sub_comp.categories.values():
all_sub_bips.extend(sub_bips)
root_categories = root_categories.difference(all_sub_bips)
categories = {"_": sorted(list(root_categories))}
categories.update(sub_categories)
return CategoryComp(name=cgroup.name, categories=categories)
def create_ccomp_collection(
version: str, builtin_category_names: List[str]
) -> CategoryCompCollection:
"""Create component collection from list of builtin category names"""
remaining_bics = builtin_category_names.copy()
used_bics: Set[str] = set()
for cgroup in CGROUPS:
expand_exclusives(cgroup, used_bics, remaining_bics)
for cgroup in CGROUPS:
expand_includes(cgroup, used_bics, remaining_bics)
all_comps: List[CategoryComp] = []
if len(sys.argv) > 1:
matching_cgroup = None
for cgroup in CGROUPS:
matching_cgroup = filter_cgroup(cgroup, name=sys.argv[1])
if matching_cgroup:
all_comps.append(create_ccomp(matching_cgroup))
else:
for cgroup in CGROUPS:
if not cgroup.hidden:
all_comps.append(create_ccomp(cgroup))
return CategoryCompCollection(
version=version,
bics=builtin_category_names,
components=all_comps,
used_bics=used_bics,
)
def load_bics(data_file: str):
"""Load builtin category names from file"""
bics_data: Set[str] = set()
with open(data_file, "r") as bicfile:
bics_data.update([x.strip() for x in bicfile.readlines()])
return bics_data
def dump_bics(data_file: str, ccomps_col: CategoryCompCollection):
"""Dump component collection data into file"""
with open(data_file, "w") as datafile:
json.dump(
ccomps_col, datafile, indent=2, default=lambda x: x.__dict__,
)
for entry in os.listdir(DATA_DIR):
if entry.endswith(".txt"):
bic_file = op.join(DATA_DIR, entry)
dafa_filename = op.splitext(op.basename(bic_file))[0]
bic_file_version = dafa_filename.split("_")[1]
bic_names = load_bics(bic_file)
ccomp_collection = create_ccomp_collection(bic_file_version, bic_names)
json_file = op.join(DATA_DIR, dafa_filename + ".json")
dump_bics(json_file, ccomp_collection)
|
scripts/undistort_h36m.py
|
yihui-he2020/epipolar-transformers
| 360 |
50970
|
if __name__ == '__main__' and __package__ is None:
import sys
from os import path
sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ))
import os
import torch
from utils.model_serialization import strip_prefix_if_present
from utils import zipreader
import argparse
from tqdm import tqdm
import pickle
import cv2
import numpy as np
parser = argparse.ArgumentParser(description="PyTorch Keypoints Training")
parser.add_argument(
"--src",
default="~/datasets",
help="source model",
type=str,
)
parser.add_argument(
"--dst",
default="~/local/datasets/h36m/undistortedimages",
help="dst model",
type=str,
)
parser.add_argument(
"--anno",
default="~/datasets/h36m/annot/h36m_validation.pkl",
type=str,
)
args = parser.parse_args()
src = os.path.expanduser(args.src)
dst = os.path.expanduser(args.dst)
with open(os.path.expanduser(args.anno), 'rb') as f:
data = pickle.load(f)
for db_rec in tqdm(data):
path = db_rec['image']
image_dir = 'images.zip@'
image_file = os.path.join(src, db_rec['source'], image_dir, 'images', db_rec['image'])
output_path = os.path.join(dst, path)
if os.path.exists(output_path):
continue
output_dir = os.path.dirname(output_path)
os.makedirs(output_dir, exist_ok=True)
data_numpy = zipreader.imread(
image_file, cv2.IMREAD_COLOR | cv2.IMREAD_IGNORE_ORIENTATION)
camera = db_rec['camera']
K = np.array([
[float(camera['fx']), 0, float(camera['cx'])],
[0, float(camera['fy']), float(camera['cy'])],
[0, 0, 1.],
])
distCoeffs = np.array([float(i) for i in [camera['k'][0], camera['k'][1], camera['p'][0], camera['p'][1], camera['k'][2]]])
data_numpy = cv2.undistort(data_numpy, K, distCoeffs)
#cv2.imwrite(output_path, data_numpy, [int(cv2.IMWRITE_JPEG_QUALITY), 100])
#cv2.imwrite(output_path, data_numpy)
cv2.imwrite(output_path, data_numpy, [int(cv2.IMWRITE_JPEG_QUALITY), 90])
|
bigquery_schema_generator/anonymize.py
|
ZiggerZZ/bigquery-schema-generator
| 170 |
50990
|
#!/usr/bin/env python3
#
# Copyright 2018 <NAME>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Anonymize a newline-delimited JSON data file. By default, both the keys and
values are anonymized to prevent any chance of extracting the original source of
the data file. To preserve the keys, use the --preserve_keys flag.
The purpose of this script is to anonymize large JSON data files for
benchmarking purposes, while preserving the structure of the JSON data file so
that the BigQuery schema of the anonymized data file is structurally identical
to the original data file (modulo the names of the keys). If the --preserve_keys
flag is used, then the BigQuery schema file from the anonymized data should
be identical to the schema file from the original dataset.
Usage: anonymize.py [-h] [flags ...] < file.data.json > file.anon.data.json
"""
import argparse
import json
import logging
import sys
from collections import OrderedDict
from bigquery_schema_generator.generate_schema import SchemaGenerator
class Anonymizer:
"""Anonymize both the key and value of a newline-delimited JSON file.
The anon_map is used to keep track of the (key -> anon_key) mapping.
anon_map := {
key: anon_entry,
...
}
anon_entry := {
'anon_key': anonymous_key,
'anon_map': anon_map,
'next_anon_key': next_key
}
"""
def __init__(self, debugging_interval=1000, preserve_keys=False):
self.debugging_interval = debugging_interval
self.preserve_keys = preserve_keys
self.line_number = 0
def log_error(self, msg):
logging.error('line: %s; msg: %s', self.line_number, msg)
def anonymize_file(self, file):
"""Anonymous the JSON data record one line at a time from the
given file-like object.
"""
anon_entry = {}
for line in file:
self.line_number += 1
if self.line_number % self.debugging_interval == 0:
logging.info("Processing line %s", self.line_number)
json_object = json.loads(line)
if not isinstance(json_object, dict):
self.log_error(
'Top level record must be an Object but was a %s' %
type(json_object))
continue
try:
anon_dict = self.anonymize_dict(json_object, anon_entry)
except Exception as e:
self.log_error(str(e))
json.dump(anon_dict, sys.stdout)
print()
logging.info("Processed %s lines", self.line_number)
def anonymize_dict(self, json_dict, anon_entry):
"""Recursively anonymize the JSON dictionary object, replacing the key
and the value with their anonymized versions. Returns the 'anon_dict'
with the 'anon_entry' updated.
"""
# Add some bookkeeping variables to 'anon_entry' for a dict.
anon_map = anon_entry.get('anon_map')
if not anon_map:
anon_map = {}
anon_entry['anon_map'] = anon_map
next_anon_key = anon_entry.get('next_anon_key')
if not next_anon_key:
next_anon_key = 'a'
anon_dict = OrderedDict()
for key, value in json_dict.items():
child_anon_entry = anon_map.get(key)
if not child_anon_entry:
child_anon_entry = {}
if self.preserve_keys:
child_anon_entry['anon_key'] = key
else:
# Pad the anonymous key to preserve length
padding = max(0, len(key) - len(next_anon_key))
child_anon_entry['anon_key'] = \
next_anon_key + ('.' * padding)
next_anon_key = increment_anon_key(next_anon_key)
anon_map[key] = child_anon_entry
if isinstance(value, dict):
value = self.anonymize_dict(value, child_anon_entry)
elif isinstance(value, list):
value = self.anonymize_list(value, child_anon_entry)
else:
value = self.anonymize_value(value)
child_anon_key = child_anon_entry['anon_key']
anon_dict[child_anon_key] = value
# Update the next_anon_key so that anon_entry can be reused
# for multiple dicts, e.g. in a list or lines in a file.
anon_entry['next_anon_key'] = next_anon_key
return anon_dict
def anonymize_list(self, json_list, anon_entry):
"""Anonymize the given list, calling anonymize_dict() recursively if
necessary.
"""
anon_list = []
for item in json_list:
if isinstance(item, list):
item = self.anonymize_list(item, anon_entry)
elif isinstance(item, dict):
item = self.anonymize_dict(item, anon_entry)
else:
item = self.anonymize_value(item)
anon_list.append(item)
return anon_list
def anonymize_value(self, value):
"""Anonymize the value. A string is replaced with a string of an equal
number of '*' characters. DATE, TIME and TIMESTAMP values are replaced
with a fixed versions of those. An integer is replaced with just a '1'.
A float is replaced with just a '2.0'. A boolean is replaced with just a
'True'.
"""
if isinstance(value, str):
if SchemaGenerator.TIMESTAMP_MATCHER.match(value):
return '2018-07-17T09:05:00-07:00'
elif SchemaGenerator.DATE_MATCHER.match(value):
return '2018-07-17'
elif SchemaGenerator.TIME_MATCHER.match(value):
return '09:05:00'
else:
# Pad the anonymous string to the same length as the original
return '*' * len(value)
elif isinstance(value, bool):
return True
elif isinstance(value, int):
return 1
elif isinstance(value, float):
return 2.0
elif value is None:
return None
else:
raise Exception('Unsupported node type: %s' % type(value))
def run(self):
self.anonymize_file(sys.stdin)
def increment_anon_key(key):
"""Increment the key in base-26 to the next key. The sequence looks like
this: [a, ..., z, ba, bb, ..., bz, ..., baa, ...].
Note that this is not the the Excel column label sequence. Base-26 is easier
to generate and it's good enough for this use-case. Also note that this
method performs NO validation, it assumes that all the digits are in the
[a-z] range.
"""
reversed_key = key[::-1]
new_key = ''
carry = 1
for c in reversed_key:
if carry == 0:
new_key += c
continue
new_ord = ord(c) + carry
if new_ord == ord('z') + 1:
newc = 'a'
carry = 1
else:
newc = chr(new_ord)
carry = 0
new_key += newc
if carry == 1:
new_key += 'b'
return new_key[::-1]
def main():
# Configure command line flags.
parser = argparse.ArgumentParser(
description='Anonymize newline-delimited JSON data file.')
parser.add_argument(
'--preserve_keys',
help='Preserve the keys, do not anonymize them',
action="store_true")
parser.add_argument(
'--debugging_interval',
help='Number of lines between heartbeat debugging messages.',
type=int,
default=1000)
args = parser.parse_args()
# Configure logging.
logging.basicConfig(level=logging.INFO)
anonymizer = Anonymizer(args.debugging_interval, args.preserve_keys)
anonymizer.run()
if __name__ == '__main__':
main()
|
src/utils.py
|
teddykoker/image-gpt
| 196 |
50993
|
<filename>src/utils.py
import torch
def squared_euclidean_distance(a, b):
b = torch.transpose(b, 0, 1)
a2 = torch.sum(torch.square(a), dim=1, keepdims=True)
b2 = torch.sum(torch.square(b), dim=0, keepdims=True)
ab = torch.matmul(a, b)
d = a2 - 2 * ab + b2
return d
def quantize(x, centroids):
b, c, h, w = x.shape
# [B, C, H, W] => [B, H, W, C]
x = x.permute(0, 2, 3, 1).contiguous()
x = x.view(-1, c) # flatten to pixels
d = squared_euclidean_distance(x, centroids)
x = torch.argmin(d, 1)
x = x.view(b, h, w)
return x
def unquantize(x, centroids):
return centroids[x]
|
python-packages/middlewares/test/__init__.py
|
bryan-liu-nova/ZRXFork
| 1,075 |
51025
|
"""Tests of zero_x.middlewares."""
|
plans/migrations/0005_recurring_payments.py
|
feedgurus/django-plans
| 240 |
51054
|
<gh_stars>100-1000
# Generated by Django 3.0.5 on 2020-04-15 07:32
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('plans', '0004_create_user_plans'),
]
operations = [
migrations.AddField(
model_name='planpricing',
name='has_automatic_renewal',
field=models.BooleanField(default=False, help_text='Use automatic renewal if possible?', verbose_name='has automatic renewal'),
),
migrations.AlterField(
model_name='plan',
name='order',
field=models.PositiveIntegerField(db_index=True, editable=False, verbose_name='order'),
),
migrations.AlterField(
model_name='quota',
name='order',
field=models.PositiveIntegerField(db_index=True, editable=False, verbose_name='order'),
),
migrations.CreateModel(
name='RecurringUserPlan',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('token', models.CharField(blank=True, default=None, help_text='Token, that will be used for payment renewal. Depends on used payment provider', max_length=255, null=True, verbose_name='recurring token')),
('payment_provider', models.CharField(blank=True, default=None, help_text='Provider, that will be used for payment renewal', max_length=255, null=True, verbose_name='payment provider')),
('amount', models.DecimalField(blank=True, db_index=True, decimal_places=2, max_digits=7, null=True, verbose_name='amount')),
('tax', models.DecimalField(blank=True, db_index=True, decimal_places=2, max_digits=4, null=True, verbose_name='tax')),
('currency', models.CharField(max_length=3, verbose_name='currency')),
('has_automatic_renewal', models.BooleanField(default=False, help_text='Automatic renewal is enabled for associated plan. If False, the plan renewal can be still initiated by user.', verbose_name='has automatic plan renewal')),
('card_expire_year', models.IntegerField(blank=True, null=True)),
('card_expire_month', models.IntegerField(blank=True, null=True)),
('pricing', models.ForeignKey(blank=True, default=None, help_text='Recurring pricing', null=True, on_delete=django.db.models.deletion.CASCADE, to='plans.Pricing')),
('user_plan', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='recurring', to='plans.UserPlan')),
],
),
]
|
terrascript/resource/terraform_provider_graylog/graylog.py
|
mjuenema/python-terrascript
| 507 |
51077
|
# terrascript/resource/terraform-provider-graylog/graylog.py
# Automatically generated by tools/makecode.py (24-Sep-2021 15:17:31 UTC)
import terrascript
class graylog_alarm_callback(terrascript.Resource):
pass
class graylog_alert_condition(terrascript.Resource):
pass
class graylog_dashboard(terrascript.Resource):
pass
class graylog_dashboard_widget(terrascript.Resource):
pass
class graylog_dashboard_widget_positions(terrascript.Resource):
pass
class graylog_event_definition(terrascript.Resource):
pass
class graylog_event_notification(terrascript.Resource):
pass
class graylog_extractor(terrascript.Resource):
pass
class graylog_grok_pattern(terrascript.Resource):
pass
class graylog_index_set(terrascript.Resource):
pass
class graylog_input(terrascript.Resource):
pass
class graylog_input_static_fields(terrascript.Resource):
pass
class graylog_ldap_setting(terrascript.Resource):
pass
class graylog_output(terrascript.Resource):
pass
class graylog_pipeline(terrascript.Resource):
pass
class graylog_pipeline_connection(terrascript.Resource):
pass
class graylog_pipeline_rule(terrascript.Resource):
pass
class graylog_role(terrascript.Resource):
pass
class graylog_sidecar_collector(terrascript.Resource):
pass
class graylog_sidecar_configuration(terrascript.Resource):
pass
class graylog_sidecars(terrascript.Resource):
pass
class graylog_stream(terrascript.Resource):
pass
class graylog_stream_output(terrascript.Resource):
pass
class graylog_stream_rule(terrascript.Resource):
pass
class graylog_user(terrascript.Resource):
pass
__all__ = [
"graylog_alarm_callback",
"graylog_alert_condition",
"graylog_dashboard",
"graylog_dashboard_widget",
"graylog_dashboard_widget_positions",
"graylog_event_definition",
"graylog_event_notification",
"graylog_extractor",
"graylog_grok_pattern",
"graylog_index_set",
"graylog_input",
"graylog_input_static_fields",
"graylog_ldap_setting",
"graylog_output",
"graylog_pipeline",
"graylog_pipeline_connection",
"graylog_pipeline_rule",
"graylog_role",
"graylog_sidecar_collector",
"graylog_sidecar_configuration",
"graylog_sidecars",
"graylog_stream",
"graylog_stream_output",
"graylog_stream_rule",
"graylog_user",
]
|
projects/ABDNet/eval_acc.py
|
Danish-VSL/deep-person-reid
| 244 |
51142
|
from __future__ import print_function
from __future__ import division
import os
import sys
import time
import datetime
import os.path as osp
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.backends.cudnn as cudnn
from torch.optim import lr_scheduler
from args import argument_parser, image_dataset_kwargs, optimizer_kwargs
from torchreid.data_manager import ImageDataManager
from torchreid import models
from torchreid.losses import CrossEntropyLoss, DeepSupervision
from torchreid.utils.iotools import save_checkpoint, check_isfile
from torchreid.utils.avgmeter import AverageMeter
from torchreid.utils.loggers import Logger, RankLogger
from torchreid.utils.torchtools import count_num_param, open_all_layers, open_specified_layers
from torchreid.utils.reidtools import visualize_ranked_results
from torchreid.eval_metrics import evaluate
from torchreid.optimizers import init_optimizer
from torchreid.regularizers import get_regularizer
from torchreid.losses.wrapped_cross_entropy_loss import WrappedCrossEntropyLoss
from torchreid.models.tricks.dropout import DropoutOptimizer
import logging
logging.basicConfig(level=os.environ.get('LOGLEVEL', 'CRITICAL'))
# global variables
parser = argument_parser()
args = parser.parse_args()
dropout_optimizer = DropoutOptimizer(args)
os.environ['TORCH_HOME'] = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '.torch'))
def accuracy(output, target, topk=(1,)):
"""Computes the accuracy over the k top predictions for
the specified values of k.
Args:
output (torch.Tensor): prediction matrix with shape (batch_size, num_classes).
target (torch.LongTensor): ground truth labels with shape (batch_size).
topk (tuple, optional): accuracy at top-k will be computed. For example,
topk=(1, 5) means accuracy at top-1 and top-5 will be computed.
Returns:
list: accuracy at top-k.
Examples::
>>> from torchreid import metrics
>>> metrics.accuracy(output, target)
"""
maxk = max(topk)
batch_size = target.size(0)
if isinstance(output, (tuple, list)):
output = output[0]
_, pred = output.topk(maxk, 1, True, True)
pred = pred.t()
correct = pred.eq(target.view(1, -1).expand_as(pred))
res = []
for k in topk:
correct_k = correct[:k].view(-1).float().sum(0, keepdim=True)
acc = correct_k.mul_(100.0 / batch_size)
res.append(acc)
return res
def get_criterions(num_classes: int, use_gpu: bool, args) -> ('criterion', 'fix_criterion', 'switch_criterion'):
from torchreid.losses.wrapped_triplet_loss import WrappedTripletLoss
from torchreid.regularizers.param_controller import HtriParamController
htri_param_controller = HtriParamController()
if 'htri' in args.criterion:
fix_criterion = WrappedTripletLoss(num_classes, use_gpu, args, htri_param_controller)
switch_criterion = WrappedTripletLoss(num_classes, use_gpu, args, htri_param_controller)
else:
fix_criterion = WrappedCrossEntropyLoss(num_classes=num_classes, use_gpu=use_gpu, label_smooth=args.label_smooth)
switch_criterion = WrappedCrossEntropyLoss(num_classes=num_classes, use_gpu=use_gpu, label_smooth=args.label_smooth)
if args.criterion == 'xent':
criterion = WrappedCrossEntropyLoss(num_classes=num_classes, use_gpu=use_gpu, label_smooth=args.label_smooth)
elif args.criterion == 'spectral':
from torchreid.losses.spectral_loss import SpectralLoss
criterion = SpectralLoss(num_classes=num_classes, use_gpu=use_gpu, label_smooth=args.label_smooth, penalty_position=args.penalty_position)
elif args.criterion == 'batch_spectral':
from torchreid.losses.batch_spectral_loss import BatchSpectralLoss
criterion = BatchSpectralLoss(num_classes=num_classes, use_gpu=use_gpu, label_smooth=args.label_smooth)
elif args.criterion == 'lowrank':
from torchreid.losses.lowrank_loss import LowRankLoss
criterion = LowRankLoss(num_classes=num_classes, use_gpu=use_gpu, label_smooth=args.label_smooth)
elif args.criterion == 'singular':
from torchreid.losses.singular_loss import SingularLoss
criterion = SingularLoss(num_classes=num_classes, use_gpu=use_gpu, label_smooth=args.label_smooth, penalty_position=args.penalty_position)
elif args.criterion == 'htri':
criterion = WrappedTripletLoss(num_classes=num_classes, use_gpu=use_gpu, args=args, param_controller=htri_param_controller)
elif args.criterion == 'singular_htri':
from torchreid.losses.singular_triplet_loss import SingularTripletLoss
criterion = SingularTripletLoss(num_classes, use_gpu, args, htri_param_controller)
elif args.criterion == 'incidence':
from torchreid.losses.incidence_loss import IncidenceLoss
criterion = IncidenceLoss()
elif args.criterion == 'incidence_xent':
from torchreid.losses.incidence_xent_loss import IncidenceXentLoss
criterion = IncidenceXentLoss(num_classes, use_gpu, args.label_smooth)
else:
raise RuntimeError('Unknown criterion {!r}'.format(criterion))
if args.fix_custom_loss:
fix_criterion = criterion
if args.switch_loss < 0:
criterion, switch_criterion = switch_criterion, criterion
return criterion, fix_criterion, switch_criterion, htri_param_controller
def main():
global args, dropout_optimizer
torch.manual_seed(args.seed)
if not args.use_avai_gpus:
os.environ['CUDA_VISIBLE_DEVICES'] = args.gpu_devices
use_gpu = torch.cuda.is_available()
if args.use_cpu:
use_gpu = False
log_name = 'log_test.txt' if args.evaluate else 'log_train.txt'
sys.stderr = sys.stdout = Logger(osp.join(args.save_dir, log_name))
print("==========\nArgs:{}\n==========".format(args))
if use_gpu:
print("Currently using GPU {}".format(args.gpu_devices))
cudnn.benchmark = True
torch.cuda.manual_seed_all(args.seed)
else:
print("Currently using CPU, however, GPU is highly recommended")
print("Initializing image data manager")
dm = ImageDataManager(use_gpu, **image_dataset_kwargs(args))
trainloader, testloader_dict = dm.return_dataloaders()
print("Initializing model: {}".format(args.arch))
model = models.init_model(name=args.arch, num_classes=dm.num_train_pids, loss={'xent'}, use_gpu=use_gpu, dropout_optimizer=dropout_optimizer)
print(model)
print("Model size: {:.3f} M".format(count_num_param(model)))
# criterion = WrappedCrossEntropyLoss(num_classes=dm.num_train_pids, use_gpu=use_gpu, label_smooth=args.label_smooth)
criterion, fix_criterion, switch_criterion, htri_param_controller = get_criterions(dm.num_train_pids, use_gpu, args)
regularizer, reg_param_controller = get_regularizer(args.regularizer)
optimizer = init_optimizer(model.parameters(), **optimizer_kwargs(args))
scheduler = lr_scheduler.MultiStepLR(optimizer, milestones=args.stepsize, gamma=args.gamma)
if args.load_weights and check_isfile(args.load_weights):
# load pretrained weights but ignore layers that don't match in size
try:
checkpoint = torch.load(args.load_weights)
except Exception as e:
print(e)
checkpoint = torch.load(args.load_weights, map_location={'cuda:0': 'cpu'})
# dropout_optimizer.set_p(checkpoint.get('dropout_p', 0))
# print(list(checkpoint.keys()), checkpoint['dropout_p'])
pretrain_dict = checkpoint['state_dict']
model_dict = model.state_dict()
pretrain_dict = {k: v for k, v in pretrain_dict.items() if k in model_dict and model_dict[k].size() == v.size()}
model_dict.update(pretrain_dict)
model.load_state_dict(model_dict)
print("Loaded pretrained weights from '{}'".format(args.load_weights))
if args.resume and check_isfile(args.resume):
checkpoint = torch.load(args.resume)
state = model.state_dict()
state.update(checkpoint['state_dict'])
model.load_state_dict(state)
# args.start_epoch = checkpoint['epoch'] + 1
print("Loaded checkpoint from '{}'".format(args.resume))
print("- start_epoch: {}\n- rank1: {}".format(args.start_epoch, checkpoint['rank1']))
if use_gpu:
model = nn.DataParallel(model, device_ids=list(range(len(args.gpu_devices.split(','))))).cuda()
extract_train_info(model, trainloader)
def extract_train_info(model, trainloader):
model.eval()
os.environ['fake'] = '1'
accs = [AverageMeter() for _ in range(3)]
with torch.no_grad():
for imgs, pids, _, paths in trainloader:
xent_features = model(imgs.cuda())[1]
for i, xent_feature in enumerate(xent_features):
accs[i].update(
accuracy(xent_feature, pids.cuda())[0].item(),
pids.size(0),
)
with open(args.load_weights + '.acc', 'w') as f:
print(*(acc.avg for acc in accs), file=f)
if __name__ == '__main__':
main()
|
traceback_with_variables/global_hooks.py
|
cclauss/traceback_with_variables
| 550 |
51147
|
import sys
from typing import NoReturn, Optional, Type
from traceback_with_variables.print import print_exc, Format
def global_print_exc(fmt: Optional[Format] = None) -> NoReturn:
sys.excepthook = lambda e_cls, e, tb: print_exc(e=e, fmt=fmt)
def global_print_exc_in_ipython(fmt: Optional[Format] = None) -> NoReturn:
try:
import IPython
except ModuleNotFoundError:
raise ValueError("IPython not found")
IPython.core.interactiveshell.InteractiveShell.showtraceback = \
lambda self, *args, **kwargs: print_exc(num_skipped_frames=1, fmt=fmt)
def is_ipython_global(name: str, type_: Type, filename: str, is_global: bool) -> bool:
return is_global and (
name in ['In', 'Out', 'get_ipython', 'exit', 'quit']
or name.startswith('_')
)
|
v2/backend/admin/__init__.py
|
jonfairbanks/rtsp-nvr
| 558 |
51159
|
<gh_stars>100-1000
from backend.magic import Bundle
from .macro import macro
from .model_admin import ModelAdmin
admin_bundle = Bundle(__name__)
|
umqtt.robust/example_sub_robust.py
|
Carglglz/micropython-lib
| 1,556 |
51197
|
import time
from umqtt.robust import MQTTClient
def sub_cb(topic, msg):
print((topic, msg))
c = MQTTClient("umqtt_client", "localhost")
# Print diagnostic messages when retries/reconnects happens
c.DEBUG = True
c.set_callback(sub_cb)
# Connect to server, requesting not to clean session for this
# client. If there was no existing session (False return value
# from connect() method), we perform the initial setup of client
# session - subscribe to needed topics. Afterwards, these
# subscriptions will be stored server-side, and will be persistent,
# (as we use clean_session=False).
#
# There can be a problem when a session for a given client exists,
# but doesn't have subscriptions a particular application expects.
# In this case, a session needs to be cleaned first. See
# example_reset_session.py for an obvious way how to do that.
#
# In an actual application, it's up to its developer how to
# manage these issues. One extreme is to have external "provisioning"
# phase, where initial session setup, and any further management of
# a session, is done by external tools. This allows to save resources
# on a small embedded device. Another extreme is to have an application
# to perform auto-setup (e.g., clean session, then re-create session
# on each restart). This example shows mid-line between these 2
# approaches, where initial setup of session is done by application,
# but if anything goes wrong, there's an external tool to clean session.
if not c.connect(clean_session=False):
print("New session being set up")
c.subscribe(b"foo_topic")
while 1:
c.wait_msg()
c.disconnect()
|
utils/ProcessorsScheduler.py
|
Leo-xxx/NeuronBlocks
| 1,257 |
51213
|
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT license.
import multiprocessing
from multiprocessing import cpu_count
import math
class ProcessorsScheduler(object):
process_num = cpu_count()
def __init__(self, cpu_num_workers=None):
if cpu_num_workers != None and cpu_num_workers > 0:
self.process_num = cpu_num_workers
def run_data_parallel(self, func, func_args):
data, rest_args = func_args[0], func_args[1:]
res = []
# logging.info("multiprocess enabled, process num: %d" % (self.process_num))
process_p = multiprocessing.Pool(self.process_num)
data_length = len(data)
size = math.ceil(data_length/ self.process_num)
for i in range(self.process_num):
start = size * i
end = (i + 1) * size if (i + 1) * size < data_length else data_length
args = (data[start:end], ) + rest_args
res.append((i, process_p.apply_async(func, args=args)))
process_p.close()
process_p.join()
res = sorted(res, key=lambda x:x[0])
return res
|
stp_zmq/authenticator.py
|
andkononykhin/plenum
| 148 |
51224
|
import sys
import asyncio
import zmq
import zmq.asyncio
from zmq.auth import Authenticator
from zmq.auth.thread import _inherit_docstrings, ThreadAuthenticator, \
AuthenticationThread
# Copying code from zqm classes since no way to inject these dependencies
class MultiZapAuthenticator(Authenticator):
"""
`Authenticator` supports only one ZAP socket in a single process, this lets
you have multiple ZAP sockets
"""
count = 0
def __init__(self, context=None, encoding='utf-8', log=None):
MultiZapAuthenticator.count += 1
super().__init__(context=context, encoding=encoding, log=log)
def start(self):
"""Create and bind the ZAP socket"""
self.zap_socket = self.context.socket(zmq.REP)
self.zap_socket.linger = 1
zapLoc = 'inproc://zeromq.zap.{}'.format(MultiZapAuthenticator.count)
self.zap_socket.bind(zapLoc)
self.log.debug('Starting ZAP at {}'.format(zapLoc))
def stop(self):
"""Close the ZAP socket"""
if self.zap_socket:
self.log.debug(
'Stopping ZAP at {}'.format(self.zap_socket.LAST_ENDPOINT))
super().stop()
@_inherit_docstrings
class ThreadMultiZapAuthenticator(ThreadAuthenticator):
def start(self):
"""Start the authentication thread"""
# create a socket to communicate with auth thread.
self.pipe = self.context.socket(zmq.PAIR)
self.pipe.linger = 1
self.pipe.bind(self.pipe_endpoint)
authenticator = MultiZapAuthenticator(self.context, encoding=self.encoding,
log=self.log)
self.thread = AuthenticationThread(self.context, self.pipe_endpoint,
encoding=self.encoding, log=self.log,
authenticator=authenticator)
self.thread.start()
# Event.wait:Changed in version 2.7: Previously, the method always returned None.
if sys.version_info < (2, 7):
self.thread.started.wait(timeout=10)
else:
if not self.thread.started.wait(timeout=10):
raise RuntimeError("Authenticator thread failed to start")
class AsyncioAuthenticator(MultiZapAuthenticator):
"""ZAP authentication for use in the asyncio IO loop"""
def __init__(self, context=None, loop=None):
super().__init__(context)
self.loop = loop or asyncio.get_event_loop()
self.__poller = None
self.__task = None
# TODO: Remove this commented method later
# @asyncio.coroutine
# def __handle_zap(self):
# while True:
# events = yield from self.__poller.poll()
# if self.zap_socket in dict(events):
# msg = yield from self.zap_socket.recv_multipart()
# self.handle_zap_message(msg)
async def __handle_zap(self):
while True:
events = await self.__poller.poll()
if self.zap_socket in dict(events):
msg = await self.zap_socket.recv_multipart()
self.handle_zap_message(msg)
def start(self):
"""Start ZAP authentication"""
super().start()
self.__poller = zmq.asyncio.Poller()
self.__poller.register(self.zap_socket, zmq.POLLIN)
self.__task = asyncio.ensure_future(self.__handle_zap())
def stop(self):
"""Stop ZAP authentication"""
if self.__task:
self.__task.cancel()
if self.__poller:
self.__poller.unregister(self.zap_socket)
self.__poller = None
super().stop()
|
pysph/tools/tests/test_mesh_tools.py
|
nauaneed/pysph
| 293 |
51227
|
import numpy as np
import unittest
import pytest
from pysph.base.particle_array import ParticleArray
import pysph.tools.mesh_tools as G
from pysph.base.utils import get_particle_array
# Data of a unit length cube
def cube_data():
points = np.array([[0., 0., 0.],
[0., 1., 0.],
[1., 1., 0.],
[1., 0., 0.],
[0., 0., 1.],
[0., 1., 1.],
[1., 0., 1.],
[1., 1., 1.]])
x_cube, y_cube, z_cube = points.T
cells = np.array([[0, 1, 2],
[0, 2, 3],
[0, 4, 5],
[0, 5, 1],
[0, 3, 6],
[0, 6, 4],
[4, 6, 7],
[4, 7, 5],
[3, 2, 7],
[3, 7, 6],
[1, 5, 7],
[1, 7, 2]])
normals = np.array([[0., 0., -1.],
[0., 0., -1.],
[-1., 0., 0.],
[-1., 0., 0.],
[0., -1., 0.],
[0., -1., 0.],
[0., 0., 1.],
[0., 0., 1.],
[1., 0., 0.],
[1., 0., 0.],
[0., 1., 0.],
[0., 1., 0.]])
vectors = np.zeros((len(cells), 3, 3))
for i, cell in enumerate(cells):
idx1, idx2, idx3 = cell
vector = np.array([[x_cube[idx1], y_cube[idx1], z_cube[idx1]],
[x_cube[idx2], y_cube[idx2], z_cube[idx2]],
[x_cube[idx3], y_cube[idx3], z_cube[idx3]]])
vectors[i] = vector
return x_cube, y_cube, z_cube, cells, normals, vectors
class TestGeometry(unittest.TestCase):
def test_in_triangle(self):
assert(G._in_triangle(0.5, 0.5, 0.0, 0.0, 1.5, 0.0, 0.0, 1.5) is True)
assert(G._in_triangle(1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0) is False)
def test_interp_2d(self):
# Check interpolation between two points on line y=x
dx = 0.1
r = G._interp_2d(np.array([0., 0.]), np.array([1., 1.]), dx)
# Check if all points satisfy y=x
np.testing.assert_array_almost_equal(
r[:, 0] - r[:, 1], np.zeros(r.shape[0]))
# Check if distance between consecutive points is lesser than dx
np.testing.assert_array_less(np.linalg.norm(r[1:] - r[0:-1], axis=1),
np.ones(r.shape[0] - 1) * dx)
def test_fill_triangle(self):
triangle = np.array([[0., 0., 0.],
[1., 0., 0.],
[0., 1., 0.]])
dx_triangle = 0.1
x, y, z = G._fill_triangle(triangle, dx_triangle)
EPS = np.finfo(float).eps
np.testing.assert_array_less(-x, np.zeros(x.shape[0]) + EPS)
np.testing.assert_array_less(-y, np.zeros(x.shape[0]) + EPS)
np.testing.assert_array_less(-(x + y), np.ones(x.shape[0]) + EPS)
np.testing.assert_almost_equal(z, np.zeros(x.shape[0]))
def test_fill_triangle_throws_zero_area_triangle_exception(self):
self.assertRaises(G.ZeroAreaTriangleException, G._fill_triangle,
np.zeros((3, 3)), 0.5)
def test_fill_triangle_throws_polygon_mesh_error(self):
self.assertRaises(G.PolygonMeshError, G._fill_triangle,
np.zeros((4, 3)), 0.5)
def test_get_points_from_mgrid(self):
"""Find neighbouring particles around a unit cube"""
h = 0.1
x_cube, y_cube, z_cube, cells, normals, vectors = cube_data()
x, y, z, x_list, y_list, z_list, vectors = \
G._get_surface_mesh(x_cube, y_cube, z_cube, cells, h, uniform=True)
pa_mesh = ParticleArray(name='mesh', x=x, y=y, z=z, h=h)
offset = h
x_grid, y_grid, z_grid = np.meshgrid(
np.arange(x.min() - offset, x.max() + offset, h),
np.arange(y.min() - offset, y.max() + offset, h),
np.arange(z.min() - offset, z.max() + offset, h))
pa_grid = ParticleArray(name='grid', x=x_grid, y=y_grid, z=z_grid, h=h)
x_grid, y_grid, z_grid = G.get_points_from_mgrid(
pa_grid, pa_mesh, x_list, y_list, z_list, 1, h, vectors, normals
)
for i in range(x.shape[0]):
assert((x[i] ** 2 + y[i] ** 2 + z[i] ** 2) <= 4)
def _cube_assert(self, x, y, z, h):
"""Check if x,y,z lie within surface of thickness `h` of a unit cube"""
def surface1(x, y, z): return min(abs(x), abs(1 - x)) < h and \
y > -h and y < 1 + h and z > -h and z < 1 + h
def on_surface(x, y, z): return surface1(x, y, z) or \
surface1(y, x, z) or surface1(z, x, y)
for i in range(x.shape[0]):
assert on_surface(x[i], y[i], z[i])
def test_get_surface_mesh(self):
"""Check if mesh is generated correctly for unit cube"""
x_cube, y_cube, z_cube, cells, normals, vectors = cube_data()
x, y, z = G._get_surface_mesh(x_cube, y_cube, z_cube, cells, 0.1)
h = np.finfo(float).eps
self._cube_assert(x, y, z, h)
def test_get_surface_points(self):
"""Check if surface is generated correctly for unit cube"""
h = 0.1
x_cube, y_cube, z_cube, cells, normals, vectors = cube_data()
x, y, z = G.surface_points(x_cube, y_cube, z_cube, cells, h)
self._cube_assert(x, y, z, h)
def test_get_surface_points_uniform(self):
"""Check if uniform surface is generated correctly for unit cube"""
h = 0.1
x_cube, y_cube, z_cube, cells, normals, vectors = cube_data()
x, y, z = G.surf_points_uniform(x_cube, y_cube, z_cube,
cells, normals, 1.0, 1.0)
self._cube_assert(x, y, z, h)
def test_prism(self):
tri_normal = np.array([0, -1, 0])
tri_points = np.array([[0, 0, 0], [1, 0, 0], [0, 0, 1]])
h = 1/1.5
prism_normals, prism_points, prism_face_centres = \
G.prism(tri_normal, tri_points, h)
assert np.array([-1, 0, 0]) in prism_normals
assert np.array([0, 1, 0]) in prism_points
assert np.array([0.5, 0.5, 0]) in prism_face_centres
if __name__ == "__main__":
unittest.main()
|
mode/examples/Topics/AdvancedData/LoadSaveTable/Bubble.py
|
timgates42/processing.py
| 1,224 |
51277
|
<filename>mode/examples/Topics/AdvancedData/LoadSaveTable/Bubble.py<gh_stars>1000+
# A Bubble class
class Bubble(object):
# Create the Bubble
def __init__(self, x, y, diameter, name):
self.x = x
self.y = y
self.diameter = diameter
self.name = name
self.over = False
# Checking if mouse is over the Bubble
def rollover(self, px, py):
d = dist(px, py, self.x, self.y)
self.over = d < self.diameter / 2
# Display the Bubble
def display(self):
stroke(0)
strokeWeight(2)
noFill()
ellipse(self.x, self.y, self.diameter, self.diameter)
if self.over:
fill(0)
textAlign(CENTER)
text(self.name, self.x, self.y + self.diameter / 2 + 20)
|
etw/evntprov.py
|
tyh2333/pywintrace
| 247 |
51307
|
<filename>etw/evntprov.py
########################################################################
# Copyright 2017 FireEye Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
########################################################################
import ctypes as ct
import ctypes.wintypes as wt
EVENT_FILTER_TYPE_NONE = 0x00000000
EVENT_FILTER_TYPE_SCHEMATIZED = 0x80000000
EVENT_FILTER_TYPE_SYSTEM_FLAGS = 0x80000001
VENT_FILTER_TYPE_TRACEHANDLE = 0x80000002
EVENT_FILTER_TYPE_PID = 0x80000004
EVENT_FILTER_TYPE_EXECUTABLE_NAME = 0x80000008
EVENT_FILTER_TYPE_PACKAGE_ID = 0x80000010
EVENT_FILTER_TYPE_PACKAGE_APP_ID = 0x80000020
EVENT_FILTER_TYPE_PAYLOAD = 0x80000100
EVENT_FILTER_TYPE_EVENT_ID = 0x80000200
EVENT_FILTER_TYPE_STACKWALK = 0x80001000
MAX_EVENT_FILTER_EVENT_ID_COUNT = 64
MAX_EVENT_FILTER_DATA_SIZE = 1024
class EVENT_FILTER_DESCRIPTOR(ct.Structure):
_fields_ = [('Ptr', ct.c_ulonglong),
('Size', ct.c_ulong),
('Type', ct.c_ulong)]
class EVENT_FILTER_HEADER(ct.Structure):
_fields_ = [('Id', wt.USHORT),
('Version', wt.CHAR),
('Reserved', wt.CHAR * 5),
('InstanceId', ct.c_ulonglong),
('Size', wt.ULONG),
('NextOffset', wt.ULONG)]
class EVENT_FILTER_EVENT_ID(ct.Structure):
_fields_ = [('FilterIn', wt.BOOLEAN),
('Reserved', wt.CHAR),
('Count', wt.USHORT),
('Events', wt.USHORT * 0)]
def __init__(self, filter_in, events):
struct_size = len(events) * ct.sizeof(wt.USHORT) + ct.sizeof(EVENT_FILTER_EVENT_ID)
self._buf = (ct.c_char * struct_size)()
self._props = ct.cast(ct.pointer(self._buf), ct.POINTER(EVENT_FILTER_EVENT_ID))
self._props.contents.FilterIn = filter_in
self._props.contents.Reserved = 0
self._props.contents.Count = len(events)
for i in range(len(events)):
ct.memmove(ct.cast(ct.addressof(self._buf) + ct.sizeof(EVENT_FILTER_EVENT_ID) + (ct.sizeof(wt.WCHAR) * i),
ct.c_void_p),
ct.byref(wt.USHORT(events[i])),
ct.sizeof(wt.WCHAR))
def get(self):
return self._props
class EVENT_FILTER_LEVEL_KW(ct.Structure):
_fields_ = [('MatchAnyKeyword', ct.c_ulonglong),
('MatchAllKeyword', ct.c_ulonglong),
('Level', wt.CHAR),
('FilterIn', wt.BOOLEAN)]
class EVENT_FILTER_EVENT_NAME(ct.Structure):
_fields_ = [('MatchAnyKeyword', ct.c_ulonglong),
('MatchAllKeyword', ct.c_ulonglong),
('Level', wt.CHAR),
('FilterIn', wt.BOOLEAN),
('NameCount', wt.USHORT),
('Names', wt.CHAR * 0)]
def __init__(self, match_any, match_all, level, filter_in, names):
struct_size = ((sum([len(name) for name in names]) * ct.sizeof(wt.CHAR)) + (ct.sizeof(wt.CHAR) * len(names))) +\
ct.sizeof(EVENT_FILTER_EVENT_NAME)
self._buf = (ct.c_char * struct_size)()
self._props = ct.cast(ct.pointer(self._buf), ct.POINTER(EVENT_FILTER_EVENT_NAME))
self._props.contents.MatchAnyKeyword = match_any
self._props.contents.MatchAllKeyword = match_all
self._props.contents.Level = level
self._props.contents.FilterIn = filter_in
self._props.contents.NameCount = len(names)
str_off = 0
for i in range(len(names)):
ct.memmove(ct.cast(ct.addressof(self._buf) + ct.sizeof(EVENT_FILTER_EVENT_NAME) + str_off,
ct.c_void_p),
names[i],
len(names[i]))
str_off += len(names[i]) + ct.sizeof(wt.CHAR)
def get(self):
return self._props
class EVENT_DESCRIPTOR(ct.Structure):
_fields_ = [('Id', ct.c_ushort),
('Version', ct.c_ubyte),
('Channel', ct.c_ubyte),
('Level', ct.c_ubyte),
('Opcode', ct.c_ubyte),
('Task', ct.c_ushort),
('Keyword', ct.c_ulonglong)]
|
bindings/python/py_src/tokenizers/tools/visualizer.py
|
AnubhabB/tokenizers
| 5,620 |
51357
|
import os
import itertools
import re
from typing import List, Optional, Tuple, Dict, Callable, Any, NamedTuple
from string import Template
from typing import List
from tokenizers import Tokenizer, Encoding
dirname = os.path.dirname(__file__)
css_filename = os.path.join(dirname, "visualizer-styles.css")
with open(css_filename) as f:
css = f.read()
class Annotation:
start: int
end: int
label: int
def __init__(self, start: int, end: int, label: str):
self.start = start
self.end = end
self.label = label
AnnotationList = List[Annotation]
PartialIntList = List[Optional[int]]
class CharStateKey(NamedTuple):
token_ix: Optional[int]
anno_ix: Optional[int]
class CharState:
char_ix: Optional[int]
def __init__(self, char_ix):
self.char_ix = char_ix
self.anno_ix: Optional[int] = None
self.tokens: List[int] = []
@property
def token_ix(self):
return self.tokens[0] if len(self.tokens) > 0 else None
@property
def is_multitoken(self):
"""
BPE tokenizers can output more than one token for a char
"""
return len(self.tokens) > 1
def partition_key(self) -> CharStateKey:
return CharStateKey(
token_ix=self.token_ix,
anno_ix=self.anno_ix,
)
class Aligned:
pass
class EncodingVisualizer:
"""
Build an EncodingVisualizer
Args:
tokenizer (:class:`~tokenizers.Tokenizer`):
A tokenizer instance
default_to_notebook (:obj:`bool`):
Whether to render html output in a notebook by default
annotation_converter (:obj:`Callable`, `optional`):
An optional (lambda) function that takes an annotation in any format and returns
an Annotation object
"""
unk_token_regex = re.compile("(.{1}\b)?(unk|oov)(\b.{1})?", flags=re.IGNORECASE)
def __init__(
self,
tokenizer: Tokenizer,
default_to_notebook: bool = True,
annotation_converter: Optional[Callable[[Any], Annotation]] = None,
):
if default_to_notebook:
try:
from IPython.core.display import display, HTML
except ImportError as e:
raise Exception(
"""We couldn't import IPython utils for html display.
Are you running in a notebook?
You can also pass `default_to_notebook=False` to get back raw HTML
"""
)
self.tokenizer = tokenizer
self.default_to_notebook = default_to_notebook
self.annotation_coverter = annotation_converter
pass
def __call__(
self,
text: str,
annotations: AnnotationList = [],
default_to_notebook: Optional[bool] = None,
) -> Optional[str]:
"""
Build a visualization of the given text
Args:
text (:obj:`str`):
The text to tokenize
annotations (:obj:`List[Annotation]`, `optional`):
An optional list of annotations of the text. The can either be an annotation class
or anything else if you instantiated the visualizer with a converter function
default_to_notebook (:obj:`bool`, `optional`, defaults to `False`):
If True, will render the html in a notebook. Otherwise returns an html string.
Returns:
The HTML string if default_to_notebook is False, otherwise (default) returns None and
renders the HTML in the notebook
"""
final_default_to_notebook = self.default_to_notebook
if default_to_notebook is not None:
final_default_to_notebook = default_to_notebook
if final_default_to_notebook:
try:
from IPython.core.display import display, HTML
except ImportError as e:
raise Exception(
"""We couldn't import IPython utils for html display.
Are you running in a notebook?"""
)
if self.annotation_coverter is not None:
annotations = list(map(self.annotation_coverter, annotations))
encoding = self.tokenizer.encode(text)
html = EncodingVisualizer.__make_html(text, encoding, annotations)
if final_default_to_notebook:
display(HTML(html))
else:
return html
@staticmethod
def calculate_label_colors(annotations: AnnotationList) -> Dict[str, str]:
"""
Generates a color palette for all the labels in a given set of annotations
Args:
annotations (:obj:`Annotation`):
A list of annotations
Returns:
:obj:`dict`: A dictionary mapping labels to colors in HSL format
"""
if len(annotations) == 0:
return {}
labels = set(map(lambda x: x.label, annotations))
num_labels = len(labels)
h_step = int(255 / num_labels)
if h_step < 20:
h_step = 20
s = 32
l = 64
h = 10
colors = {}
for label in sorted(
labels
): # sort so we always get the same colors for a given set of labels
colors[label] = f"hsl({h},{s}%,{l}%"
h += h_step
return colors
@staticmethod
def consecutive_chars_to_html(
consecutive_chars_list: List[CharState],
text: str,
encoding: Encoding,
):
"""
Converts a list of "consecutive chars" into a single HTML element.
Chars are consecutive if they fall under the same word, token and annotation.
The CharState class is a named tuple with a "partition_key" method that makes it easy to
compare if two chars are consecutive.
Args:
consecutive_chars_list (:obj:`List[CharState]`):
A list of CharStates that have been grouped together
text (:obj:`str`):
The original text being processed
encoding (:class:`~tokenizers.Encoding`):
The encoding returned from the tokenizer
Returns:
:obj:`str`: The HTML span for a set of consecutive chars
"""
first = consecutive_chars_list[0]
if first.char_ix is None:
# its a special token
stoken = encoding.tokens[first.token_ix]
# special tokens are represented as empty spans. We use the data attribute and css
# magic to display it
return f'<span class="special-token" data-stoken={stoken}></span>'
# We're not in a special token so this group has a start and end.
last = consecutive_chars_list[-1]
start = first.char_ix
end = last.char_ix + 1
span_text = text[start:end]
css_classes = [] # What css classes will we apply on the resulting span
data_items = {} # What data attributes will we apply on the result span
if first.token_ix is not None:
# We can either be in a token or not (e.g. in white space)
css_classes.append("token")
if first.is_multitoken:
css_classes.append("multi-token")
if first.token_ix % 2:
# We use this to color alternating tokens.
# A token might be split by an annotation that ends in the middle of it, so this
# lets us visually indicate a consecutive token despite its possible splitting in
# the html markup
css_classes.append("odd-token")
else:
# Like above, but a different color so we can see the tokens alternate
css_classes.append("even-token")
if (
EncodingVisualizer.unk_token_regex.search(encoding.tokens[first.token_ix])
is not None
):
# This is a special token that is in the text. probably UNK
css_classes.append("special-token")
# TODO is this the right name for the data attribute ?
data_items["stok"] = encoding.tokens[first.token_ix]
else:
# In this case we are looking at a group/single char that is not tokenized.
# e.g. white space
css_classes.append("non-token")
css = f'''class="{' '.join(css_classes)}"'''
data = ""
for key, val in data_items.items():
data += f' data-{key}="{val}"'
return f"<span {css} {data} >{span_text}</span>"
@staticmethod
def __make_html(text: str, encoding: Encoding, annotations: AnnotationList) -> str:
char_states = EncodingVisualizer.__make_char_states(text, encoding, annotations)
current_consecutive_chars = [char_states[0]]
prev_anno_ix = char_states[0].anno_ix
spans = []
label_colors_dict = EncodingVisualizer.calculate_label_colors(annotations)
cur_anno_ix = char_states[0].anno_ix
if cur_anno_ix is not None:
# If we started in an annotation make a span for it
anno = annotations[cur_anno_ix]
label = anno.label
color = label_colors_dict[label]
spans.append(f'<span class="annotation" style="color:{color}" data-label="{label}">')
for cs in char_states[1:]:
cur_anno_ix = cs.anno_ix
if cur_anno_ix != prev_anno_ix:
# If we've transitioned in or out of an annotation
spans.append(
# Create a span from the current consecutive characters
EncodingVisualizer.consecutive_chars_to_html(
current_consecutive_chars,
text=text,
encoding=encoding,
)
)
current_consecutive_chars = [cs]
if prev_anno_ix is not None:
# if we transitioned out of an annotation close it's span
spans.append("</span>")
if cur_anno_ix is not None:
# If we entered a new annotation make a span for it
anno = annotations[cur_anno_ix]
label = anno.label
color = label_colors_dict[label]
spans.append(
f'<span class="annotation" style="color:{color}" data-label="{label}">'
)
prev_anno_ix = cur_anno_ix
if cs.partition_key() == current_consecutive_chars[0].partition_key():
# If the current charchter is in the same "group" as the previous one
current_consecutive_chars.append(cs)
else:
# Otherwise we make a span for the previous group
spans.append(
EncodingVisualizer.consecutive_chars_to_html(
current_consecutive_chars,
text=text,
encoding=encoding,
)
)
# An reset the consecutive_char_list to form a new group
current_consecutive_chars = [cs]
# All that's left is to fill out the final span
# TODO I think there is an edge case here where an annotation's span might not close
spans.append(
EncodingVisualizer.consecutive_chars_to_html(
current_consecutive_chars,
text=text,
encoding=encoding,
)
)
res = HTMLBody(spans) # Send the list of spans to the body of our html
return res
@staticmethod
def __make_anno_map(text: str, annotations: AnnotationList) -> PartialIntList:
"""
Args:
text (:obj:`str`):
The raw text we want to align to
annotations (:obj:`AnnotationList`):
A (possibly empty) list of annotations
Returns:
A list of length len(text) whose entry at index i is None if there is no annotation on
charachter i or k, the index of the annotation that covers index i where k is with
respect to the list of annotations
"""
annotation_map = [None] * len(text)
for anno_ix, a in enumerate(annotations):
for i in range(a.start, a.end):
annotation_map[i] = anno_ix
return annotation_map
@staticmethod
def __make_char_states(
text: str, encoding: Encoding, annotations: AnnotationList
) -> List[CharState]:
"""
For each character in the original text, we emit a tuple representing it's "state":
* which token_ix it corresponds to
* which word_ix it corresponds to
* which annotation_ix it corresponds to
Args:
text (:obj:`str`):
The raw text we want to align to
annotations (:obj:`List[Annotation]`):
A (possibly empty) list of annotations
encoding: (:class:`~tokenizers.Encoding`):
The encoding returned from the tokenizer
Returns:
:obj:`List[CharState]`: A list of CharStates, indicating for each char in the text what
it's state is
"""
annotation_map = EncodingVisualizer.__make_anno_map(text, annotations)
# Todo make this a dataclass or named tuple
char_states: List[CharState] = [CharState(char_ix) for char_ix in range(len(text))]
for token_ix, token in enumerate(encoding.tokens):
offsets = encoding.token_to_chars(token_ix)
if offsets is not None:
start, end = offsets
for i in range(start, end):
char_states[i].tokens.append(token_ix)
for char_ix, anno_ix in enumerate(annotation_map):
char_states[char_ix].anno_ix = anno_ix
return char_states
def HTMLBody(children: List[str], css_styles=css) -> str:
"""
Generates the full html with css from a list of html spans
Args:
children (:obj:`List[str]`):
A list of strings, assumed to be html elements
css_styles (:obj:`str`, `optional`):
Optional alternative implementation of the css
Returns:
:obj:`str`: An HTML string with style markup
"""
children_text = "".join(children)
return f"""
<html>
<head>
<style>
{css_styles}
</style>
</head>
<body>
<div class="tokenized-text" dir=auto>
{children_text}
</div>
</body>
</html>
"""
|
core/argo/core/network/s-vae/hyperspherical_vae/ops/ive.py
|
szokejokepu/natural-rws
| 164 |
51366
|
# Copyright 2016 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""The exponentially scaled modified Bessel function of the first kind."""
import numpy as np
import scipy.special
from tensorflow.python.ops import script_ops
from tensorflow.python.ops import array_ops
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import ops
from tensorflow.python.ops.custom_gradient import custom_gradient
@custom_gradient
def ive(v, z):
"""Exponentially scaled modified Bessel function of the first kind."""
output = array_ops.reshape(script_ops.py_func(
lambda v, z: np.select(condlist=[v == 0, v == 1],
choicelist=[scipy.special.i0e(z, dtype=z.dtype),
scipy.special.i1e(z, dtype=z.dtype)],
default=scipy.special.ive(v, z, dtype=z.dtype)), [v, z], z.dtype),
ops.convert_to_tensor(array_ops.shape(z), dtype=dtypes.int32))
def grad(dy):
return None, dy * (ive(v - 1, z) - ive(v, z) * (v + z) / z)
return output, grad
|
py/mistql/cli.py
|
evinism/millieql
| 263 |
51373
|
<reponame>evinism/millieql
#!/usr/bin/env python3
from typing import Union
import argparse
from mistql import __version__
from mistql import query
import sys
import json
import logging
log = logging.getLogger(__name__)
parser = argparse.ArgumentParser(
description="CLI for the python MistQL query language implementation"
)
parser.add_argument("--version", "-v", action="version", version=__version__)
parser.add_argument("query", type=str, help="The query to run")
inputgroup = parser.add_mutually_exclusive_group()
inputgroup.add_argument("--data", "-d", type=str, help="The data to run the query on.")
inputgroup.add_argument(
"--file", "-f", type=str, help="The file to read the data from. Defaults to stdin"
)
parser.add_argument(
"--output", "-o", type=str, help="The output file. Defaults to stdout"
)
parser.add_argument(
"--pretty", "-p", action="store_true", help="Pretty print the output"
)
def main(supplied_args=None):
if supplied_args is None:
args = parser.parse_args()
else:
args = parser.parse_args(supplied_args)
raw_data: Union[str, bytes]
if args.data:
raw_data = args.data
elif args.file:
with open(args.file, 'rb') as f:
raw_data = f.read()
else:
raw_data = sys.stdin.buffer.read()
data = json.loads(raw_data)
out = query(args.query, data)
if args.output:
# TODO: Allow alternate output encodings other than utf-8
out_bytes = json.dumps(
out,
indent=2 if args.pretty else None,
ensure_ascii=False
).encode("utf-8")
with open(args.output, "wb") as f:
f.write(out_bytes)
else:
print(json.dumps(out, indent=2 if args.pretty else None, ensure_ascii=False))
if __name__ == "__main__":
main()
|
malib/algorithm/common/__init__.py
|
ReinholdM/play_football_with_human
| 258 |
51411
|
<filename>malib/algorithm/common/__init__.py
"""
__init__.py
@Organization:
@Author: <NAME>
@Time: 4/22/21 5:28 PM
@Function:
"""
|
python/pyspark_hbase/sql/context.py
|
CrazyZero1/astro
| 365 |
51413
|
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from pyspark.sql import SQLContext
from py4j.java_gateway import java_import
def register(sc):
java_import(sc._gateway.jvm, "org.apache.spark.sql.hbase.HBaseSQLContext")
__all__ = ["HBaseSQLContext"]
class HBaseSQLContext(SQLContext):
"""A variant of Spark SQL that integrates with data stored in HBase.
"""
def __init__(self, sparkContext):
"""Create a new HbaseContext.
@param sparkContext: The SparkContext to wrap.
"""
SQLContext.__init__(self, sparkContext)
self._scala_HBaseSQLContext = self._get_hbase_ctx()
@property
def _ssql_ctx(self):
if self._scala_HBaseSQLContext is None:
print ("loading hbase context ..")
self._scala_HBaseSQLContext = self._get_hbase_ctx()
if self._scala_SQLContext is None:
self._scala_SQLContext = self._scala_HBaseSQLContext
return self._scala_HBaseSQLContext
def _get_hbase_ctx(self):
return self._jvm.HBaseSQLContext(self._jsc.sc())
#TODO: add tests if for main
|
art/estimators/poison_mitigation/strip/__init__.py
|
monshri/adversarial-robustness-toolbox
| 1,350 |
51414
|
"""
STRIP estimators.
"""
from art.estimators.poison_mitigation.strip.strip import STRIPMixin
|
backend/db/friend.py
|
sleepingAnt/viewfinder
| 645 |
51428
|
# Copyright 2012 Viewfinder Inc. All Rights Reserved.
"""Friend relation.
Viewfinder friends define a relationship between two users predicated on confirmation of photo
sharing permission. Each friend has an associated 'status', which can be:
- 'friend': user has been marked as a friend; however, that user may not have the reverse
friendship object.
- 'muted': a friend who has attained special status as an unwanted irritant. Content shared
from these friends is not shown, though still received and can be retrieved.
- 'blocked': a friend who has attained special status as an unwanted irritant. These users will
not show up in suggestions lists and cannot be contacted for sharing.
Friends are different than contacts. Contacts are the full spectrum of social connections. A
contact doesn't become a viewfinder friend until a share has been completed.
NOTE: Next comment is outdated, but we may re-enable something similar in future.
The 'colocated_shares', 'total_shares', 'last_colocated' and 'last_share' values are used to
quantify the strength of the sharing relationship. Each time the users in a friend relationship
are co-located, 'colocated_shares' is decayed based on 'last_colocated' and the current time
and updated either with a +1 if the sharing occurs or a -1 if not. 'total_shares' is similarly
updated, though not just when the users are co-located, but on every share that a user initiates.
Friend: viewfinder friend information
"""
__authors__ = ['<EMAIL> (<NAME>)',
'<EMAIL> (<NAME>)']
import logging
import math
from functools import partial
from tornado import gen
from viewfinder.backend.base import util
from viewfinder.backend.base.exceptions import NotFoundError
from viewfinder.backend.db import db_client, vf_schema
from viewfinder.backend.db.base import DBObject
from viewfinder.backend.db.range_base import DBRangeObject
from viewfinder.backend.op.notification_manager import NotificationManager
@DBObject.map_table_attributes
class Friend(DBRangeObject):
"""Viewfinder friend data object."""
__slots__ = []
_table = DBObject._schema.GetTable(vf_schema.FRIEND)
FRIEND = 'friend'
MUTED = 'muted'
BLOCKED = 'blocked'
FRIEND_ATTRIBUTES = set(['nickname'])
"""Subset of friend attributes that should be projected to the user."""
_SHARE_HALF_LIFE = 60 * 60 * 24 * 30 # 1 month
def __init__(self, user_id=None, friend_id=None):
super(Friend, self).__init__()
self.user_id = user_id
self.friend_id = friend_id
self.status = Friend.FRIEND
def IsBlocked(self):
"""Returns true if the "friend" identified by self.friend_id is blocked."""
return self.status == Friend.BLOCKED
def DecayShares(self, timestamp):
"""Decays 'total_shares' and 'colocated_shares' based on 'timestamp'. Updates 'last_share'
and 'last_colocated' to 'timestamp'.
"""
def _ComputeDecay(shares, last_time):
if last_time is None:
assert shares is None, shares
return 0
decay = math.exp(-math.log(2) * (timestamp - last_time) /
Friend._SHARE_HALF_LIFE)
return shares * decay
self.total_shares = _ComputeDecay(self.total_shares, self.last_share)
self.last_share = timestamp
self.colocated_shares = _ComputeDecay(self.colocated_shares, self.last_colocated)
self.last_colocated = timestamp
def IncrementShares(self, timestamp, shared, colocated):
"""Decays and updates 'total_shares' and 'last_share' based on whether sharing occurred
('shared'==True). If 'colocated', the 'colocated_shares' and 'last_colocated' are updated
similarly.
"""
self.DecayShares(timestamp)
self.total_shares += (1.0 if shared else -1.0)
if colocated:
self.colocated_shares += (1.0 if shared else -1.0)
@classmethod
@gen.engine
def MakeFriends(cls, client, user_id, friend_id, callback):
"""Creates a bi-directional friendship between user_id and friend_id if it does not already
exist. Invokes the callback with the pair of friendship objects:
[(user_id=>friend_id), (friend_id=>user_id)]
"""
from viewfinder.backend.db.user import User
# Determine whether one or both sides of the friendship are missing.
forward_friend, reverse_friend = \
yield [gen.Task(Friend.Query, client, user_id, friend_id, None, must_exist=False),
gen.Task(Friend.Query, client, friend_id, user_id, None, must_exist=False)]
# Make sure that both sides of the friendship have been created.
if forward_friend is None:
forward_friend = Friend.CreateFromKeywords(user_id=user_id, friend_id=friend_id, status=Friend.FRIEND)
yield gen.Task(forward_friend.Update, client)
if reverse_friend is None:
reverse_friend = Friend.CreateFromKeywords(user_id=friend_id, friend_id=user_id, status=Friend.FRIEND)
yield gen.Task(reverse_friend.Update, client)
callback((forward_friend, reverse_friend))
@classmethod
@gen.engine
def MakeFriendsWithGroup(cls, client, user_ids, callback):
"""Creates bi-directional friendships between all the specified users. Each user will be
friends with every other user.
"""
yield [gen.Task(Friend.MakeFriends, client, user_id, friend_id)
for index, user_id in enumerate(user_ids)
for friend_id in user_ids[index + 1:]
if user_id != friend_id]
callback()
@classmethod
@gen.engine
def MakeFriendAndUpdate(cls, client, user_id, friend_dict, callback):
"""Ensures that the given user has at least a one-way friend relationship with the given
friend. Updates the friend relationship attributes with those given in "friend_dict".
"""
from viewfinder.backend.db.user import User
friend = yield gen.Task(Friend.Query, client, user_id, friend_dict['user_id'], None, must_exist=False)
if friend is None:
# Ensure that the friend exists as user in the system.
friend_user = yield gen.Task(User.Query, client, friend_dict['user_id'], None, must_exist=False)
if friend_user is None:
raise NotFoundError('User %d does not exist.' % friend_dict['user_id'])
# Create a one-way friend relationship from the calling user to the friend user.
friend = Friend.CreateFromKeywords(user_id=user_id, friend_id=friend_dict['user_id'], status=Friend.FRIEND)
# Update all given attributes.
assert friend_dict['user_id'] == friend.friend_id, (friend_dict, friend)
for key, value in friend_dict.iteritems():
if key != 'user_id':
assert key in Friend.FRIEND_ATTRIBUTES, friend_dict
setattr(friend, key, value)
yield gen.Task(friend.Update, client)
callback()
@classmethod
@gen.engine
def UpdateOperation(cls, client, callback, user_id, friend):
"""Updates friend metadata for the relationship between the given user and friend."""
# Update the metadata.
yield gen.Task(Friend.MakeFriendAndUpdate, client, user_id, friend)
# Send notifications to all the calling user's devices.
yield NotificationManager.NotifyUpdateFriend(client, friend)
callback()
|
samples/vsphere/contentlibrary/vmtemplate/create_vm_template.py
|
restapicoding/VMware-SDK
| 589 |
51445
|
<reponame>restapicoding/VMware-SDK
#!/usr/bin/env python
"""
* *******************************************************
* Copyright VMware, Inc. 2017-2018. All Rights Reserved.
* SPDX-License-Identifier: MIT
* *******************************************************
*
* DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN,
* EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED
* WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY,
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
"""
__author__ = 'VMware, Inc.'
__vcenter_version__ = '6.6.2+'
from com.vmware.vcenter.vm_template_client import (
LibraryItems as VmtxLibraryItem)
from vmware.vapi.vsphere.client import create_vsphere_client
from samples.vsphere.common.id_generator import rand
from samples.vsphere.common.sample_base import SampleBase
from samples.vsphere.common.ssl_helper import get_unverified_session
from samples.vsphere.contentlibrary.lib.cls_api_client import ClsApiClient
from samples.vsphere.contentlibrary.lib.cls_api_helper import ClsApiHelper
from samples.vsphere.vcenter.helper.resource_pool_helper import (
get_resource_pool)
from samples.vsphere.vcenter.helper.vm_helper import get_vm
class CreateVmTemplate(SampleBase):
"""
Demonstrates how to create a library item containing a virtual machine
template from a virtual machine.
Prerequisites:
- A virtual machine
- A datacenter
- A resource pool
- A datastore
"""
def __init__(self):
SampleBase.__init__(self, self.__doc__)
self.servicemanager = None
self.client = None
self.helper = None
self.vm_name = None
self.datastore_name = None
self.library_name = 'demo-vmtx-lib'
self.item_name = None
self.item_id = None
def _options(self):
self.argparser.add_argument('-vmname', '--vmname',
required=True,
help='The name of the source VM from '
'which to create a library item')
self.argparser.add_argument('-datacentername', '--datacentername',
required=True,
help='The name of the datacenter in which '
'to place the VM template')
self.argparser.add_argument('-resourcepoolname', '--resourcepoolname',
required=True,
help='The name of the resource pool in '
'the datacenter in which to place '
'the VM template')
self.argparser.add_argument('-datastorename', '--datastorename',
required=True,
help='The name of the datastore in which '
'to create a library and VM template')
self.argparser.add_argument('-itemname', '--itemname',
help='The name of the library item to '
'create. The item will contain a '
'VM template.')
def _setup(self):
# Required arguments
self.vm_name = self.args.vmname
self.datacenter_name = self.args.datacentername
self.resource_pool_name = self.args.resourcepoolname
self.datastore_name = self.args.datastorename
# Optional arguments
self.item_name = (self.args.itemname if self.args.itemname
else rand('vmtx-item-'))
self.servicemanager = self.get_service_manager()
self.client = ClsApiClient(self.servicemanager)
self.helper = ClsApiHelper(self.client, self.skip_verification)
session = get_unverified_session() if self.skip_verification else None
self.vsphere_client = create_vsphere_client(server=self.server,
username=self.username,
password=self.password,
session=session)
def _execute(self):
# Get the identifiers
vm_id = get_vm(self.vsphere_client, self.vm_name)
assert vm_id
resource_pool_id = get_resource_pool(self.vsphere_client,
self.datacenter_name,
self.resource_pool_name)
assert resource_pool_id
# Create a library
storage_backings = self.helper.create_storage_backings(
self.servicemanager, self.datastore_name)
self.library_id = self.helper.create_local_library(storage_backings,
self.library_name)
# Build the create specification
create_spec = VmtxLibraryItem.CreateSpec()
create_spec.source_vm = vm_id
create_spec.library = self.library_id
create_spec.name = self.item_name
create_spec.placement = VmtxLibraryItem.CreatePlacementSpec(
resource_pool=resource_pool_id)
# Create a new library item from the source VM
self.item_id = self.client.vmtx_service.create(create_spec)
print("Created VM template item '{0}' with ID: {1}".format(
self.item_name, self.item_id))
# Retrieve the library item info
info = self.client.vmtx_service.get(self.item_id)
print('VM template guest OS: {0}'.format(info.guest_os))
def _cleanup(self):
if self.library_id:
self.client.local_library_service.delete(self.library_id)
print('Deleted library ID: {0}'.format(self.library_id))
def main():
sample = CreateVmTemplate()
sample.main()
if __name__ == '__main__':
main()
|
test/jpypetest/test_sql_generic.py
|
pitmanst/jpype
| 531 |
51460
|
# This file is Public Domain and may be used without restrictions.
import _jpype
import jpype
from jpype.types import *
from jpype import java
import jpype.dbapi2 as dbapi2
import common
import time
try:
import zlib
except ImportError:
zlib = None
class SQLModuleTestCase(common.JPypeTestCase):
def setUp(self):
common.JPypeTestCase.setUp(self)
def assertIsSubclass(self, a, b):
self.assertTrue(issubclass(a, b), "`%s` is not a subclass of `%s`" % (a.__name__, b.__name__))
def testConstants(self):
self.assertEqual(dbapi2.apilevel, "2.0")
self.assertEqual(dbapi2.threadsafety, 2)
self.assertEqual(dbapi2.paramstyle, "qmark")
def testExceptions(self):
self.assertIsSubclass(dbapi2.Warning, Exception)
self.assertIsSubclass(dbapi2.Error, Exception)
self.assertIsSubclass(dbapi2.InterfaceError, dbapi2.Error)
self.assertIsSubclass(dbapi2.DatabaseError, dbapi2.Error)
self.assertIsSubclass(dbapi2._SQLException, dbapi2.Error)
self.assertIsSubclass(dbapi2.DataError, dbapi2.DatabaseError)
self.assertIsSubclass(dbapi2.OperationalError, dbapi2.DatabaseError)
self.assertIsSubclass(dbapi2.IntegrityError, dbapi2.DatabaseError)
self.assertIsSubclass(dbapi2.InternalError, dbapi2.DatabaseError)
self.assertIsSubclass(dbapi2.InternalError, dbapi2.DatabaseError)
self.assertIsSubclass(dbapi2.ProgrammingError, dbapi2.DatabaseError)
self.assertIsSubclass(dbapi2.NotSupportedError, dbapi2.DatabaseError)
def testConnectionExceptions(self):
cx = dbapi2.Connection
self.assertEqual(cx.Warning, dbapi2.Warning)
self.assertEqual(cx.Error, dbapi2.Error)
self.assertEqual(cx.InterfaceError, dbapi2.InterfaceError)
self.assertEqual(cx.DatabaseError, dbapi2.DatabaseError)
self.assertEqual(cx.DataError, dbapi2.DataError)
self.assertEqual(cx.OperationalError, dbapi2.OperationalError)
self.assertEqual(cx.IntegrityError, dbapi2.IntegrityError)
self.assertEqual(cx.InternalError, dbapi2.InternalError)
self.assertEqual(cx.InternalError, dbapi2.InternalError)
self.assertEqual(cx.ProgrammingError, dbapi2.ProgrammingError)
self.assertEqual(cx.NotSupportedError, dbapi2.NotSupportedError)
def test_Date(self):
d1 = dbapi2.Date(2002, 12, 25) # noqa F841
d2 = dbapi2.DateFromTicks( # noqa F841
time.mktime((2002, 12, 25, 0, 0, 0, 0, 0, 0))
)
# Can we assume this? API doesn't specify, but it seems implied
# self.assertEqual(str(d1),str(d2))
def test_Time(self):
t1 = dbapi2.Time(13, 45, 30) # noqa F841
t2 = dbapi2.TimeFromTicks( # noqa F841
time.mktime((2001, 1, 1, 13, 45, 30, 0, 0, 0))
)
# Can we assume this? API doesn't specify, but it seems implied
# self.assertEqual(str(t1),str(t2))
def test_Timestamp(self):
t1 = dbapi2.Timestamp(2002, 12, 25, 13, 45, 30) # noqa F841
t2 = dbapi2.TimestampFromTicks( # noqa F841
time.mktime((2002, 12, 25, 13, 45, 30, 0, 0, 0))
)
# Can we assume this? API doesn't specify, but it seems implied
# self.assertEqual(str(t1),str(t2))
def test_Binary(self):
b = dbapi2.Binary(b"Something")
b = dbapi2.Binary(b"") # noqa F841
def test_STRING(self):
self.assertTrue(hasattr(dbapi2, "STRING"), "module.STRING must be defined")
def test_BINARY(self):
self.assertTrue(
hasattr(dbapi2, "BINARY"), "module.BINARY must be defined."
)
def test_NUMBER(self):
self.assertTrue(
hasattr(dbapi2, "NUMBER"), "module.NUMBER must be defined."
)
def test_DATETIME(self):
self.assertTrue(
hasattr(dbapi2, "DATETIME"), "module.DATETIME must be defined."
)
def test_ROWID(self):
self.assertTrue(hasattr(dbapi2, "ROWID"), "module.ROWID must be defined.")
class SQLTablesTestCase(common.JPypeTestCase):
def setUp(self):
common.JPypeTestCase.setUp(self)
def testStr(self):
for i in dbapi2._types:
self.assertIsInstance(str(i), str)
def testRepr(self):
for i in dbapi2._types:
self.assertIsInstance(repr(i), str)
|
demo/evaluation/SP_GoogLeNet.py
|
ntoussaint/SPN.pytorch
| 228 |
51497
|
<reponame>ntoussaint/SPN.pytorch<filename>demo/evaluation/SP_GoogLeNet.py<gh_stars>100-1000
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Function, Variable
from torch.utils.serialization import load_lua
from spn import SoftProposal, SpatialSumOverMap, hook_spn, unhook_spn
class CallLegacyModel(Function):
@staticmethod
def forward(ctx, model, x):
if x.is_cuda:
return model.cuda().forward(x)
else:
return model.float().forward(x)
@staticmethod
def backward(ctx, *args, **kwargs):
raise NotImplementedError('The backward call of LegacyModel is not implemented')
class LegacyModel(nn.Module):
def __init__(self, model):
super(LegacyModel, self).__init__()
self.model = model
def forward(self, x):
return CallLegacyModel.apply(self.model, x)
def __repr__(self):
return '{}({})'.format(self.__class__.__name__, repr(self.model))
class SP_GoogLeNet(nn.Module):
def __init__(self, state_dict='SP_GoogleNet_ImageNet.pt'):
super(SP_GoogLeNet, self).__init__()
state_dict = load_lua(state_dict)
pretrained_model = state_dict[0]
pretrained_model.evaluate()
self.features = LegacyModel(pretrained_model)
self.pooling = nn.Sequential()
self.pooling.add_module('adconv', nn.Conv2d(832, 1024, kernel_size=3, stride=1, padding=1, groups=2, bias=True))
self.pooling.add_module('maps', nn.ReLU())
self.pooling.add_module('sp', SoftProposal(factor=2.1))
self.pooling.add_module('sum', SpatialSumOverMap())
self.pooling.adconv.weight.data.copy_(state_dict[1][0])
self.pooling.adconv.bias.data.copy_(state_dict[1][1])
# classification layer
self.classifier = nn.Linear(1024, 1000)
self.classifier.weight.data.copy_(state_dict[2][0])
self.classifier.bias.data.copy_(state_dict[2][1])
# image normalization
self.image_normalization_mean = [0.485, 0.456, 0.406]
self.image_normalization_std = [0.229, 0.224, 0.225]
def forward(self, x):
x = self.features(x)
x = self.pooling(x)
x = x.view(x.size(0), -1)
x = self.classifier(x)
return x
def inference(self, mode=True):
hook_spn(self) if mode else unhook_spn(self)
return self
|
test/core/derivatives/implementation/backpack.py
|
jabader97/backpack
| 395 |
51527
|
"""Contains derivative calculation with BackPACK."""
from test.core.derivatives.implementation.base import DerivativesImplementation
from test.utils import chunk_sizes
from typing import List
from torch import Tensor, einsum, zeros
from backpack.utils.subsampling import subsample
class BackpackDerivatives(DerivativesImplementation):
"""Derivative implementations with BackPACK."""
def __init__(self, problem):
"""Initialization.
Args:
problem: test problem
"""
problem.extend()
super().__init__(problem)
def store_forward_io(self):
"""Do one forward pass.
This implicitly saves relevant quantities for backward pass.
"""
self.problem.forward_pass()
def jac_mat_prod(self, mat): # noqa: D102
self.store_forward_io()
return self.problem.derivative.jac_mat_prod(
self.problem.module, None, None, mat
)
def jac_t_mat_prod(
self, mat: Tensor, subsampling: List[int]
) -> Tensor: # noqa: D102
self.store_forward_io()
return self.problem.derivative.jac_t_mat_prod(
self.problem.module, None, None, mat, subsampling=subsampling
)
def param_mjp(
self,
param_str: str,
mat: Tensor,
sum_batch: bool,
subsampling: List[int] = None,
) -> Tensor: # noqa: D102
self.store_forward_io()
return self.problem.derivative.param_mjp(
param_str,
self.problem.module,
None,
None,
mat,
sum_batch=sum_batch,
subsampling=subsampling,
)
def weight_jac_mat_prod(self, mat): # noqa: D102
self.store_forward_io()
return self.problem.derivative.weight_jac_mat_prod(
self.problem.module, None, None, mat
)
def bias_jac_mat_prod(self, mat): # noqa: D102
self.store_forward_io()
return self.problem.derivative.bias_jac_mat_prod(
self.problem.module, None, None, mat
)
def ea_jac_t_mat_jac_prod(self, mat): # noqa: D102
self.store_forward_io()
return self.problem.derivative.ea_jac_t_mat_jac_prod(
self.problem.module, None, None, mat
)
def sum_hessian(self): # noqa: D102
self.store_forward_io()
return self.problem.derivative.sum_hessian(self.problem.module, None, None)
def input_hessian_via_sqrt_hessian(
self, mc_samples: int = None, chunks: int = 1, subsampling: List[int] = None
) -> Tensor:
"""Computes the Hessian w.r.t. to the input from its matrix square root.
Args:
mc_samples: If int, uses an MC approximation with the specified
number of samples. If None, uses the exact hessian. Defaults to None.
chunks: Maximum sequential split of the computation. Default: ``1``.
Only used if mc_samples is specified.
subsampling: Indices of active samples. ``None`` uses all samples.
Returns:
Hessian with respect to the input. Has shape
``[N, A, B, ..., N, A, B, ...]`` where ``N`` is the batch size or number
of active samples when sub-sampling is used, and ``[A, B, ...]`` are the
input's feature dimensions.
"""
self.store_forward_io()
if mc_samples is not None:
chunk_samples = chunk_sizes(mc_samples, chunks)
chunk_weights = [samples / mc_samples for samples in chunk_samples]
individual_hessians: Tensor = sum(
weight
* self._sample_hessians_from_sqrt(
self.problem.derivative.sqrt_hessian_sampled(
self.problem.module,
None,
None,
mc_samples=samples,
subsampling=subsampling,
)
)
for weight, samples in zip(chunk_weights, chunk_samples)
)
else:
sqrt_hessian = self.problem.derivative.sqrt_hessian(
self.problem.module, None, None, subsampling=subsampling
)
individual_hessians = self._sample_hessians_from_sqrt(sqrt_hessian)
input0 = subsample(self.problem.module.input0, subsampling=subsampling)
return self._embed_sample_hessians(individual_hessians, input0)
def hessian_is_zero(self) -> bool: # noqa: D102
return self.problem.derivative.hessian_is_zero(self.problem.module)
def _sample_hessians_from_sqrt(self, sqrt: Tensor) -> Tensor:
"""Convert individual matrix square root into individual full matrix.
Args:
sqrt: individual square root of hessian
Returns:
Individual Hessians of shape ``[N, A, B, ..., A, B, ...]`` where
``input.shape[1:] = [A, B, ...]`` are the input feature dimensions
and ``N`` is the batch size.
"""
N, input_dims = sqrt.shape[1], sqrt.shape[2:]
sqrt_flat = sqrt.flatten(start_dim=2)
sample_hessians = einsum("vni,vnj->nij", sqrt_flat, sqrt_flat)
return sample_hessians.reshape(N, *input_dims, *input_dims)
def _embed_sample_hessians(
self, individual_hessians: Tensor, input: Tensor
) -> Tensor:
"""Embed Hessians w.r.t. individual samples into Hessian w.r.t. all samples.
Args:
individual_hessians: Hessians w.r.t. individual samples in the input.
input: Inputs for the for samples whose individual Hessians are passed.
Has shape ``[N, A, B, ..., A, B, ...]`` where ``N`` is the number of
active samples and ``[A, B, ...]`` are the feature dimensions.
Returns:
Hessian that contains the individual Hessians as diagonal blocks.
Has shape ``[N, A, B, ..., N, A, B, ...]``.
"""
N, D = input.shape[0], input.shape[1:].numel()
hessian = zeros(N, D, N, D, device=input.device, dtype=input.dtype)
for n in range(N):
hessian[n, :, n, :] = individual_hessians[n].reshape(D, D)
return hessian.reshape(*input.shape, *input.shape)
def hessian_mat_prod(self, mat: Tensor) -> Tensor: # noqa: D102
self.store_forward_io()
hmp = self.problem.derivative.make_hessian_mat_prod(
self.problem.module, None, None
)
return hmp(mat)
|
src/genie/libs/parser/iosxe/tests/ShowIsisHostname/cli/equal/golden_output_expected.py
|
balmasea/genieparser
| 204 |
51601
|
expected_output = {
"tag": {
"VRF1": {
"hostname_db": {
"hostname": {
"7777.77ff.eeee": {"hostname": "R7", "level": 2},
"2222.22ff.4444": {"hostname": "R2", "local_router": True},
}
}
},
"test": {
"hostname_db": {
"hostname": {
"9999.99ff.3333": {"hostname": "R9", "level": 2},
"8888.88ff.1111": {"hostname": "R8", "level": 2},
"7777.77ff.eeee": {"hostname": "R7", "level": 2},
"5555.55ff.aaaa": {"hostname": "R5", "level": 2},
"3333.33ff.6666": {"hostname": "R3", "level": 2},
"1111.11ff.2222": {"hostname": "R1", "level": 1},
"2222.22ff.4444": {"hostname": "R2", "local_router": True},
}
}
},
}
}
|
Sources/Workflows/ONE「一个」/one.py
|
hzlzh/AlfredWorkflow.com
| 2,177 |
51618
|
<gh_stars>1000+
#!/usr/bin/python
#coding=utf-8
#
#
# Copyright (c) 2016 fusijie <<EMAIL>>
#
# MIT Licence. See http://opensource.org/licenses/MIT
#
# Created on 2016-04-22
#
import sys
import os
from workflow import Workflow, web
reading_url = 'http://v3.wufazhuce.com:8000/api/reading/index'
essay_url_prefix = 'http://wufazhuce.com/article/'
serial_url_prefix = 'http://m.wufazhuce.com/serial/'
question_url_prefix = 'http://wufazhuce.com/question/'
default_thumsnail = 'icon.png'
def _get_reading_url():
return reading_url
def _parse_reading():
data = web.get(_get_reading_url()).json()
return data
def _get_thumbnail():
return default_thumsnail
def _get_reading(wf):
data = wf.cached_data('one_reading', _parse_reading, max_age = 30)
reading_data = data['data']
if sys.argv[1] == 'essay':
essays = reading_data['essay']
for essay in essays:
essay_title = essay['hp_title']
essay_subtitle = essay['guide_word']
essay_thumbnail = essay['author'][0]['web_url']
essay_url = essay_url_prefix + essay['content_id']
wf.add_item(title = essay_title, subtitle = essay_subtitle, icon = _get_thumbnail(), arg = essay_url, valid = True)
wf.send_feedback()
elif sys.argv[1] == 'serial':
serials = reading_data['serial']
for serial in serials:
serial_title = serial['title']
serial_subtitle = serial['excerpt']
serial_thumbnail = serial['author']['web_url']
serial_url = serial_url_prefix + serial['id']
wf.add_item(title = serial_title, subtitle = serial_subtitle, icon = _get_thumbnail(), arg = serial_url, valid = True)
wf.send_feedback()
elif sys.argv[1] == 'question':
questions = reading_data['question']
for question in questions:
question_title = question['question_title']
question_subtitle = question['answer_content']
question_url = question_url_prefix + question['question_id']
wf.add_item(title = question_title, subtitle = question_subtitle, icon = _get_thumbnail(), arg = question_url, valid = True)
wf.send_feedback()
def main(wf):
try:
_get_reading(wf)
except:
pass
if __name__ == '__main__':
wf = Workflow()
sys.exit(wf.run(main))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.